{"id":20445854,"url":"https://github.com/rapid7/metasploit-vagrant-builders","last_synced_at":"2025-10-10T06:16:10.433Z","repository":{"id":49552893,"uuid":"136119940","full_name":"rapid7/metasploit-vagrant-builders","owner":"rapid7","description":"Build tools to generate vagrant images used by metasploit-framework CI","archived":false,"fork":false,"pushed_at":"2025-02-13T14:50:35.000Z","size":163,"stargazers_count":13,"open_issues_count":0,"forks_count":8,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-04-13T00:44:08.497Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapid7.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-06-05T04:31:07.000Z","updated_at":"2025-02-13T14:50:38.000Z","dependencies_parsed_at":"2023-10-03T01:45:23.298Z","dependency_job_id":"8bd01efa-0698-45c2-a0f9-8a5085a8f6a3","html_url":"https://github.com/rapid7/metasploit-vagrant-builders","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/rapid7/metasploit-vagrant-builders","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-vagrant-builders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-vagrant-builders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-vagrant-builders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-vagrant-builders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapid7","download_url":"https://codeload.github.com/rapid7/metasploit-vagrant-builders/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-vagrant-builders/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002963,"owners_count":26083487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:14:51.474Z","updated_at":"2025-10-10T06:16:10.416Z","avatar_url":"https://github.com/rapid7.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metasploit-vagrant-builds\n\nThis repository hold tools for creating vagrant systems used by the Metasploit Framework to build and release artifacts.\n\n## Building\n\nTo build locally first install `packer`.\n\n### Local building\n\nWindows is currently built remotely on AWS, but OSX must be built locally. It is possible to build the macOS and Windows systems locally:\n\n* `git submodule update --init`\n* Install `vmware_desktop` or `virtualbox`\n* If using `virtualbox` update the `templates\\metasploitMacOSBuilder.json` `vagrant_provider` to `virtualbox`\n* Add a `authorized_keys` file (this is required to build, see [Security considerations](#security-considerations) section for more information)\n* Manually source the macOS/Windows ISO files (Steps for OSX below)\n* Execute `./buildBoxes.sh`\n* To debug a failing build you can use the `-on-error=ask` packer flag to inspect a failed VM, or the `PACKER_LOG=1` environment variable to log vagrant commands and their results\n\nIn some cases importing the seed macOS source box currently from vagrantcloud into your vagrant environment may be need.\nThe project is currently utilizing a prebuild macinabox image referenced in `resources/macos/macos.json`\n\nBuild systems for macOS can only be created on macOS and requires a `.dmg` file:\n\n```shell\n# Find available software\nsoftwareupdate --list-full-installers\n\n# Download the required version\nsoftwareupdate --fetch-full-installer --full-installer-version 11.7.10\n\n# Create a new sparse disk image\nhdiutil create -o 'Install_macOS_11.7.10' -size 16384m -volname Install_macOS_11.7.10 -layout SPUD -fs HFS+J\n\n# Mount the dmg\nhdiutil attach Install_macOS_11.7.10.dmg -noverify -mountpoint '/Volumes/Big Sur'\n\n# Create intstall media dmg\nsudo /Applications/Install\\ macOS\\ Big\\ Sur.app/Contents/Resources/createinstallmedia --volume '/Volumes/Big Sur'\n\n# Detatch the bootable installer\nhdiutil detach -force '/Volumes/Big Sur'\n```\n\nIf your target virtualization environment is running an older ESXi version (i.e. 6.7 or below) - it may be easier to create the base\nvagrant VM directly in ESXi first:\n\n```\n# Pull the base box:\nvagrant box add --box-version 2020.08.21 --provider vmware_desktop ekai-upt/macos-catalina\n\n# Move into the VM directory:\ncd ~/.vagrant.d/boxes/ekai-upt-VAGRANTSLASH-macos-catalina/2020.08.21/vmware_desktop\n\n# Create a new VM on ESXi:\ntime /Applications/VMware\\ Fusion.app/Contents/Library/VMware\\ OVF\\ Tool/ovftool \\\n    --overwrite \\\n    --diskMode=thin \\\n    --numberOfCpus:'*'=4 \\\n    --memorySize:'*'=8192 \\\n    --maxVirtualHardwareVersion=15 \\\n    --network=\u003cnetwork\u003e \\\n    --datastore=\u003cdatastore\u003e \\\n    --vmFolder=Metasploit \\\n    --compress=9 \\\n    --name=metasploitMacOSBuilder-\u003cversion\u003e  \\\n    macinbox.vmx \\\n    vi://\u003cvcenter_host\u003e:443/\u003cdatacenter\u003e/host/\u003cesxi_host\u003e/\n```\n\nThen Resize the VM on VSphere from 64gb to 84gb, boot it - and run disktuil `diskutil apfs resizeContainer disk0s2 84G`.\nThen remotely provision the VM with packer's [null builder](https://developer.hashicorp.com/packer/docs/builders/null):\n\n```json5\n{\n  \"_command\": \"Build with `packer build macos.json`\",\n  \"builders\": [\n    {\n      \"type\": \"null\",\n      \"ssh_host\": \"x.x.x.x\",\n      \"ssh_username\": \"{{ user `ssh_username` }}\",\n      \"ssh_password\": \"{{ user `ssh_password` }}\"\n    }\n  ]\n  // ...\n}\n```\n\nThis ensures that the created VM is compatible with with the host's hypervisor. This fixes an issue of building locally with\na newer VMWare fusion version may leave a VM that isn't bootable on a remote ESXi server. macOS provisioning take ~4 hours to finish.\n\nThen execute packer:\n\n```\nPACKER_LOG=1 packer build -on-error=abort -var-file=templates/metasploitMacOSBuilder.json resources/macos/macos.json\n```\n\nIf you've remotely provisioned an existing ESXi target - you will want to convert the VM to a template afterwards.\n\nExample of testing the locally built OSX box:\n\n```shell\nvagrant box add metasploitMacOSBuilder-1.0.8 ./box/vmware_desktop/metasploitMacOSBuilder-1.0.8.box\nvagrant init metasploitMacOSBuilder-1.0.8\nvagrant up --provider=vmware_desktop\nvagrant ssh\n```\n\nExample of uploading a locally built Vagrant box to vSphere with vmware's `ovftool`:\n\n```\n# Extract the box; to gain access to the box.vmx metadata file:\ntar xvf metasploitMacOSBuilder-1.0.8.box\n\n# Upload to vSphere\n/Applications/VMware\\ Fusion.app/Contents/Library/VMware\\ OVF\\ Tool/ovftool \\\n    --overwrite \\\n    --diskMode=thin \\\n    --numberOfCpus:'*'=4 \\\n    --memorySize:'*'=8192 \\\n    --maxVirtualHardwareVersion=15 \\\n    --network=\u003cnetwork\u003e \\\n    --datastore=\u003cdatastore\u003e \\\n    --importAsTemplate \\\n    --vmFolder=Metasploit \\\n    --compress=9 \\\n    --name=metasploitMacOSBuilder-\u003cversion\u003e  \\\n    box.vmx \\\n    vi://\u003cvcenter_host\u003e:443/\u003cdatacenter\u003e/host/\u003cesxi_host\u003e/\n```\n\n### Building remotely\n\nNote: macOS not yet supported with remote builds.\n\nTo build the Windows system remotely on an AWS environment:\n\n```\n# Create a temporary install password; By defafult you can WinRM into this account with vagrant:$INSTALL_PASSWORD\nexport INSTALL_PASS=$(openssl rand -base64 9 | tr -d '\\r\\n')\necho \"The temporary WinRM credentials will be: vagrant:${INSTALL_PASS}\"\n\n# Install any required terraform plugins\npacker init resources/windows/windows.pkr.hcl\n\n# Validate the packer configuration\npacker validate -var \"install_pass=${INSTALL_PASS}\" -var \"authorized_keys_path=./resources/authorized_keys\" resources/windows/windows.pkr.hcl\n\n# Build on AWS\npacker build -var \"install_pass=${INSTALL_PASS}\" -var \"authorized_keys_path=./resources/authorized_keys\" resources/windows/windows.pkr.hcl\n```\n\nThis will create a new AMI, and replace the existing AMI if present:\n\n```\n# Replace an existing AMI. Warning - do this only if you are creating a new unused version:\npacker build -var \"install_pass=${INSTALL_PASS}\" -var \"authorized_keys_path=./resources/authorized_keys\" -var \"force_deregister=true\" -var \"force_delete_snapshot=true\" resources/windows/windows.pkr.hcl\n```\n\n### Debugging\n\nTo debug a failing build you can use the `-on-error=ask` flag or the `PACKER_LOG=1` environment variable:\n\n```\npacker build -var \"install_pass=${INSTALL_PASS}\" -var \"authorized_keys_path=./resources/authorized_keys\" -on-error=ask resources/windows/windows.pkr.hcl\n```\n\nYou can remote into the machine via WinRM tooling, potentially via Metasploit:\n\n```msf\nmsf6 auxiliary(scanner/winrm/winrm_login) \u003e run rhost=50.18.26.233 username=Administrator password=MJ72x)O7R3D-96VbAPX).0M%nlZv9bHP rport=5986\n\n[!] No active DB -- Credential data will not be saved!\n[+] 50.18.26.233:5986 - Login Successful: WORKSTATION\\Administrator:MJ72x)O7R3D-96VbAPX).0M%nlZv9bHP\n[*] Command shell session 1 opened (x.x.x.x:52424 -\u003e x.x.x.x:5986) at 2023-11-16 12:44:46 +0000\n[*] Scanned 1 of 1 hosts (100% complete)\n[*] Auxiliary module execution completed\n\nmsf6 auxiliary(scanner/winrm/winrm_login) \u003e sessions -i -1\n[*] Starting interaction with 1...\n\nMicrosoft Windows [Version 10.0.17763.4974]\n(c) 2018 Microsoft Corporation. All rights reserved.\n\nC:\\Users\\Administrator\u003e\n```\n\nThe `-debug` flag can be used to pause at each step as well, which will extract and print the remote EC2 build password directly\nnot just the temporary Administrator account that is created:\n\n```\n$ packer build -var \"install_pass=${INSTALL_PASS}\" -var \"authorized_keys_path=./resources/authorized_keys\" -debug -on-error=ask resources/windows/windows.pkr.hcl\n...\n==\u003e win-builder-base.amazon-ebs.metasploit-windows-builder: Waiting for instance (i-0f18b8be1c11b0893) to become ready...\nwin-builder-base.amazon-ebs.metasploit-windows-builder: Public DNS: ec2-50-18-26-233.us-west-1.compute.amazonaws.com\nwin-builder-base.amazon-ebs.metasploit-windows-builder: Public IP: 50.18.26.233\nwin-builder-base.amazon-ebs.metasploit-windows-builder: Private IP: 172.31.13.97\n==\u003e win-builder-base.amazon-ebs.metasploit-windows-builder: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue.\n==\u003e win-builder-base.amazon-ebs.metasploit-windows-builder: Waiting for auto-generated password for instance...\nwin-builder-base.amazon-ebs.metasploit-windows-builder: It is normal for this process to take up to 15 minutes,\nwin-builder-base.amazon-ebs.metasploit-windows-builder: but it usually takes around 5. Please wait.\nwin-builder-base.amazon-ebs.metasploit-windows-builder:\nwin-builder-base.amazon-ebs.metasploit-windows-builder: Password retrieved!\nwin-builder-base.amazon-ebs.metasploit-windows-builder: Password (since debug is enabled): MJ72x)O7R3D-96VbAPX).0M%nlZv9bHP\n==\u003e win-builder-base.amazon-ebs.metasploit-windows-builder: Pausing after run of step 'StepGetPassword'. Press enter to continue.\n```\n\nSee more details in the [documentation](https://github.com/hashicorp/packer/blob/c245b1fb7c87fdf2e655887d49f8ad75c59b7e2b/website/content/docs/debugging.mdx#L9)\n\n### Security considerations\n\nThe created AMI will require an SSH authorized key to be able to log into the box - by default this is set to `./resources/authorized_keys`. If you are a Rapid7 Metasploit maintainer, pre-existing keys have been made available to you via an internal password manager.\n\nHashicorp does offer [vagrant's \"insecure\" keypairs](https://github.com/hashicorp/vagrant/tree/9b460ecedefa45a557b1c13c63449839819dc220/keys#insecure-keypairs), which are weak credentials and allow anyone with vagrant's \"insecure\" keypairs to access the machine. **This is not advised and is not secure**, if this method is chosen you should at the very least behind a restricted security group (i.e. limited to office/host IP addresses).\n\nExample of adding the keys to the `./resources/authorized_keys` file and SSH'ing in via Vagrant's private key, **again this is not secure**:\n\nAdd the keys:\n```bash\ncurl https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub  \u003e ./resources/authorized_keys\n```\n\nExample of SSH'ing in via Vagrant's private key:\n```bash\ncurl -L -o ./vagrant_key https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant\nchmod 600 ./vagrant_key\n\nssh -o PubkeyAcceptedKeyTypes=ssh-rsa -v -i ./vagrant_key vagrant@ec2-54-215-236-141.us-west-1.compute.amazonaws.com\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapid7%2Fmetasploit-vagrant-builders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapid7%2Fmetasploit-vagrant-builders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapid7%2Fmetasploit-vagrant-builders/lists"}