Build Linux VM in packer.

This makes some other changes:
* Moves packer related files to packer directory.
* Updates build scripts for new packer directory.
* Renames boxes to metasploitabl3-<OS>
This commit is contained in:
James Barnett 2017-07-31 15:48:27 -05:00
parent b4b47b5e06
commit 520c0564be
13 changed files with 426 additions and 279 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.vagrant/
packer_cache/
packer/builds/
*.exe
*.msi
*.msu

64
Vagrantfile vendored
View File

@ -2,10 +2,24 @@
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define "ub1404" do |ub1404|
ub1404.vm.box = "metasploitable3-ub1404"
ub1404.vm.hostname = "metasploitable3_ub1404"
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
ub1404.vm.network "private_network", ip: '172.28.128.3'
ub1404.vm.provider "virtualbox" do |v|
v.name = "Metasploitable-ub1404"
v.memory = 2048
end
end
config.vm.define "win2k8" do |win2k8|
# Base configuration for the VM and provisioner
win2k8.vm.box = "metasploitable3"
win2k8.vm.hostname = "metasploitable3"
win2k8.vm.box = "metasploitable3-win2k8"
win2k8.vm.hostname = "metasploitable3_win2k8"
win2k8.vm.communicator = "winrm"
win2k8.winrm.retry_limit = 60
win2k8.winrm.retry_delay = 10
@ -27,50 +41,4 @@ Vagrant.configure("2") do |config|
win2k8.vm.provision :shell, path: "scripts/installs/setup_linux_share.bat"
win2k8.vm.provision :shell, inline: "rm C:\\tmp\\vagrant-shell.bat" # Hack for this bug: https://github.com/mitchellh/vagrant/issues/7614
end
config.vm.define "trusty" do |trusty|
trusty.vm.box = "rsginc/ubuntu64-14-04-1"
trusty.vm.hostname = "metasploitableUB"
trusty.vm.network "private_network", ip: '172.28.128.3'
trusty.vm.provider "virtualbox" do |v|
v.name = "MetasploitableUB"
v.memory = 2048
end
config.omnibus.chef_version = :latest
# Provision with Chef Solo
#
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = [ 'chef/cookbooks' ]
chef.json = { 'metasploitable' => {
# Customizations here
}
}
chef.add_recipe "metasploitable::mysql"
chef.add_recipe "metasploitable::apache_continuum"
chef.add_recipe "metasploitable::apache"
chef.add_recipe "metasploitable::php_545"
chef.add_recipe "metasploitable::phpmyadmin"
chef.add_recipe "metasploitable::proftpd"
chef.add_recipe "metasploitable::users"
chef.add_recipe "metasploitable::docker"
chef.add_recipe "metasploitable::samba"
chef.add_recipe "metasploitable::sinatra"
chef.add_recipe "metasploitable::unrealircd"
chef.add_recipe "metasploitable::chatbot"
chef.add_recipe "metasploitable::payroll_app"
chef.add_recipe "metasploitable::readme_app"
chef.add_recipe "metasploitable::cups"
chef.add_recipe "metasploitable::drupal"
chef.add_recipe "metasploitable::knockd"
chef.add_recipe "metasploitable::iptables"
chef.add_recipe "metasploitable::flags"
chef.add_recipe "metasploitable::clear_cache"
end
end
end

View File

@ -95,11 +95,11 @@ If (![string]::IsNullOrEmpty($vagrantPlugins)) {
Write-Host "All requirements found. Proceeding..."
If ($(Test-Path "windows_2008_r2_virtualbox.box") -eq $True) {
If ($(Test-Path "packer\templates\windows_2008_r2_virtualbox.box") -eq $True) {
Write-Host "It looks like the Vagrant box already exists. Skipping the Packer build."
} else {
Write-Host "Building the Vagrant box..."
cmd.exe /c packer build --only=virtualbox-iso windows_2008_r2.json
cmd.exe /c packer build --only=virtualbox-iso packer\templates\windows_2008_r2.json
if($?) {
Write-Host "Box successfully built by Packer."
@ -110,15 +110,15 @@ If ($(Test-Path "windows_2008_r2_virtualbox.box") -eq $True) {
echo "Attempting to add the box to Vagrant..."
$vagrant_box_list = cmd.exe /c "vagrant box list" | select-string -pattern "metasploitable3"
$vagrant_box_list = cmd.exe /c "vagrant box list" | select-string -pattern "metasploitable3-win2k8"
If ($vagrant_box_list) { $vagrant_box_list = $vagrant_box_list.ToString().Trim() }
If ($vagrant_box_list -eq "metasploitable3") {
Write-Host "metasploitable3 already found in Vagrant box repository. Skipping the addition to Vagrant."
If ($vagrant_box_list -eq "metasploitable3-win2k8") {
Write-Host "metasploitable3-win2k8 already found in Vagrant box repository. Skipping the addition to Vagrant."
} else {
cmd.exe /c vagrant box add metasploitable3 windows_2008_r2_virtualbox.box
cmd.exe /c vagrant box add metasploitable3-win2k8 packer\builds\windows_2008_r2_virtualbox.box
if($?) {
Write-Host "Box successfully added to Vagrant."

View File

@ -97,11 +97,11 @@ fi
echo "All requirements found. Proceeding..."
if ls | grep -q 'windows_2008_r2_virtualbox.box'; then
if ls packer/builds/ | grep -q 'windows_2008_r2_virtualbox.box'; then
echo "It looks like the vagrant box already exists. Skipping the Packer build."
else
echo "Building the Vagrant box..."
if $packer_bin build --only=virtualbox-iso windows_2008_r2.json; then
if $packer_bin build --only=virtualbox-iso packer/templates/windows_2008_r2.json; then
echo "Box successfully built by Packer."
else
echo "Error building the Vagrant box using Packer. Please check the output above for any error messages."
@ -111,11 +111,11 @@ fi
echo "Attempting to add the box to Vagrant..."
if vagrant box list | grep -q 'metasploitable3'; then
if vagrant box list | grep -q 'metasploitable3-win2k8'; then
echo 'metasploitable3 already found in Vagrant box repository. Skipping the addition to Vagrant.'
echo "NOTE: If you are having issues, try starting over by doing 'vagrant destroy' and then 'vagrant up'."
else
if vagrant box add windows_2008_r2_virtualbox.box --name metasploitable3; then
if vagrant box add packer/builds/windows_2008_r2_virtualbox.box --name metasploitable3-win2k8; then
echo "Box successfully added to Vagrant."
else
echo "Error adding box to Vagrant. See the above output for any error messages."

View File

@ -10,6 +10,7 @@ include_recipe 'metasploitable::php_545'
drupal_tar = "drupal-#{node[:drupal][:version]}.tar.gz"
coder_tar = "coder-7.x-2.5.tar.gz"
files_path = File.join(Chef::Config[:file_cache_path], 'cookbooks', 'metasploitable', 'files', 'drupal')
remote_file "#{Chef::Config[:file_cache_path]}/#{drupal_tar}" do
source "#{node[:drupal][:download_url]}/#{drupal_tar}"
@ -42,7 +43,7 @@ end
execute 'untar default site' do
cwd node[:drupal][:sites_dir]
command "tar xvzf #{node[:drupal][:files_path]}/default_site.tar.gz"
command "tar xvzf #{File.join(files_path, 'default_site.tar.gz')}"
not_if { ::File.exists?(File.join(node[:drupal][:default_site_dir], 'settings.php')) }
not_if { ::File.directory?(File.join(node[:drupal][:default_site_dir], 'files')) }
end
@ -61,7 +62,7 @@ bash "create drupal database and inject data" do
code <<-EOH
mysql -h 127.0.0.1 --user="root" --password="sploitme" --execute="CREATE DATABASE drupal;"
mysql -h 127.0.0.1 --user="root" --password="sploitme" --execute="GRANT SELECT, INSERT, DELETE, CREATE, DROP, INDEX, ALTER ON drupal.* TO 'root'@'localhost' IDENTIFIED BY 'sploitme';"
mysql -h 127.0.0.1 --user="root" --password="sploitme" drupal < #{File.join(node[:drupal][:files_path], 'drupal.sql')}
mysql -h 127.0.0.1 --user="root" --password="sploitme" drupal < #{File.join(files_path, 'drupal.sql')}
EOH
not_if "mysql -h 127.0.0.1 --user=\"root\" --password=\"sploitme\" --execute=\"SHOW DATABASES LIKE 'drupal'\" | grep -c drupal"
end

View File

@ -43,7 +43,7 @@ bash "load 8 of hearts into DB" do
code <<-EOH
mysql -h 127.0.0.1 --user="root" --password="sploitme" --execute="CREATE DATABASE super_secret_db;"
mysql -h 127.0.0.1 --user="root" --password="sploitme" --execute="GRANT SELECT, INSERT, DELETE, CREATE, DROP, INDEX, ALTER ON drupal.* TO 'root'@'localhost' IDENTIFIED BY 'sploitme';"
mysql -h 127.0.0.1 --user="root" --password="sploitme" super_secret_db < #{File.join(node[:metasploitable][:files_path], 'flags', 'super_secret_db.sql')}
mysql -h 127.0.0.1 --user="root" --password="sploitme" super_secret_db < #{File.join(Chef::Config[:file_cache_path], 'cookbooks', 'metasploitable', 'files', 'flags', 'super_secret_db.sql')}
EOH
not_if "mysql -h 127.0.0.1 --user=\"root\" --password=\"sploitme\" --execute=\"SHOW DATABASES LIKE 'super_secret_db'\" | grep -c drupal"
end

View File

@ -15,6 +15,7 @@ bash 'setup for knockd, used for flag' do
node[:metasploitable][:ports].keys.each do |service|
code_to_execute << "iptables -A INPUT -p tcp --dport #{node[:metasploitable][:ports][service.to_sym]} -j ACCEPT\n"
end
code_to_execute << "iptables -A INPUT -p tcp --dport 22 -j ACCEPT\n"
code_to_execute << "iptables -A INPUT -j DROP\n"
code code_to_execute
end

43
packer/http/preseed.cfg Normal file
View File

@ -0,0 +1,43 @@
choose-mirror-bin mirror/http/proxy string
d-i base-installer/kernel/override-image string linux-server
d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i finish-install/reboot_in_progress note
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true
d-i pkgsel/include string openssh-server cryptsetup build-essential libssl-dev libreadline-dev zlib1g-dev linux-source dkms nfs-common curl wget ca-certificates libwww-perl python open-vm-tools-lts-trusty
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select unattended-upgrades
d-i pkgsel/upgrade select full-upgrade
d-i time/zone string UTC
tasksel tasksel/first multiselect standard, ubuntu-server
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/modelcode string pc105
d-i debian-installer/locale string en_US
# Create vagrant user account.
d-i passwd/user-fullname string vagrant
d-i passwd/username string vagrant
d-i passwd/user-password password vagrant
d-i passwd/user-password-again password vagrant
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
d-i passwd/user-default-groups vagrant sudo
d-i passwd/user-uid string 900
d-i preseed/late_command string \
echo "vagrant ALL=(ALL:ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/vagrant ; \
chmod 0440 /target/etc/sudoers.d/vagrant ;

View File

@ -0,0 +1,130 @@
{
"builders": [
{
"type": "vmware-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"http_directory" : "{{template_dir}}/../http",
"http_port_min" : 9001,
"http_port_max" : 9001,
"boot_command": [
"<esc><wait>",
"<esc><wait>",
"<enter><wait>",
"/install/vmlinuz",
" auto=true",
" priority=critical",
" initrd=/install/initrd.gz",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
" -- ",
"<enter>"
],
"boot_wait": "20s",
"communicator": "ssh",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "2h",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
"guest_os_type": "Ubuntu_64",
"tools_upload_flavor": "linux",
"disk_size": 40000,
"vm_name": "metasploitable3-ub1404",
"vmx_data": {
"cpuid.coresPerSocket": "2",
"memsize": "4096",
"numvcpus": "2",
"scsi0.virtualDev": "lsisas1068"
}
},
{
"type": "virtualbox-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"http_directory" : "{{template_dir}}/../http",
"http_port_min" : 9001,
"http_port_max" : 9001,
"boot_command": [
"<esc><wait>",
"<esc><wait>",
"<enter><wait>",
"/install/vmlinuz",
" auto=true",
" priority=critical",
" initrd=/install/initrd.gz",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
" -- ",
"<enter>"
],
"boot_wait": "20s",
"communicator": "ssh",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "2h",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
"guest_os_type": "Ubuntu_64",
"disk_size": 40000,
"vm_name": "metasploitable3-ub1404",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"4096"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"2"
]
]
}
],
"provisioners": [
{
"type": "chef-solo",
"cookbook_paths": [
"{{template_dir}}/../../chef/cookbooks"
],
"run_list": [
"metasploitable::vm_tools",
"metasploitable::mysql",
"metasploitable::apache_continuum",
"metasploitable::apache",
"metasploitable::php_545",
"metasploitable::phpmyadmin",
"metasploitable::proftpd",
"metasploitable::users",
"metasploitable::docker",
"metasploitable::samba",
"metasploitable::sinatra",
"metasploitable::unrealircd",
"metasploitable::chatbot",
"metasploitable::payroll_app",
"metasploitable::readme_app",
"metasploitable::cups",
"metasploitable::drupal",
"metasploitable::knockd",
"metasploitable::iptables",
"metasploitable::flags"
]
}
],
"post-processors": [
{
"type": "vagrant",
"keep_input_artifact": false,
"output": "{{template_dir}}/../builds/ubuntu_1404_{{.Provider}}.box"
}
],
"variables": {
"iso_url": "http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso",
"iso_checksum_type": "md5",
"iso_checksum": "ca2531b8cd79ea5b778ede3a524779b9",
"box_version": "0.1.0"
}
}

View File

@ -0,0 +1,221 @@
{
"builders": [
{
"type": "vmware-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"boot_wait": "10m",
"communicator": "ssh",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "winServer2008Standard-64",
"tools_upload_flavor": "windows",
"disk_size": 61440,
"floppy_files": [
"{{user `autounattend`}}",
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
"{{user `scripts_dir`}}/configs/win-updates.ps1",
"{{user `scripts_dir`}}/installs/openssh.ps1",
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
"{{user `resources_dir`}}/certs/oracle-cert.cer",
"{{user `resources_dir`}}/certs/gdig2.crt",
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
"{{user `resources_dir`}}/certs/comodorsacertificationauthority.crt",
"{{user `resources_dir`}}/certs/addtrust_external_ca.cer",
"{{user `resources_dir`}}/certs/baltimore_ca.cer",
"{{user `resources_dir`}}/certs/digicert.cer",
"{{user `resources_dir`}}/certs/equifax.cer",
"{{user `resources_dir`}}/certs/globalsign.cer",
"{{user `resources_dir`}}/certs/gte_cybertrust.cer",
"{{user `resources_dir`}}/certs/microsoft_root_2011.cer",
"{{user `resources_dir`}}/certs/thawte_primary_root.cer",
"{{user `resources_dir`}}/certs/utn-userfirst.cer"
],
"vm_name": "metasploitable3-win2k8",
"vmx_data": {
"cpuid.coresPerSocket": "2",
"memsize": "4096",
"numvcpus": "2",
"scsi0.virtualDev": "lsisas1068"
}
},
{
"type": "virtualbox-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"boot_wait": "10m",
"communicator": "ssh",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "Windows2008_64",
"disk_size": 61440,
"vm_name": "metasploitable3-win2k8",
"floppy_files": [
"{{user `autounattend`}}",
"{{user `scripts_dir`}}/configs/microsoft-updates.bat",
"{{user `scripts_dir`}}/configs/win-updates.ps1",
"{{user `scripts_dir`}}/installs/openssh.ps1",
"{{user `scripts_dir`}}/installs/install_dotnet45.ps1",
"{{user `scripts_dir`}}/installs/install_wmf.ps1",
"{{user `resources_dir`}}/certs/oracle-cert.cer",
"{{user `resources_dir`}}/certs/gdig2.crt",
"{{user `resources_dir`}}/certs/comodorsadomainvalidationsecureserverca.crt",
"{{user `resources_dir`}}/certs/comodorsacertificationauthority.crt",
"{{user `resources_dir`}}/certs/addtrust_external_ca.cer",
"{{user `resources_dir`}}/certs/baltimore_ca.cer",
"{{user `resources_dir`}}/certs/digicert.cer",
"{{user `resources_dir`}}/certs/equifax.cer",
"{{user `resources_dir`}}/certs/globalsign.cer",
"{{user `resources_dir`}}/certs/gte_cybertrust.cer",
"{{user `resources_dir`}}/certs/microsoft_root_2011.cer",
"{{user `resources_dir`}}/certs/thawte_primary_root.cer",
"{{user `resources_dir`}}/certs/utn-userfirst.cer"
],
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"4096"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"2"
]
]
}
],
"provisioners": [
{
"type": "file",
"source": "{{user `scripts_dir`}}",
"destination": "C:/vagrant"
},
{
"type": "file",
"source": "{{user `resources_dir`}}",
"destination": "C:/vagrant"
},
{
"type": "shell",
"remote_path": "/tmp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"{{user `scripts_dir`}}/configs/update_root_certs.bat",
"{{user `scripts_dir`}}/installs/vm-guest-tools.bat",
"{{user `scripts_dir`}}/configs/vagrant-ssh.bat",
"{{user `scripts_dir`}}/configs/disable-auto-logon.bat",
"{{user `scripts_dir`}}/configs/enable-rdp.bat"
]
},
{
"type": "windows-shell",
"remote_path": "C:/Windows/Temp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"{{user `scripts_dir`}}/configs/disable_firewall.bat"
]
},
{
"type": "windows-restart"
},
{
"type":"powershell",
"inline": [
"iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
],
"pause_before": "60s"
},
{
"type": "windows-restart"
},
{
"type": "windows-shell",
"remote_path": "C:/Windows/Temp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"{{user `scripts_dir`}}/installs/install_boxstarter.bat",
"{{user `scripts_dir`}}/chocolatey_installs/7zip.bat",
"{{user `scripts_dir`}}/configs/apply_password_settings.bat",
"{{user `scripts_dir`}}/configs/create_users.bat",
"{{user `scripts_dir`}}/installs/setup_iis.bat",
"{{user `scripts_dir`}}/installs/setup_ftp_site.bat",
"{{user `scripts_dir`}}/chocolatey_installs/java.bat"
]
},
{
"type": "windows-restart"
},
{
"type": "windows-shell",
"remote_path": "C:/Windows/Temp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"{{user `scripts_dir`}}/chocolatey_installs/tomcat.bat",
"{{user `scripts_dir`}}/installs/setup_apache_struts.bat",
"{{user `scripts_dir`}}/installs/setup_glassfish.bat",
"{{user `scripts_dir`}}/installs/start_glassfish_service.bat",
"{{user `scripts_dir`}}/installs/setup_jenkins.bat",
"{{user `scripts_dir`}}/chocolatey_installs/vcredist2008.bat",
"{{user `scripts_dir`}}/installs/install_wamp.bat",
"{{user `scripts_dir`}}/installs/start_wamp.bat",
"{{user `scripts_dir`}}/installs/install_wordpress.bat",
"{{user `scripts_dir`}}/installs/install_openjdk6.bat",
"{{user `scripts_dir`}}/installs/setup_jmx.bat",
"{{user `scripts_dir`}}/installs/install_ruby.bat",
"{{user `scripts_dir`}}/installs/install_devkit.bat"
]
},
{
"type": "windows-restart"
},
{
"type": "windows-shell",
"remote_path": "C:/Windows/Temp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"{{user `scripts_dir`}}/installs/install_rails_server.bat",
"{{user `scripts_dir`}}/installs/setup_rails_server.bat",
"{{user `scripts_dir`}}/installs/install_rails_service.bat",
"{{user `scripts_dir`}}/installs/setup_webdav.bat",
"{{user `scripts_dir`}}/installs/setup_mysql.bat",
"{{user `scripts_dir`}}/installs/install_manageengine.bat",
"{{user `scripts_dir`}}/installs/setup_axis2.bat",
"{{user `scripts_dir`}}/installs/install_backdoors.bat",
"{{user `scripts_dir`}}/installs/setup_snmp.bat",
"{{user `scripts_dir`}}/configs/configure_firewall.bat",
"{{user `scripts_dir`}}/installs/install_elasticsearch.bat",
"{{user `scripts_dir`}}/installs/install_flags.bat",
"{{user `scripts_dir`}}/configs/packer_cleanup.bat"
]
}
],
"post-processors": [
{
"type": "vagrant",
"keep_input_artifact": false,
"output": "{{template_dir}}/../builds/windows_2008_r2_{{.Provider}}_{{user `box_version`}}_{{user `box_version`}}.box",
"vagrantfile_template": "{{template_dir}}/vagrantfile-windows_2008_r2.template"
}
],
"variables": {
"iso_url": "http://download.microsoft.com/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso",
"iso_checksum_type": "md5",
"iso_checksum": "4263be2cf3c59177c45085c0a7bc6ca5",
"autounattend": "{{template_dir}}/../answer_files/2008_r2/Autounattend.xml",
"scripts_dir": "{{template_dir}}/../../scripts",
"resources_dir": "{{template_dir}}/../../resources",
"box_version": "0.1.0"
}
}

View File

@ -1,218 +0,0 @@
{
"builders": [
{
"type": "vmware-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"boot_wait": "10m",
"communicator": "ssh",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "winServer2008Standard-64",
"tools_upload_flavor": "windows",
"disk_size": 61440,
"floppy_files": [
"{{user `autounattend`}}",
"./scripts/configs/microsoft-updates.bat",
"./scripts/configs/win-updates.ps1",
"./scripts/installs/openssh.ps1",
"./scripts/installs/install_dotnet45.ps1",
"./scripts/installs/install_wmf.ps1",
"./resources/certs/oracle-cert.cer",
"./resources/certs/gdig2.crt",
"./resources/certs/comodorsadomainvalidationsecureserverca.crt",
"./resources/certs/comodorsacertificationauthority.crt",
"./resources/certs/addtrust_external_ca.cer",
"./resources/certs/baltimore_ca.cer",
"./resources/certs/digicert.cer",
"./resources/certs/equifax.cer",
"./resources/certs/globalsign.cer",
"./resources/certs/gte_cybertrust.cer",
"./resources/certs/microsoft_root_2011.cer",
"./resources/certs/thawte_primary_root.cer",
"./resources/certs/utn-userfirst.cer"
],
"vm_name": "metasploitable3-win2k8",
"vmx_data": {
"cpuid.coresPerSocket": "2",
"memsize": "4096",
"numvcpus": "2",
"scsi0.virtualDev": "lsisas1068"
}
},
{
"type": "virtualbox-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"boot_wait": "10m",
"communicator": "ssh",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "2h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "Windows2008_64",
"disk_size": 61440,
"vm_name": "metasploitable3-win2k8",
"floppy_files": [
"{{user `autounattend`}}",
"./scripts/configs/microsoft-updates.bat",
"./scripts/configs/win-updates.ps1",
"./scripts/installs/openssh.ps1",
"./scripts/installs/install_dotnet45.ps1",
"./scripts/installs/install_wmf.ps1",
"./resources/certs/oracle-cert.cer",
"./resources/certs/gdig2.crt",
"./resources/certs/comodorsadomainvalidationsecureserverca.crt",
"./resources/certs/comodorsacertificationauthority.crt",
"./resources/certs/addtrust_external_ca.cer",
"./resources/certs/baltimore_ca.cer",
"./resources/certs/digicert.cer",
"./resources/certs/equifax.cer",
"./resources/certs/globalsign.cer",
"./resources/certs/gte_cybertrust.cer",
"./resources/certs/microsoft_root_2011.cer",
"./resources/certs/thawte_primary_root.cer",
"./resources/certs/utn-userfirst.cer"
],
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"4096"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"2"
]
]
}
],
"provisioners": [
{
"type": "file",
"source": "scripts",
"destination": "C:/vagrant"
},
{
"type": "file",
"source": "resources",
"destination": "C:/vagrant"
},
{
"type": "shell",
"remote_path": "/tmp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"./scripts/configs/update_root_certs.bat",
"./scripts/installs/vm-guest-tools.bat",
"./scripts/configs/vagrant-ssh.bat",
"./scripts/configs/disable-auto-logon.bat",
"./scripts/configs/enable-rdp.bat"
]
},
{
"type": "windows-shell",
"remote_path": "C:/Windows/Temp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"./scripts/configs/disable_firewall.bat"
]
},
{
"type": "windows-restart"
},
{
"type":"powershell",
"inline": [
"iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
],
"pause_before": "60s"
},
{
"type": "windows-restart"
},
{
"type": "windows-shell",
"remote_path": "C:/Windows/Temp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"scripts/installs/install_boxstarter.bat",
"scripts/chocolatey_installs/7zip.bat",
"scripts/configs/apply_password_settings.bat",
"scripts/configs/create_users.bat",
"scripts/installs/setup_iis.bat",
"scripts/installs/setup_ftp_site.bat",
"scripts/chocolatey_installs/java.bat"
]
},
{
"type": "windows-restart"
},
{
"type": "windows-shell",
"remote_path": "C:/Windows/Temp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"scripts/chocolatey_installs/tomcat.bat",
"scripts/installs/setup_apache_struts.bat",
"scripts/installs/setup_glassfish.bat",
"scripts/installs/start_glassfish_service.bat",
"scripts/installs/setup_jenkins.bat",
"scripts/chocolatey_installs/vcredist2008.bat",
"scripts/installs/install_wamp.bat",
"scripts/installs/start_wamp.bat",
"scripts/installs/install_wordpress.bat",
"scripts/installs/install_openjdk6.bat",
"scripts/installs/setup_jmx.bat",
"scripts/installs/install_ruby.bat",
"scripts/installs/install_devkit.bat"
]
},
{
"type": "windows-restart"
},
{
"type": "windows-shell",
"remote_path": "C:/Windows/Temp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"scripts/installs/install_rails_server.bat",
"scripts/installs/setup_rails_server.bat",
"scripts/installs/install_rails_service.bat",
"scripts/installs/setup_webdav.bat",
"scripts/installs/setup_mysql.bat",
"scripts/installs/install_manageengine.bat",
"scripts/installs/setup_axis2.bat",
"scripts/installs/install_backdoors.bat",
"scripts/installs/setup_snmp.bat",
"scripts/configs/configure_firewall.bat",
"scripts/installs/install_elasticsearch.bat",
"scripts/installs/install_flags.bat",
"scripts/configs/packer_cleanup.bat"
]
}
],
"post-processors": [
{
"type": "vagrant",
"keep_input_artifact": false,
"output": "windows_2008_r2_{{.Provider}}.box",
"vagrantfile_template": "vagrantfile-windows_2008_r2.template"
}
],
"variables": {
"iso_url": "http://download.microsoft.com/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso",
"iso_checksum_type": "md5",
"iso_checksum": "4263be2cf3c59177c45085c0a7bc6ca5",
"autounattend": "./answer_files/2008_r2/Autounattend.xml"
}
}