robertdavidgraham / masscan

TCP port scanner, spews SYN packets asynchronously, scanning entire Internet in under 5 minutes.
GNU Affero General Public License v3.0
23k stars 3.02k forks source link

masscan not working with virtualbox host only adapter. #684

Open cletifer opened 1 year ago

cletifer commented 1 year ago

I wonder if anyone else has this issue or knows a fix. I am running Virtualbox v6.1.34 on an Ubuntu 22.04.1 LTS (5.15.0-47-generic) host when I have a few machines set up in a host-only network within the virtual environment. When I try to run masscan (v1.3.2) against one of the machines in the host-only network without the -e flag, it defaults to my wlan0 interface even though the routing table says to use vboxnet0. I tried forcing it to use vboxnet0 with the -e flag, but now I get errors: root@localhost:~# masscan -v -e vboxnet0 -p1-65535 192.168.56.100 [-] pcap: failed to load: libpcap.so [-] pcap: failed to load: libpcap.A.dylib [-] pcap: failed to load: libpcap.dylib [-] pcap: failed to load: libpcap.so.0.9.5 [-] pcap: failed to load: libpcap.so.0.9.4 [+] pcap: found library: libpcap.so.0.8 [+] interface = vboxnet0 [+] if(vboxnet0): pcap: libpcap version 1.10.1 (with TPACKET_V3) [+] if(vboxnet0): successfully opened [+] interface-type = 1 if:vboxnet0: type=ethernet(1) [+] source-mac = 0a-00-27-00-00-00 [+] source-ip = 192.168.56.1 [+] router-ip = 0.0.0.0 [+] resolving router 0.0.0.0 with ARP (may take some time)... [+] router-mac-ipv4 = 00-00-00-00-00-00 [-] FAIL: ARP timed-out resolving MAC address for router vboxnet0: "0.0.0.0" [hint] try "--router ip 192.0.2.1" to specify different router [hint] try "--router-mac 66-55-44-33-22-11" instead to bypass ARP [hint] try "--interface eth0" to change interface

My routing table is as follows: root@localhost:~# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.0.1 0.0.0.0 UG 600 0 0 wlan0 192.168.0.0 0.0.0.0 255.255.255.0 U 600 0 0 wlan0 192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 vboxnet0

Nmap can scan it just fine: root@localhost:~# nmap -Pn -n -sS -p- -e vboxnet0 --open 192.168.56.100 Starting Nmap 7.80 ( https://nmap.org ) at 2022-09-14 19:04 EDT Nmap scan report for 192.168.56.100 Host is up (0.000095s latency). Not shown: 65505 closed ports PORT STATE SERVICE 21/tcp open ftp 22/tcp open ssh 23/tcp open telnet 25/tcp open smtp 53/tcp open domain 80/tcp open http 111/tcp open rpcbind 139/tcp open netbios-ssn 445/tcp open microsoft-ds 512/tcp open exec 513/tcp open login 514/tcp open shell 1099/tcp open rmiregistry 1524/tcp open ingreslock 2049/tcp open nfs 2121/tcp open ccproxy-ftp 3306/tcp open mysql 3632/tcp open distccd 5432/tcp open postgresql 5900/tcp open vnc 6000/tcp open X11 6667/tcp open irc 6697/tcp open ircs-u 8009/tcp open ajp13 8180/tcp open unknown 8787/tcp open msgsrvr 33444/tcp open unknown 42098/tcp open unknown 43068/tcp open unknown 45971/tcp open unknown MAC Address: 08:00:27:C3:9E:83 (Oracle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 0.82 seconds

Does anyone know what may be causing it or how to fix it? Thanks for your help in advance, and please let me know if you need any more information.

NiuBlibing commented 10 months ago

I've encountered the same issue as well. Upon inspecting the network, I noticed a considerable number of ARP packets, which I suspect might be causing the problem when masscan attempts to retrieve the gateway's MAC address.

To circumvent this issue, I took the following steps:

  1. Manually obtained the MAC address of the gateway using arp -a or arping.
  2. Explicitly specified the --router-mac parameter with the gateway mac like 66-55-44-33-22-11 within the masscan command.
sec13b commented 8 months ago

masscan -v --router-mac 66-55-44-33-22-11 -p1-65535 192.168.56.100