Repository navigation
Closed
Description
Haven't tried to reproduce it yet, for now I managed to attach to running scan and grab some info. I will update this issue if I will have more information.
nmap -n -Pn -oG /tmp/nmap-<ip>-1432834534 -sS --defeat-rst-ratelimit -sU -p T:<long list of ports> --scan-delay 10 <ip>
# nmap --version
Nmap version 7.40 ( https://nmap.org )
Platform: x86_64-pc-linux-gnu
Compiled with: liblua-5.3.3 openssl-1.1.0c libpcre-8.39 libpcap-1.8.1 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select
# uname -a
Linux debian 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64 GNU/Linux
# strace -p1212 -s9999
strace: Process 1212 attached
select(6, [5], NULL, NULL, {tv_sec=9, tv_usec=170055}) = 0 (Timeout)
ioctl(-1, TIOCGPGRP, 0x7ffe4a632bdc) = -1 EBADF (Bad file descriptor)
getpgrp() = 872
sendto(4, "E\0\0,/&\0\0005\6X\321\300\250\n\332P\370\341Z\3206\10:y\221\273\257\0\0\0\0`\2\4\0\210\237\0\0\2\4\5\264", 44, 0, {sa_family=AF_INET, sin_port=htons(2106), sin_addr=inet_addr("<ip>")}, 16) = 44
select(6, [5], NULL, NULL, {tv_sec=9, tv_usec=999728}) = 1 (in [5], left {tv_sec=9, tv_usec=964264})
ioctl(-1, TIOCGPGRP, 0x7ffe4a632bdc) = -1 EBADF (Bad file descriptor)
getpgrp() = 872
select(6, [5], NULL, NULL, {tv_sec=9, tv_usec=963845}^Cstrace: Process 1212 detached
<detached ...>
and above keeps repeating
(gdb) attach 1212
(gdb) bt
#0 0x00002ad3702905e3 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:84
#1 0x0000563913f0c0b9 in pcap_select(pcap*, timeval*) ()
#2 0x0000563913f0c47d in pcap_select(pcap*, long) ()
#3 0x0000563913edfb74 in readip_pcap(pcap*, unsigned int*, long, timeval*, link_header*, bool) ()
#4 0x0000563913ecbbd1 in get_pcap_result(UltraScanInfo*, timeval*) ()
#5 0x0000563913ec43b1 in ultra_scan(std::vector<Target*, std::allocator<Target*> >&, scan_lists*, stype, timeout_info*) ()
#6 0x0000563913e969b1 in nmap_main(int, char**) ()
#7 0x0000563913e68c41 in main ()
# lsof -p 1212
(...)
nmap 1212 root mem REG 0,8 28012 socket:[28012] (stat: No such file or directory)
(...)
# ls -lh /proc/1212/fd
total 0
lr-x------ 1 root root 64 May 12 10:14 0 -> /dev/null
lrwx------ 1 root root 64 May 12 10:14 1 -> socket:[28003]
lrwx------ 1 root root 64 May 12 10:14 2 -> socket:[28003]
l-wx------ 1 root root 64 May 12 10:14 3 -> /tmp/nmap-<ip>-1432834534
lrwx------ 1 root root 64 May 12 10:14 4 -> socket:[28010]
lrwx------ 1 root root 64 May 12 10:14 5 -> socket:[28012]
Metadata
Metadata
Assignees
Labels
No labels
Activity
livelace commentedon May 21, 2020
I'm experiencing the same thing. Firstly I found this link #1385, but after stracing I found this one :)
version:
strace:
some proc info:
logs (they are still filling):
args:
livelace commentedon May 22, 2020
the situation has changed, if replace -sS with -sT - the scanning is completed and nmap doesn't stuck at all (how it was before, stucking last more than 1 day before I killed it).
btw, "Bad file descriptor" appears even for -sT scanning.
livelace commentedon Jun 2, 2020
update. -sT doesn't help :)
I decreased port numbers from default to 78 ports and:
dmiller-nmap commentedon Sep 23, 2022
The
EBADF (Bad file descriptor)error is in response toioctl(TIOCGPGRP), which comes from a call totcgetpgrp()innmap_tty.cc. This is expected behavior when Nmap is not the foreground process of a terminal, though I will see about making it a bit more efficient if I can. The hang issue is unrelated, so I will investigate that.Don't bother with interactive input if we can't open the TTY. See #2042
dmiller-nmap commentedon Sep 23, 2022
I do not think this is a true hang; the
straceoutput shows that probes are still being sent, and each Nmap output listed here shows it is in a different scan phase (First one uses-Pnand shows a TCP RST packet, another is in Ping scan, the last in Service scan). Notably, the original report used--scan-delay 10and a "long list of ports," which means the scan should be expected to take a long time, since Nmap must wait 10 seconds between sending each new probe. I am closing this issue; if you are experiencing hangs, please open a new issue or find an existing issue that describes a hang in the same scan phase with the same scan options as your report.