mirror of
https://github.com/rapid7/metasploitable3.git
synced 2024-09-21 00:01:14 +02:00
Use prebuilt box from vagrant cloud
Update build scripts to remove checks for packer since it is no longer a requirement.
This commit is contained in:
parent
1810872c47
commit
572588beac
9
Vagrantfile
vendored
9
Vagrantfile
vendored
|
@ -3,14 +3,19 @@
|
|||
|
||||
Vagrant.configure("2") do |config|
|
||||
# Base configuration for the VM and provisioner
|
||||
config.vm.box = "metasploitable3"
|
||||
config.vm.hostname = "metasploitable3"
|
||||
config.vm.box = "jbarnett-r7/metasploitable3-win2k8"
|
||||
config.vm.hostname = "metasploitable3-win2k8"
|
||||
config.vm.communicator = "winrm"
|
||||
config.winrm.retry_limit = 60
|
||||
config.winrm.retry_delay = 10
|
||||
|
||||
config.vm.network "private_network", type: "dhcp"
|
||||
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.name = "metasploitable3-win2k8"
|
||||
v.memory = 2048
|
||||
end
|
||||
|
||||
# Configure Firewall to open up vulnerable services
|
||||
case ENV['MS3_DIFFICULTY']
|
||||
when 'easy'
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$virtualBoxMinVersion = "5.1.10"
|
||||
$packerMinVersion = "0.10.0"
|
||||
$vagrantMinVersion = "1.9.0"
|
||||
$vagrantreloadMinVersion = "0.0.1"
|
||||
|
||||
|
@ -48,15 +47,6 @@ If (CompareVersions -actualVersion $vboxVersion -expectedVersion $virtualBoxMinV
|
|||
exit
|
||||
}
|
||||
|
||||
$packerVersion = cmd.exe /c "packer" -v
|
||||
|
||||
If (CompareVersions -actualVersion $packerVersion -expectedVersion $packerMinVersion) {
|
||||
Write-Host "Compatible version of packer found."
|
||||
} else {
|
||||
Write-Host "Could not find a compatible version of packer. Please download it from https://www.packer.io/downloads.html and add it to your PATH."
|
||||
exit
|
||||
}
|
||||
|
||||
If ($(Test-Path "C:\HashiCorp\Vagrant\bin\vagrant.exe") -eq $True) {
|
||||
$vagrantVersion = cmd.exe /c "vagrant" -v
|
||||
$vagrantVersion = $vagrantVersion.split(" ")[1]
|
||||
|
@ -95,30 +85,15 @@ If (![string]::IsNullOrEmpty($vagrantPlugins)) {
|
|||
|
||||
Write-Host "All requirements found. Proceeding..."
|
||||
|
||||
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 --only=virtualbox-iso windows_2008_r2.json
|
||||
|
||||
if($?) {
|
||||
Write-Host "Box successfully built by Packer."
|
||||
} else {
|
||||
throw "Error building the Vagrant box using Packer. Please check the output above for any error messages."
|
||||
}
|
||||
}
|
||||
|
||||
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 "jbarnett-r7/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 "jbarnett-r7/metasploitable3-win2k8") {
|
||||
Write-Host "jbarnett-r7/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
|
||||
Write-Host "Attempting to add the box to Vagrant. This may take a while..."
|
||||
cmd.exe /c vagrant box add jbarnett-r7/metasploitable3-win2k8
|
||||
|
||||
if($?) {
|
||||
Write-Host "Box successfully added to Vagrant."
|
||||
|
|
|
@ -4,7 +4,6 @@ min_vbox_ver="5.1.10"
|
|||
min_vagrant_ver="1.9.0"
|
||||
min_packer_ver="0.10.0"
|
||||
min_vagrantreload_ver="0.0.1"
|
||||
packer_bin="packer"
|
||||
|
||||
function compare_versions {
|
||||
actual_version=$1
|
||||
|
@ -42,9 +41,6 @@ if [ $(uname) = "Darwin" ]; then
|
|||
vagrant_exact_match=false
|
||||
elif [ $(uname) = "Linux" ]; then
|
||||
vagrant_exact_match=false
|
||||
if (cat /etc/*-release | grep -q 'DISTRIB_ID=Arch')|(cat /etc/os-release | grep -q 'ID=arch'); then
|
||||
packer_bin="packer-io"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -x "$(which VBoxManage)" ] ; then
|
||||
|
@ -63,18 +59,6 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if compare_versions $($packer_bin -v) $min_packer_ver false; then
|
||||
echo "Compatible version of $packer_bin was found."
|
||||
else
|
||||
packer_bin=packer
|
||||
if compare_versions $($packer_bin -v) $min_packer_ver false; then
|
||||
echo "Compatible version of $packer_bin was found."
|
||||
else
|
||||
echo "A compatible version of packer was not found. Please install from here: https://www.packer.io/downloads.html"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if compare_versions $(vagrant -v | cut -d' ' -f2) $min_vagrant_ver $vagrant_exact_match; then
|
||||
echo 'Correct version of vagrant was found.'
|
||||
else
|
||||
|
@ -97,25 +81,12 @@ fi
|
|||
|
||||
echo "All requirements found. Proceeding..."
|
||||
|
||||
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 --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."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Attempting to add the box to Vagrant..."
|
||||
|
||||
if vagrant box list | grep -q 'metasploitable3'; then
|
||||
echo 'metasploitable3 already found in Vagrant box repository. Skipping the addition to Vagrant.'
|
||||
if vagrant box list | grep -q 'jbarnett-r7/metasploitable3-win2k8'; then
|
||||
echo 'jbarnett-r7/metasploitable3-win2k8 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
|
||||
echo 'Attempting to add the box to Vagrant. This may take a while...'
|
||||
if vagrant box add jbarnett-r7/metasploitable3-win2k8; then
|
||||
echo "Box successfully added to Vagrant."
|
||||
else
|
||||
echo "Error adding box to Vagrant. See the above output for any error messages."
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"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,
|
||||
"disk_size": 30000,
|
||||
"floppy_files": [
|
||||
"{{user `autounattend`}}",
|
||||
"./scripts/configs/microsoft-updates.bat",
|
||||
|
@ -57,7 +57,7 @@
|
|||
"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,
|
||||
"disk_size": 30000,
|
||||
"vm_name": "metasploitable3-win2k8",
|
||||
"floppy_files": [
|
||||
"{{user `autounattend`}}",
|
||||
|
|
Loading…
Reference in New Issue
Block a user