diff --git a/.gitignore b/.gitignore index d8e03309..d744ee21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vagrant/ +output-qemu/ packer_cache/ packer/builds/ resources/drivers/ diff --git a/README.md b/README.md index ff3f8ba1..18872b50 100644 --- a/README.md +++ b/README.md @@ -49,16 +49,23 @@ Requirements: 3. When this process completes, you should be able to open the VM within VirtualBox and login. The default credentials are U: `vagrant` and P: `vagrant`. ### To build manually: - 1. Clone this repo and navigate to the main directory. -2. Build the base VM image by running `packer build --only= ./packer/templates/windows_2008_r2.json` where `` is your preferred virtualization platform. Currently `virtualbox-iso`, `qemu`, and `vmware-iso` providers 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 packer/builds/windows_2008_r2_*_0.1.0.box --name=rapid7/metasploitable3-win2k8`. +2. Build the base VM image by running `packer build --only= ./packer/templates/windows_2008_r2.json` where `` is your preferred virtualization platform. Currently `virtualbox-iso`, `qemu`, and `vmware-iso` providers are supported. This will take a while the first time you run it since it has to download the OS installation ISO. If you are using `qemu`, refer to the section [below](#Downloading-virtio-drivers) to download virtio-drivers. +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 packer/builds/windows_2008_r2_*_0.1.0.box --name=rapid7/metasploitable3-win2k8`. If using libvirt, you can use a custom pool name, by passing setting `LIBVIRT_POOL=` environment variable. 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 win2k8`. 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: - Username: `vagrant` - Password: `vagrant` +#### Downloading virtio-drivers +If you are using QEMU/libvirt, you will need to download **virtio-drivers** for windows. A script in `./packer/scripts/virtio-win-drivers.sh` is already present. To use the script: +```sh +cd ./packer/scripts/ +./virtio-win-drivers.sh +``` +This will download the drivers and put the `amd64` the `./resources/drivers` directory. + ### ub1404 Development and Modification Using Vagrant and a lightweight Ubuntu 14.04 vagrant cloud box image, you can diff --git a/Vagrantfile b/Vagrantfile index a23fb970..4734f59c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,8 +1,10 @@ # -*- mode: ruby -*- # vi: set ft=ruby : - Vagrant.configure("2") do |config| config.vm.synced_folder '.', '/vagrant', disabled: true + config.winrm.transport = :plaintext + config.winrm.basic_auth_only = true + config.vm.define "ub1404" do |ub1404| ub1404.vm.box = "rapid7/metasploitable3-ub1404" ub1404.vm.hostname = "metasploitable3-ub1404" @@ -15,6 +17,13 @@ Vagrant.configure("2") do |config| v.name = "Metasploitable3-ub1404" v.memory = 2048 end + + ub1404.vm.provider "libvirt" do |v| + v.memory = 2048 + v.title = "Metasploitable3-ub1404" + v.storage_pool_name = ENV['LIBVIRT_POOL'] || "default" + end + end config.vm.define "win2k8" do |win2k8| @@ -41,6 +50,10 @@ Vagrant.configure("2") do |config| v.hyperv_feature :name => 'relaxed', :state => 'on' v.hyperv_feature :name => 'vapic', :state => 'on' v.hyperv_feature :name => 'synic', :state => 'on' + v.hyperv_feature :name => 'vpindex', :state => 'on' + v.clock_timer :name => 'hypervclock', :present => 'yes' + v.title = "Metasploitable3-win2k8" + v.storage_pool_name = ENV['LIBVIRT_POOL'] || "default" end # Configure Firewall to open up vulnerable services diff --git a/chef/cookbooks/metasploitable/recipes/docker.rb b/chef/cookbooks/metasploitable/recipes/docker.rb index b7a1f56c..7c00fbd2 100644 --- a/chef/cookbooks/metasploitable/recipes/docker.rb +++ b/chef/cookbooks/metasploitable/recipes/docker.rb @@ -4,8 +4,8 @@ # docker_service 'default' do - install_method 'package' - version '18.06.1' + install_method 'tarball' + version '18.06.0' action [:create, :start] group 'docker' end diff --git a/packer/scripts/virtio-win-drivers.sh b/packer/scripts/virtio-win-drivers.sh index 43e1518f..984d2eab 100755 --- a/packer/scripts/virtio-win-drivers.sh +++ b/packer/scripts/virtio-win-drivers.sh @@ -42,5 +42,7 @@ if [ "$have_tools" = true ]; then else echo "Downloading and extracting virtio ${virtio_release} drivers." wget -c "${virtio_uri}" -O ".${virtio_release}.vfd" && 7z x -oresources/drivers/virtio/"${virtio_release}" ".${virtio_release}.vfd" amd64/Win2008R2 + mkdir ../../resources/drivers/ + cp -r ./resources/drivers/virtio/virtio-win-0.1.117_amd64/amd64/ ../../resources/drivers/ fi fi diff --git a/packer/templates/windows_2008_r2.json b/packer/templates/windows_2008_r2.json index 92dcc2fa..de4a6ab8 100644 --- a/packer/templates/windows_2008_r2.json +++ b/packer/templates/windows_2008_r2.json @@ -110,18 +110,8 @@ "{{user `resources_dir`}}/certs/utn-userfirst.cer" ], "vboxmanage": [ - [ - "modifyvm", - "{{.Name}}", - "--memory", - "4096" - ], - [ - "modifyvm", - "{{.Name}}", - "--cpus", - "2" - ] + ["modifyvm", "{{.Name}}", "--memory", "4096"], + ["modifyvm", "{{.Name}}", "--cpus", "2"] ] }, { @@ -132,8 +122,8 @@ "boot_wait": "10m", "communicator": "ssh", "accelerator": "kvm", - "ssh_username": "vagrant", "ssh_password": "vagrant", + "ssh_username": "vagrant", "ssh_timeout": "2h", "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", "disk_size": 61440, @@ -157,34 +147,29 @@ "{{user `resources_dir`}}/certs/microsoft_root_2011.cer", "{{user `resources_dir`}}/certs/thawte_primary_root.cer", "{{user `resources_dir`}}/certs/utn-userfirst.cer", - "./resources/drivers/virtio/*" + "{{user `resources_dir`}}/drivers/amd64/Win2008R2/*" ], "qemuargs": [ - [ - "-m", - "4096" - ], - [ - "-smp", - "2" - ], - [ - "-display", - "gtk" - ] + ["-m", "4096"], + ["-smp", "2"], + ["-display", "gtk"] ] } ], "provisioners": [ { - "type": "shell-local", - "only_on": ["linux", "darwin"], - "inline": ["cd {{user `resources_dir`}} && {{user `resources_dir`}}/download-windows-files.sh"] + "type": "shell-local", + "only_on": ["linux", "darwin"], + "inline": [ + "cd {{user `resources_dir`}} && {{user `resources_dir`}}/download-windows-files.sh" + ] }, { - "type": "shell-local", - "only_on": ["windows"], - "inline": ["cd {{user `resources_dir`}} && powershell {{user `resources_dir`}}/download-windows-files.ps1"] + "type": "shell-local", + "only_on": ["windows"], + "inline": [ + "cd {{user `resources_dir`}} && powershell {{user `resources_dir`}}/download-windows-files.ps1" + ] }, { "type": "file", @@ -209,27 +194,21 @@ "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" - ] + "scripts": ["{{user `scripts_dir`}}/configs/disable_firewall.bat"] }, { "type": "windows-restart" }, { "type": "powershell", - "scripts": [ - "{{user `scripts_dir`}}/installs/install_dotnet45.ps1" - ] + "scripts": ["{{user `scripts_dir`}}/installs/install_dotnet45.ps1"] }, { "type": "windows-restart" }, { "type": "powershell", - "scripts": [ - "{{user `scripts_dir`}}/installs/install_wmf.ps1" - ] + "scripts": ["{{user `scripts_dir`}}/installs/install_wmf.ps1"] }, { "type": "windows-restart", @@ -325,9 +304,7 @@ }, { "type": "powershell", - "inline": [ - "mkdir -p C:/startup" - ] + "inline": ["mkdir -p C:/startup"] }, { "type": "file",