consistency for usage of VagrantCloud

This commit is contained in:
Jeffrey Martin 2018-08-03 11:41:28 -05:00
parent 604fc136e7
commit 70151811fd
No known key found for this signature in database
GPG Key ID: 0CD9BBC2AF15F171
4 changed files with 41 additions and 17 deletions

17
Vagrantfile vendored
View File

@ -4,7 +4,7 @@
Vagrant.configure("2") do |config|
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.define "ub1404" do |ub1404|
ub1404.vm.box = "metasploitable3-ub1404"
ub1404.vm.box = "rapid7/metasploitable3-ub1404"
ub1404.vm.hostname = "metasploitable3-ub1404"
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
@ -19,7 +19,7 @@ Vagrant.configure("2") do |config|
config.vm.define "win2k8" do |win2k8|
# Base configuration for the VM and provisioner
win2k8.vm.box = "metasploitable3-win2k8"
win2k8.vm.box = "rapid7/metasploitable3-win2k8"
win2k8.vm.hostname = "metasploitable3-win2k8"
win2k8.vm.communicator = "winrm"
win2k8.winrm.retry_limit = 60
@ -30,16 +30,15 @@ Vagrant.configure("2") do |config|
# Configure Firewall to open up vulnerable services
case ENV['MS3_DIFFICULTY']
when 'easy'
win2k8.vm.provision :shell, path: "scripts/configs/disable_firewall.bat"
win2k8.vm.provision :shell, inline: "C:\\vagrant\\startup\\disable_firewall.bat"
else
win2k8.vm.provision :shell, path: "scripts/configs/enable_firewall.bat"
win2k8.vm.provision :shell, path: "scripts/configs/configure_firewall.bat"
win2k8.vm.provision :shell, inline: "C:\\vagrant\\startup\\enable_firewall.bat"
win2k8.vm.provision :shell, inline: "C:\\vagrant\\startup\\configure_firewall.bat"
end
# Insecure share from the Linux machine
win2k8.vm.provision :shell, path: "scripts/installs/install_share_autorun.bat"
win2k8.vm.provision :shell, inline: "rm C:\\tmp\\vagrant-shell.bat" # Hack for this bug: https://github.com/mitchellh/vagrant/issues/7614
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
win2k8.vm.provision :shell, inline: "C:\\vagrant\\startup\\install_share_autorun.bat"
win2k8.vm.provision :shell, inline: "C:\\vagrant\\startup\\setup_linux_share.bat"
win2k8.vm.provision :shell, inline: "rm -rf C:\\vagrant\\startup" # Cleanup startup scripts
end
end

View File

@ -154,14 +154,14 @@ function InstallBox($os_full, $os_short)
echo "Attempting to add metasploitable3-$os_short box to Vagrant..."
$vagrant_box_list = cmd.exe /c "vagrant box list"
If ($vagrant_box_list -match "metasploitable3-$os_short") {
Write-Host "metasploitable3-$os_short already found in Vagrant box repository. Skipping the addition to Vagrant."
If ($vagrant_box_list -match "rapid7/metasploitable3-$os_short") {
Write-Host "rapid7/metasploitable3-$os_short already found in Vagrant box repository. Skipping the addition to Vagrant."
} else {
cmd.exe /c vagrant box add metasploitable3-$os_short packer\builds\$($os_full)_virtualbox_$boxversion.box
cmd.exe /c vagrant box add packer\builds\$($os_full)_virtualbox_$boxversion.box --name rapid7/metasploitable3-$os_short
if($?) {
Write-Host "metasploitable3-$os_short box successfully added to Vagrant."
Write-Host "rapid7/metasploitable3-$os_short box successfully added to Vagrant."
} else {
throw "Error adding metasploitable3-$os_short box to Vagrant. See the above output for any error messages."
}
@ -200,4 +200,4 @@ ElseIf ($args.Length -eq 1)
Write-Host "Invalid OS. Valid options are 'ubuntu1404' and 'windows2008'";
}
}
Write-Host "";
Write-Host "";

View File

@ -156,12 +156,12 @@ done
echo "Attempting to add the box to Vagrant..."
for provider in $providers; do
if vagrant box list | grep -q metasploitable3-"$os_short"-"$provider"; then
echo "metasploitable3-$os_short-$provider already found in Vagrant box repository. Skipping the addition to Vagrant."
if vagrant box list | grep -q rapid7/metasploitable3-"$os_short"; then
echo "rapid7/metasploitable3-$os_short 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 [ -z $box_import ]; then
if vagrant box add $packer_build_path/"$os_full"_"$provider"_"$box_version".box --name metasploitable3-$os_short; then
if vagrant box add $packer_build_path/"$os_full"_"$provider"_"$box_version".box --name rapid7/metasploitable3-$os_short; then
echo "Box successfully added to Vagrant."
else
echo "Error adding box to Vagrant. See the above output for any error messages."

View File

@ -243,6 +243,31 @@
"{{user `scripts_dir`}}/installs/install_flags.bat",
"{{user `scripts_dir`}}/configs/packer_cleanup.bat"
]
},
{
"type": "file",
"source": "{{user `scripts_dir`}}/configs/disable_firewall.bat",
"destination": "C:/vagrant/startup"
},
{
"type": "file",
"source": "{{user `scripts_dir`}}/configs/enable_firewall.bat",
"destination": "C:/vagrant/startup"
},
{
"type": "file",
"source": "{{user `scripts_dir`}}/configs/configure_firewall.bat",
"destination": "C:/vagrant/startup"
},
{
"type": "file",
"source": "{{user `scripts_dir`}}/installs/install_share_autorun.bat",
"destination": "C:/vagrant/startup"
},
{
"type": "file",
"source": "{{user `scripts_dir`}}/installs/setup_linux_share.bat",
"destination": "C:/vagrant/startup"
}
],
"post-processors": [