From 520c0564be04fcaa675709cbcb209a4cda03d1a6 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Mon, 31 Jul 2017 15:48:27 -0500 Subject: [PATCH] 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- --- .gitignore | 1 + Vagrantfile | 64 ++--- build_win2008.ps1 | 12 +- build_win2008.sh | 8 +- .../metasploitable/recipes/drupal.rb | 5 +- .../cookbooks/metasploitable/recipes/flags.rb | 2 +- .../metasploitable/recipes/iptables.rb | 1 + .../answer_files}/2008_r2/Autounattend.xml | 0 packer/http/preseed.cfg | 43 ++++ packer/templates/ubuntu_1404.json | 130 +++++++++++ .../vagrantfile-windows_2008_r2.template | 0 packer/templates/windows_2008_r2.json | 221 ++++++++++++++++++ windows_2008_r2.json | 218 ----------------- 13 files changed, 426 insertions(+), 279 deletions(-) rename {answer_files => packer/answer_files}/2008_r2/Autounattend.xml (100%) create mode 100644 packer/http/preseed.cfg create mode 100644 packer/templates/ubuntu_1404.json rename vagrantfile-windows_2008_r2.template => packer/templates/vagrantfile-windows_2008_r2.template (100%) create mode 100644 packer/templates/windows_2008_r2.json delete mode 100644 windows_2008_r2.json diff --git a/.gitignore b/.gitignore index 73fbb34..9904cb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .vagrant/ packer_cache/ +packer/builds/ *.exe *.msi *.msu diff --git a/Vagrantfile b/Vagrantfile index 40bdc85..f98a65e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/build_win2008.ps1 b/build_win2008.ps1 index bc4547b..960752c 100644 --- a/build_win2008.ps1 +++ b/build_win2008.ps1 @@ -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." diff --git a/build_win2008.sh b/build_win2008.sh index 7e62287..c575c42 100755 --- a/build_win2008.sh +++ b/build_win2008.sh @@ -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." diff --git a/chef/cookbooks/metasploitable/recipes/drupal.rb b/chef/cookbooks/metasploitable/recipes/drupal.rb index 2902186..5ac3969 100644 --- a/chef/cookbooks/metasploitable/recipes/drupal.rb +++ b/chef/cookbooks/metasploitable/recipes/drupal.rb @@ -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 diff --git a/chef/cookbooks/metasploitable/recipes/flags.rb b/chef/cookbooks/metasploitable/recipes/flags.rb index aa51b94..9add7d6 100644 --- a/chef/cookbooks/metasploitable/recipes/flags.rb +++ b/chef/cookbooks/metasploitable/recipes/flags.rb @@ -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 diff --git a/chef/cookbooks/metasploitable/recipes/iptables.rb b/chef/cookbooks/metasploitable/recipes/iptables.rb index 12e4ed6..d87aa47 100644 --- a/chef/cookbooks/metasploitable/recipes/iptables.rb +++ b/chef/cookbooks/metasploitable/recipes/iptables.rb @@ -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 diff --git a/answer_files/2008_r2/Autounattend.xml b/packer/answer_files/2008_r2/Autounattend.xml similarity index 100% rename from answer_files/2008_r2/Autounattend.xml rename to packer/answer_files/2008_r2/Autounattend.xml diff --git a/packer/http/preseed.cfg b/packer/http/preseed.cfg new file mode 100644 index 0000000..40a4081 --- /dev/null +++ b/packer/http/preseed.cfg @@ -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 ; diff --git a/packer/templates/ubuntu_1404.json b/packer/templates/ubuntu_1404.json new file mode 100644 index 0000000..df6d08b --- /dev/null +++ b/packer/templates/ubuntu_1404.json @@ -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": [ + "", + "", + "", + "/install/vmlinuz", + " auto=true", + " priority=critical", + " initrd=/install/initrd.gz", + " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", + " -- ", + "" + ], + "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": [ + "", + "", + "", + "/install/vmlinuz", + " auto=true", + " priority=critical", + " initrd=/install/initrd.gz", + " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", + " -- ", + "" + ], + "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" + } +} diff --git a/vagrantfile-windows_2008_r2.template b/packer/templates/vagrantfile-windows_2008_r2.template similarity index 100% rename from vagrantfile-windows_2008_r2.template rename to packer/templates/vagrantfile-windows_2008_r2.template diff --git a/packer/templates/windows_2008_r2.json b/packer/templates/windows_2008_r2.json new file mode 100644 index 0000000..17834f4 --- /dev/null +++ b/packer/templates/windows_2008_r2.json @@ -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" + } +} diff --git a/windows_2008_r2.json b/windows_2008_r2.json deleted file mode 100644 index 411fc5d..0000000 --- a/windows_2008_r2.json +++ /dev/null @@ -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" - } -}