rapid7 / metasploitable3

Metasploitable3 is a VM that is built from the ground up with a large amount of security vulnerabilities.
Other
4.73k stars 1.14k forks source link

vagrant up failing on macOS invalid host only networking address #555

Closed jifbrodeur closed 2 years ago

jifbrodeur commented 2 years ago

Issue Description

Please check the General Issues section in the wiki before you submit the issue. If you didn't find your issue mentioned, please give a thorough description of the issue you're seeing. Also, please be sure to include any troubleshooting steps that you've already attempted.

Host System

Command Output: vagrant up

Copy the relevant command output here. If it's long, either post to a gist and add the link here, or isolate the error lines. Bringing machine 'ub1404' up with 'virtualbox' provider... Bringing machine 'win2k8' up with 'virtualbox' provider... ==> ub1404: Box 'rapid7/metasploitable3-ub1404' could not be found. Attempting to find and install... ub1404: Box Provider: virtualbox ub1404: Box Version: >= 0 ==> ub1404: Loading metadata for box 'rapid7/metasploitable3-ub1404' ub1404: URL: https://vagrantcloud.com/rapid7/metasploitable3-ub1404 ==> ub1404: Adding box 'rapid7/metasploitable3-ub1404' (v0.1.12-weekly) for provider: virtualbox ub1404: Downloading: https://vagrantcloud.com/rapid7/boxes/metasploitable3-ub1404/versions/0.1.12-weekly/providers/virtualbox.box ==> ub1404: Successfully added box 'rapid7/metasploitable3-ub1404' (v0.1.12-weekly) for 'virtualbox'! ==> ub1404: Importing base box 'rapid7/metasploitable3-ub1404'... ==> ub1404: Matching MAC address for NAT networking... ==> ub1404: Checking if box 'rapid7/metasploitable3-ub1404' version '0.1.12-weekly' is up to date... ==> ub1404: Setting the name of the VM: Metasploitable3-ub1404 ==> ub1404: Fixed port collision for 22 => 2222. Now on port 2200. ==> ub1404: Clearing any previously set network interfaces... The IP address configured for the host-only network is not within the allowed ranges. Please update the address used to be within the allowed ranges and run the command again.

Address: 172.28.128.3 Ranges: 192.168.56.0/21

There is a limitation on macOS version of VirtualBox, On Linux, Mac OS X and Solaris Oracle VM VirtualBox will only allow IP addresses in 192.68.56.0/21 range to be assigned to host-only adapters.

I tried editing the Vagrantfile found the following line and changed it to no avail.: #ub1404.vm.network "private_network", ip: '192.168.56.10' Thanks for any help

dave-px commented 2 years ago

@jifbrodeur I just ran into the same issue. I changed this line in the Vagrantfile:

ub1404.vm.network "private_network", ip: '172.28.128.3'

To this

ub1404.vm.network "private_network", type: "dhcp"

And that worked for me. However, there may be some win2k8 scripts that can't run without that static address set for the linux box, due to windows trying to mount a share at that address:

_==> win2k8: Running provisioner: shell... win2k8: Running: inline PowerShell script win2k8: win2k8: C:\Windows\system32>copy C:\vagrant\scripts\installs\setup_linux_share.bat C:\Windows win2k8: The system cannot find the path specified. win2k8: win2k8: C:\Windows\system32>reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v share /t REG_SZ /d "C:\Windows\setup_linuxshare.bat" /f win2k8: The operation completed successfully. ==> win2k8: Running provisioner: shell... win2k8: Running: inline PowerShell script win2k8: "Linux host not available." ==> win2k8: Running provisioner: shell... win2k8: Running: inline PowerShell script

dave-px commented 2 years ago

Here's a better workaround that allows the Ubuntu VM to retain its original static 172.28.128.3 address, by placing both VMs on a new VirtualBox internal network using the 172.28.128.0/24 range.

First, add a new VirtualBox dhcpserver for a new internal network named metasploitable3 on the 172.28.128.0/24 range:

vboxmanage dhcpserver add --netname metasploitable3 --ip 172.28.128.1 --netmask 255.255.255.0 --lowerip 172.28.128.50 --upperip 172.28.128.254 --enable

Then, edit the vm.network lines in the Vagrantfile to assign the VMs to the "metasploitable3" internal network:

ub1404.vm.network "private_network", virtualbox__intnet: "metasploitable3", ip: '172.28.128.3'

win2k8.vm.network "private_network", virtualbox__intnet: "metasploitable3", type: "dhcp"

Then, vagrant up.

jifbrodeur commented 2 years ago

Hi Dave and thank you for the recommendations, I was able to build the VM but it does not start, though manually starting it in VirtualBox, brings up Ubuntu. Oddly the IP address is not static, but is given in the correct range and is: 172.28.128.50. The error message I get when building the VM is: Command: ["startvm", "03956b3a-b474-4541-a061-249afa7388db", "--type", "headless"] Stderr: VBoxManage: error: The virtual machine 'Metasploitable3-ub1404' has terminated unexpectedly during startup because of signal 10 VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine Thanks Jean-François

jmartin-tech commented 2 years ago

@jifbrodeur, the issue seems to be environment related, IP address for the virtualization environments can vary by install. The Vagrantfile provided by the project makes an assumption about the IP ranges available. There are two simple adjustments that should address this for your environment.

  1. Update the specified IP address to match you virtualization environment's network range here: https://github.com/rapid7/metasploitable3/blob/45f273705d4fdaf0ad8c8cffa276a53e04869881/Vagrantfile#L12 and here: https://github.com/rapid7/metasploitable3/blob/45f273705d4fdaf0ad8c8cffa276a53e04869881/scripts/installs/setup_linux_share.bat#L2-L5
  2. Update your virtualization environment's address range to use 172.28.128.0/24 for the network the VM is attached to.
jifbrodeur commented 2 years ago

Thanks for everything

hackeroday commented 2 years ago

@dave-px that work!,thank you.