rapid7 / metasploitable3

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

Issues building Ubuntu1404 box - pink screen / SSH timeout #608

Closed vhtmldev closed 1 year ago

vhtmldev commented 1 year 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

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.

PS D:\metasploitable3-workspace\metasploitable3> packer build -force --only=virtualbox-iso .\packer\templates\pro\ubuntu_1404_pro.json
virtualbox-iso: output will be in this color.

==> virtualbox-iso: Retrieving Guest additions
==> virtualbox-iso: Trying C:\Program Files\Oracle\VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso: Trying file://C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso: file://C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso => C:/Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso: Retrieving ISO
==> virtualbox-iso: Trying http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso
==> virtualbox-iso: Trying http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso?checksum=md5%3Aca2531b8cd79ea5b778ede3a524779b9
==> virtualbox-iso: http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso?checksum=md5%3Aca2531b8cd79ea5b778ede3a524779b9 => D:\metasploitable3-workspace\metasploitable3\packer_cache\2020a48ab89bc0319bd7da9cf5ac7d48df932a24.iso
==> virtualbox-iso: Starting HTTP server on port 9001
==> virtualbox-iso: Creating virtual machine...
==> virtualbox-iso: Creating hard drive output-virtualbox-iso\metasploitable3-ub1404.vdi with size 40000 MiB...
==> virtualbox-iso: Mounting ISOs...
    virtualbox-iso: Mounting boot ISO...
==> virtualbox-iso: Creating forwarded port mapping for communicator (SSH, WinRM, etc) (host port 3932)
==> virtualbox-iso: Executing custom VBoxManage commands...
    virtualbox-iso: Executing: modifyvm metasploitable3-ub1404 --memory 4096
    virtualbox-iso: Executing: modifyvm metasploitable3-ub1404 --cpus 2
==> virtualbox-iso: Starting the virtual machine...
==> virtualbox-iso: Waiting 20s for boot...
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Using SSH communicator to connect: 127.0.0.1
==> virtualbox-iso: Waiting for SSH to become available...
==> virtualbox-iso: Timeout waiting for SSH.
==> virtualbox-iso: Cleaning up floppy disk...
==> virtualbox-iso: Deregistering and deleting VM...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored after 2 hours 1 minute: Timeout waiting for SSH.

==> Wait completed after 2 hours 1 minute

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso: Timeout waiting for SSH.

==> Builds finished but no artifacts were created.

The Ubuntu1404 machine is straight up from hell and is just not building as per your instructions.

it boots correctly but after dhcp succeeds the screen goes all pink and then the CLI says waiting for ssh and then nothing happens.

Can you please fix this or just remove the ubuntu1404 option altogether. I've tried building it in multiple environments including ubuntu, WSL, Windows and none of them work.

I understand everyones undying love for windows but why offer ubuntu1404 if its not working at all.

adfoster-r7 commented 1 year ago

I can replicate that locally on a mac with packer 1.8.3 and virtualbox, I didn't verify vmware

As a workaround, I believe the prebuilt VM should work:

mkdir metasploitable3-workspace
cd metasploitable3-workspace
curl -O https://raw.githubusercontent.com/rapid7/metasploitable3/master/Vagrantfile
MS3_DIFFICULTY=easy vagrant up ub1404
adfoster-r7 commented 1 year ago

I kicked off a fresh vmware build, and it succeeded. I did have to tweak the guest OS though:

diff --git a/packer/templates/pro/ubuntu_1404_pro.json b/packer/templates/pro/ubuntu_1404_pro.json
index ec238a3..8794735 100644
--- a/packer/templates/pro/ubuntu_1404_pro.json
+++ b/packer/templates/pro/ubuntu_1404_pro.json
@@ -26,7 +26,7 @@
       "ssh_password": "vagrant",
       "ssh_timeout": "2h",
       "shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
-      "guest_os_type": "Ubuntu_64",
+      "guest_os_type": "Ubuntu-64",
       "tools_upload_flavor": "linux",
       "disk_size": 40000,
       "vm_name": "metasploitable3-ub1404",

Output:

vmware build ``` ➜ metasploitable3 git:(master) ✗ packer build -force --only=vmware-iso ./packer/templates/pro/ubuntu_1404_pro.json Warning: Warning when preparing build: "vmware-iso" Your vmx data contains the following variable(s), which Packer normally sets when it generates its own default vmx template. This may cause your build to fail or behave unpredictably: numvcpus, memsize, scsi0.virtualDev vmware-iso: output will be in this color. ==> vmware-iso: Retrieving ISO ==> vmware-iso: Trying http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso ==> vmware-iso: Trying http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso?checksum=md5%3Aca2531b8cd79ea5b778ede3a524779b9 ==> vmware-iso: http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso?checksum=md5%3Aca2531b8cd79ea5b778ede3a524779b9 => /Users/user/.cache/packer/2020a48ab89bc0319bd7da9cf5ac7d48df932a24.iso ==> vmware-iso: Configuring output and export directories... ==> vmware-iso: Creating required virtual machine disks ==> vmware-iso: Building and writing VMX file ==> vmware-iso: Starting HTTP server on port 9001 ==> vmware-iso: Starting virtual machine... ==> vmware-iso: Connecting to VNC... ==> vmware-iso: Waiting 20s for boot... ==> vmware-iso: Typing the boot command over VNC... ==> vmware-iso: Waiting for SSH to become available... ==> vmware-iso: Connected to SSH! ==> vmware-iso: Uploading the 'linux' VMware Tools ==> vmware-iso: Provisioning with chef-solo vmware-iso: Installing Chef... ==> vmware-iso: % Total % Received % Xferd Average Speed Time Time Time Current ==> vmware-iso: Dload Upload Total Spent Left Speed ==> vmware-iso: 100 23526 100 23526 0 0 154k 0 --:--:-- --:--:-- --:--:-- 153k vmware-iso: ubuntu 14.04 x86_64 vmware-iso: Getting information for chef stable for ubuntu... vmware-iso: downloading https://omnitruck.chef.io/stable/chef/metadata?v=&p=ubuntu&pv=14.04&m=x86_64 vmware-iso: to file /tmp/install.sh.1034/metadata.txt vmware-iso: trying wget... vmware-iso: sha1 bdf95b94236788173bc27b0888a5b5cd35517796 vmware-iso: sha256 71d303ff3ea6e56c070e595fd5b84ea5904abfe14af884bd9c73ebfa49f72452 vmware-iso: url https://packages.chef.io/files/stable/chef/15.1.36/ubuntu/14.04/chef_15.1.36-1_amd64.deb vmware-iso: version 15.1.36 vmware-iso: downloaded metadata file looks valid... vmware-iso: downloading https://packages.chef.io/files/stable/chef/15.1.36/ubuntu/14.04/chef_15.1.36-1_amd64.deb vmware-iso: to file /tmp/install.sh.1034/chef_15.1.36-1_amd64.deb vmware-iso: trying wget... vmware-iso: Comparing checksum with sha256sum... vmware-iso: vmware-iso: WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING vmware-iso: vmware-iso: You are installing a package without a version pin. If you are installing vmware-iso: on production servers via an automated process this is DANGEROUS and you will vmware-iso: be upgraded without warning on new releases, even to new major releases. vmware-iso: Letting the version float is only appropriate in test, development or vmware-iso: CI/CD environments. vmware-iso: vmware-iso: WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING vmware-iso: vmware-iso: Installing chef vmware-iso: installing with dpkg... vmware-iso: Selecting previously unselected package chef. vmware-iso: (Reading database ... 61955 files and directories currently installed.) vmware-iso: Preparing to unpack .../chef_15.1.36-1_amd64.deb ... vmware-iso: Unpacking chef (15.1.36-1) ... vmware-iso: Setting up chef (15.1.36-1) ... vmware-iso: Thank you for installing Chef Infra Client! For help getting started visit https://learn.chef.io vmware-iso: Creating directory: /tmp/packer-chef-solo vmware-iso: Creating directory: /tmp/packer-chef-solo/cookbooks-0 vmware-iso: Creating configuration file 'solo.rb' vmware-iso: Creating JSON attribute file vmware-iso: Executing Chef: sudo chef-solo --no-color -c /tmp/packer-chef-solo/solo.rb -j /tmp/packer-chef-solo/node.json vmware-iso: Starting Chef Infra Client, version 15.1.36 vmware-iso: resolving cookbooks for run list: ["metasploitable::vm_tools"] vmware-iso: Synchronizing Cookbooks: vmware-iso: - metasploitable (0.1.0) vmware-iso: - apt (7.2.0) vmware-iso: - mysql (8.5.1) vmware-iso: - iptables (4.5.0) vmware-iso: - docker (4.9.3) vmware-iso: Installing Cookbook Gems: vmware-iso: Compiling Cookbooks... vmware-iso: Converging 0 resources vmware-iso: vmware-iso: Running handlers: vmware-iso: Running handlers complete vmware-iso: Chef Infra Client finished, 0/0 resources updated in 05 seconds ==> vmware-iso: Gracefully halting virtual machine... vmware-iso: Waiting for VMware to clean up after itself... ==> vmware-iso: Deleting unnecessary VMware files... vmware-iso: Deleting: output-vmware-iso/metasploitable3-ub1404.plist vmware-iso: Deleting: output-vmware-iso/startMenu.plist vmware-iso: Deleting: output-vmware-iso/vm.scoreboard vmware-iso: Deleting: output-vmware-iso/vmware.log ==> vmware-iso: Compacting all attached virtual disks... vmware-iso: Compacting virtual disk 1 ==> vmware-iso: Cleaning VMX prior to finishing up... vmware-iso: Detaching ISO from CD-ROM device ide0:0... vmware-iso: Disabling VNC server... ==> vmware-iso: Skipping export of virtual machine... ==> vmware-iso: Running post-processor: vagrant ==> vmware-iso (vagrant): Creating a dummy Vagrant box to ensure the host system can create one correctly ==> vmware-iso (vagrant): Creating Vagrant box for 'vmware' provider vmware-iso (vagrant): Copying: output-vmware-iso/disk-s001.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s002.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s003.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s004.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s005.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s006.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s007.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s008.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s009.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk-s010.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/disk.vmdk vmware-iso (vagrant): Copying: output-vmware-iso/metasploitable3-ub1404.nvram vmware-iso (vagrant): Copying: output-vmware-iso/metasploitable3-ub1404.vmsd vmware-iso (vagrant): Copying: output-vmware-iso/metasploitable3-ub1404.vmx vmware-iso (vagrant): Copying: output-vmware-iso/metasploitable3-ub1404.vmxf vmware-iso (vagrant): Compressing: Vagrantfile vmware-iso (vagrant): Compressing: disk-s001.vmdk vmware-iso (vagrant): Compressing: disk-s002.vmdk vmware-iso (vagrant): Compressing: disk-s003.vmdk vmware-iso (vagrant): Compressing: disk-s004.vmdk vmware-iso (vagrant): Compressing: disk-s005.vmdk vmware-iso (vagrant): Compressing: disk-s006.vmdk vmware-iso (vagrant): Compressing: disk-s007.vmdk vmware-iso (vagrant): Compressing: disk-s008.vmdk vmware-iso (vagrant): Compressing: disk-s009.vmdk vmware-iso (vagrant): Compressing: disk-s010.vmdk vmware-iso (vagrant): Compressing: disk.vmdk vmware-iso (vagrant): Compressing: metadata.json vmware-iso (vagrant): Compressing: metasploitable3-ub1404.nvram vmware-iso (vagrant): Compressing: metasploitable3-ub1404.vmsd vmware-iso (vagrant): Compressing: metasploitable3-ub1404.vmx vmware-iso (vagrant): Compressing: metasploitable3-ub1404.vmxf Build 'vmware-iso' finished after 5 minutes 32 seconds. ==> Wait completed after 5 minutes 32 seconds ==> Builds finished. The artifacts of successful builds are: --> vmware-iso: 'vmware' provider box: /Users/user/metasploitable3/packer/templates/pro/../../builds/ubuntu_1404_vmware_0.1.0_pro.box ```

So presumably what you're hitting is a virtualbox regression

vhtmldev commented 1 year ago

Ok so i tried to the workaround yes it actually works with vbox and i was able to properly build the image.

I think my workspace mightve been borked as i did try the prebuilt but it was giving me some errors.

Anyhow, the workaround fixed it! Thank you!