From f8e3e4a7ff0fbda74dba387e169384585b1cb6c2 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Mon, 15 May 2017 17:07:36 -0500 Subject: [PATCH] Update resources for packer build Only use one packer build file with both virtualbox and vmware defined. Having multiple build files will make it difficult to keep things consistent. Also update references in the build scripts to only build for virtualbox by default. --- README.md | 8 ++--- build_win2008.ps1 | 2 +- build_win2008.sh | 2 +- windows_2008_r2.json | 5 +-- windows_2008_r2_vmware.json | 65 ------------------------------------- 5 files changed, 7 insertions(+), 75 deletions(-) delete mode 100644 windows_2008_r2_vmware.json diff --git a/README.md b/README.md index 25f870c..76cdc6f 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,6 @@ Metasploitable3 is a VM that is built from the ground up with a large amount of Metasploitable3 is released under a BSD-style license. See COPYING for more details. -## NOTE: This is a work in progress to move provisioning to packer and using vmware - -use: `packer build -only=vmware-iso windows_2008_r2.json` - ## Building Metasploitable 3 System Requirements: * OS capable of running all of the required applications listed below @@ -32,8 +28,8 @@ To build automatically: To build manually: 1. Clone this repo and navigate to the main directory. -2. Build the base VM image by running `packer build windows_2008_r2.json`. This will take a while the first time you run it since it has to download the OS installation ISO. -3. After the base Vagrant box is created you need to add it to your Vagrant environment. This can be done with the command `vagrant box add windows_2008_r2_virtualbox.box --name=metasploitable3`. +2. Build the base VM image by running `packer build --only= windows_2008_r2.json` where `` is your preferred virtualization platform. Currently `virtualbox-iso` and `vmware-iso` are supported. This will take a while the first time you run it since it has to download the OS installation ISO. +3. After the base Vagrant box is created you need to add it to your Vagrant environment. This can be done with the command `vagrant box add windows_2008_r2_.box --name=metasploitable3`. 4. Use `vagrant plugin install vagrant-reload` to install the reload vagrant provisioner if you haven't already. 5. To start the VM, run the command `vagrant up`. This will start up the VM and run all of the installation and configuration scripts necessary to set everything up. This takes about 10 minutes. 6. Once this process completes, you can open up the VM within VirtualBox and login. The default credentials are U: vagrant and P: vagrant. diff --git a/build_win2008.ps1 b/build_win2008.ps1 index 7ae2a53..bc4547b 100644 --- a/build_win2008.ps1 +++ b/build_win2008.ps1 @@ -99,7 +99,7 @@ If ($(Test-Path "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 windows_2008_r2.json + cmd.exe /c packer build --only=virtualbox-iso windows_2008_r2.json if($?) { Write-Host "Box successfully built by Packer." diff --git a/build_win2008.sh b/build_win2008.sh index f29308a..8d3bd69 100755 --- a/build_win2008.sh +++ b/build_win2008.sh @@ -101,7 +101,7 @@ if ls | 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 windows_2008_r2.json; then + if $packer_bin build --only=virtualbox-iso 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." diff --git a/windows_2008_r2.json b/windows_2008_r2.json index f271d8b..b25a13a 100644 --- a/windows_2008_r2.json +++ b/windows_2008_r2.json @@ -6,7 +6,8 @@ "iso_checksum_type": "{{user `iso_checksum_type`}}", "iso_checksum": "{{user `iso_checksum`}}", "headless": false, - "boot_wait": "2m", + "boot_wait": "10m", + "communicator": "ssh", "ssh_username": "vagrant", "ssh_password": "vagrant", "ssh_wait_timeout": "2h", @@ -48,7 +49,7 @@ "iso_checksum_type": "{{user `iso_checksum_type`}}", "iso_checksum": "{{user `iso_checksum`}}", "headless": false, - "boot_wait": "5m", + "boot_wait": "10m", "communicator": "ssh", "ssh_username": "vagrant", "ssh_password": "vagrant", diff --git a/windows_2008_r2_vmware.json b/windows_2008_r2_vmware.json deleted file mode 100644 index e2e9807..0000000 --- a/windows_2008_r2_vmware.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "builders": [ - { - "type": "vmware-iso", - "iso_url": "{{user `iso_url`}}", - "iso_checksum_type": "{{user `iso_checksum_type`}}", - "iso_checksum": "{{user `iso_checksum`}}", - "headless": true, - "boot_wait": "2m", - "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", - "disk_size": 61440, - "floppy_files": [ - "{{user `autounattend`}}", - "./scripts/configs/microsoft-updates.bat", - "./scripts/configs/win-updates.ps1", - "./scripts/installs/openssh.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" - ] - } - ], - "provisioners": [ - { - "type": "shell", - "remote_path": "/tmp/script.bat", - "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat", - "scripts": [ - "./scripts/installs/vm-guest-tools.bat", - "./scripts/configs/vagrant-ssh.bat", - "./scripts/configs/disable-auto-logon.bat", - "./scripts/configs/enable-rdp.bat", - "./scripts/configs/update_root_certs.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" - } -}