robertdavidgraham / masscan

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

Masscan not recieving packets #447

Open youngjew opened 4 years ago

youngjew commented 4 years ago

Hello, I found a very strange scanner behavior (as it turned out, zmap is also prone to this problem)

It all started with the fact that I purchased a virtual server (KVM vps) ( of course for hosts scanning). The first thing I discovered was the fact that there were no results in the scanner output! (found=0 on the big port and address ranges).

Different configuration options --router-ip -router-mac --adapter-ip --adapter-mac not affect situation. On tcpdump log it is clearly seen that the masscan tcp packets are not being returned. (received back). I tried to customize pf_ring, but it is not working with virtio without special configuration from provider KVM. So, i tried different libpcap builds, nothing helps.

Which way to think?, Im asking for help :\

Different logs:

./masscan/bin//masscan x.x.x.x -p13390-13391 -Pn --source-port 10000 -e ens18 -vv pcap: found library: libpcap.so pfring: found 'libpfring.so'! pfring: successfully loaded PF_RING API pfring: found 'pf_ring' driver pfring: found 'pf_ring' driver module if: initializing adapter interface if: interface=ens18 if:ens18: adapter-ip=a.b.c.54 if:ens18: type=ethernet(1) if:ens18: adapter-mac=xx-xx-xx-xx-xx-xx if:ens18: pcap=libpcap version 1.8.1 if:ens18: opening... if:ens18: successfully opened if:ens18: not receiving transmits if:ens18: looking for default gateway if:ens18: router-ip=a.b.c.1 if:ens18:arp: resolving IPv4 address arp: opcode=1, not reply(2) arp: opcode=1, not reply(2) arp: opcode=1, not reply(2) arp: opcode=1, not reply(2) arp: opcode=1, not reply(2) if:ens18: router-mac=xx-xx-xx-xx-xx-xx if:ens18: initialization done.

Starting masscan 1.0.6 (http://bit.ly/14GZzcT) at 2019-09-17 11:44:49 GMT THREAD: xmit: starting thread #0 -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth Initiating SYN Stealth Scan Scanning 1 hosts [2 ports/host] THREAD: status: starting thread maxrate = 100.00 THREAD: recv: starting thread #0 0:00:00 remaining, found=0 THREAD: recv: starting main loop THREAD: xmit done, waiting for receive thread to realize this ^Cwaiting several seconds to exit...


But...

nmap xx.xx.xx.xx -p13390-13391 -Pn --source-port 10000 -e ens18 -vv

Starting Nmap 7.40 ( https://nmap.org ) at 2019-09-17 14:48 MSK Initiating Parallel DNS resolution of 1 host. at 14:48 Completed Parallel DNS resolution of 1 host. at 14:48, 0.71s elapsed Initiating SYN Stealth Scan at 14:48 Scanning xx.xx.xx.xx [2 ports] Discovered open port 13391/tcp on xx.xx.xx.xx Completed SYN Stealth Scan at 14:48, 3.56s elapsed (2 total ports) Nmap scan report for xx.xx.xx.xx Host is up, received user-set (0.25s latency). Scanned at 2019-09-17 14:48:27 MSK for 4s PORT STATE SERVICE REASON 13390/tcp filtered unknown no-response 13391/tcp open unknown syn-ack ttl 115

Read data files from: /usr/bin/../share/nmap Nmap done: 1 IP address (1 host up) scanned in 4.34 seconds Raw packets sent: 3 (132B) | Rcvd: 1 (44B)


ethtool -k ens18 Features for ens18: rx-checksumming: on [fixed] tx-checksumming: on tx-checksum-ipv4: off [fixed] tx-checksum-ip-generic: on tx-checksum-ipv6: off [fixed] tx-checksum-fcoe-crc: off [fixed] tx-checksum-sctp: off [fixed] scatter-gather: on tx-scatter-gather: on tx-scatter-gather-fraglist: off [fixed] tcp-segmentation-offload: on tx-tcp-segmentation: on tx-tcp-ecn-segmentation: on tx-tcp-mangleid-segmentation: off tx-tcp6-segmentation: on udp-fragmentation-offload: on generic-segmentation-offload: on generic-receive-offload: on large-receive-offload: off [fixed] rx-vlan-offload: off [fixed] tx-vlan-offload: off [fixed] ntuple-filters: off [fixed] receive-hashing: off [fixed] highdma: on [fixed] rx-vlan-filter: on [fixed] vlan-challenged: off [fixed] tx-lockless: off [fixed] netns-local: off [fixed] tx-gso-robust: on [fixed] tx-fcoe-segmentation: off [fixed] tx-gre-segmentation: off [fixed] tx-gre-csum-segmentation: off [fixed] tx-ipxip4-segmentation: off [fixed] tx-ipxip6-segmentation: off [fixed] tx-udp_tnl-segmentation: off [fixed] tx-udp_tnl-csum-segmentation: off [fixed] tx-gso-partial: off [fixed] tx-sctp-segmentation: off [fixed] fcoe-mtu: off [fixed] tx-nocache-copy: off loopback: off [fixed] rx-fcs: off [fixed] rx-all: off [fixed] tx-vlan-stag-hw-insert: off [fixed] rx-vlan-stag-hw-parse: off [fixed] rx-vlan-stag-filter: off [fixed] l2-fwd-offload: off [fixed] busy-poll: on [fixed] hw-tc-offload: off [fixed]


ifconfig ens18: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet a.b.c.54 netmask 255.255.255.0 broadcast a.b.c.255 inet6 xxxx::xxxx:xxxx:xxxx:xxxx prefixlen 64 scopeid 0x20 ether xx:xx:xx:xx:xx txqueuelen 1000 (Ethernet) RX packets 10916048 bytes 947572475 (903.6 MiB) RX errors 0 dropped 2775 overruns 0 frame 0 TX packets 70155382 bytes 3799844999 (3.5 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ethtool -i ens18 driver: virtio_net version: 1.0.0 firmware-version: expansion-rom-version: bus-info: 0000:00:12.0 supports-statistics: no supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no

youngjew commented 4 years ago

I found an interesting thing. There is code string from templ-pkt.c "\x02\x04\x05\xb4" / added options [mss 1460] / But. This tcp segment does not send. 0x0020: 5002 ffff fba2 0000 P.......

mzpqnxow commented 3 years ago

I'm not sure this is at all related to your issue (it probably isn't) but if you weren't aware, the pfring userspace library packages include their own libpcap shared and static libraries. Depending on how you installed pfring, these may be in /usr/lib, /usr/local/lib, or anywhere else if you specified a custom location. It's possible masscan is loading the vanilla libpcap shared library from e.g. /usr/lib while the pfring libpcap is in /usr/local/lib

You could probably test pretty easily to see if this is related at all by verifying the location of the pfring libpcap library (find /usr /lib -name libpcap\*so) and if you see two different copies, (let's say you find one in /usr/lib, one in /usr/local/lib) try setting LD_LIBRARY_PATH=/usr/local/lib when running masscan.

Sorry if this isn't helpful but it's something that came to mind as a possible issue