-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nmap "system routes" error as root on FreeBSD (nping too) #2379
Comments
It looks like a big Nmap update came out today and still having the root system route issue. Also of note, IPv6 is also having the routing issue: [ben@SCSUbsd1 ~]$ nmap -6 ::1 Nmap done: 1 IP address (1 host up) scanned in 6.29 seconds [ben@SCSUbsd1 ~]$ sudo nmap -6 ::1 |
I just tried nping and had the same issue: root@SCSUbsd1:~ # nping google.com Nping version 0.7.92SVN ( https://nmap.org/nping ) |
After some more digging I've determined that the commit of libdnet-stripped code on 2020-10-13 in revision 38110 appears to be what broke root's ability to run Nmap on FreeBSD. Running 'svn up -r38109' then compiling allows root to run 'nmap localhost' but 'svn up -r38110' results in the error previously mentioned. Here's the info on the commit: [ben@freebsd13 ~/nmap]$ svn up -r38110 [ben@freebsd13 ~/nmap]$ svn info |
Thanks for hunting this down. The commit ID on github is a5cca6f and it removes an implementation of |
I've been able to do a bit more digging, and a lot of learning, and have created a patch which appears to resolve the issue. I am unsure what the consequences of this patch are but applying the attached diff file (attached as a .txt) to libdnet-stripped/configure allows me to run Nmap as root. Edit: After a bit more digging it looks like the patch adds back some code that is documented a manual on gnu.org so I'm guessing adding it back should have little negative consequences. |
Here is my quick guess about what is going on:
In summary, the fix could be to retrofit --- a/libdnet-stripped/configure.in 2020-10-14 21:08:09.275534843 -0600
+++ b/libdnet-stripped/configure.in 2022-03-23 18:02:44.842111434 -0600
@@ -177,6 +177,9 @@
AC_CHECK_HEADERS(hpsecurity.h stropts.h)
AC_CHECK_HEADERS(net/route.h, [], [],
[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif Or, perhaps even cleaner, would be to leverage AC_INCLUDES_DEFAULT instead: --- a/libdnet-stripped/configure.in 2020-10-14 21:08:09.275534843 -0600
+++ b/libdnet-stripped/configure.in 2022-03-23 18:02:44.842111434 -0600
@@ -177,6 +177,7 @@
AC_CHECK_HEADERS(hpsecurity.h stropts.h)
AC_CHECK_HEADERS(net/route.h, [], [],
[
+AC_INCLUDES_DEFAULT
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif Either of these two patches should rectify the issue. |
@benpratt I do not have a FreeBSD environment readily available. Could you please test the second patch, the one with AC_INCLUDES_DEFAULT? (Do not forget to regenerate |
I certainly can. How do I regenerate 'libdnet-stripped/configure'? Is there a command I can run? |
Just running |
I'm sorry for the delayed response. The second patch appears to have worked. To ensure I did everything properly my process was:
Thank you @nnposter for your help in developing this patch. |
This patch will be committed after April 15 unless concerns are raised. The full scope of the update will be:
|
The fix has been committed as r38374. Thank you for reporting the issue and tracking down the root cause. |
Describe the bug
Running Nmap as root, or using sudo, on FreeBSD returns the following error:
[ben@bepratt-dev ~]$ sudo nmap localhost
Starting Nmap 7.92SVN ( https://nmap.org ) at 2021-10-11 10:34 CDT
route_dst_generic: Failed to obtain system routes: getsysroutes_dnet: route_open() failed
To Reproduce
Expected behavior
The expected behavior is to have Nmap port scan the local system.
Version info (please complete the following information):
nmap --version
:[ben@SCSUbsd1 ~]$ sudo nmap --version
Nmap version 7.92SVN ( https://nmap.org )
Platform: x86_64-unknown-freebsd13.0
Compiled with: nmap-liblua-5.3.5 openssl-1.1.1k-freebsd libssh2-1.9.0 libz-1.2.11 libpcre-8.45 libpcap-1.9.1 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: kqueue poll select
nmap --iflist
[ben@SCSUbsd1 ~]$ nmap --iflist
Starting Nmap 7.92SVN ( https://nmap.org ) at 2021-10-11 18:49 UTC
************************INTERFACES************************
DEV (SHORT) IP/MASK TYPE UP MTU MAC
em0 (em0) 10.50.51.75/16 ethernet up 1500 00:50:56:8A:7F:2A
em0 (em0) fe80:1::250:56ff:fe8a:7f2a/128 ethernet up 1500 00:50:56:8A:7F:2A
lo0 (lo0) 127.0.0.1/8 loopback up 16384
lo0 (lo0) ::1/128 loopback up 16384
lo0 (lo0) fe80:2::1/128 loopback up 16384
ROUTES: NONE FOUND(!)
[ben@SCSUbsd1 ~]$ sudo nmap --iflist
Starting Nmap 7.92SVN ( https://nmap.org ) at 2021-10-11 18:49 UTC
************************INTERFACES************************
DEV (SHORT) IP/MASK TYPE UP MTU MAC
em0 (em0) 10.50.51.75/16 ethernet up 1500 00:50:56:8A:7F:2A
em0 (em0) fe80:1::250:56ff:fe8a:7f2a/128 ethernet up 1500 00:50:56:8A:7F:2A
lo0 (lo0) 127.0.0.1/8 loopback up 16384
lo0 (lo0) ::1/128 loopback up 16384
lo0 (lo0) fe80:2::1/128 loopback up 16384
ROUTES: NONE FOUND(!)
Additional context
Running Nmap as a standard user successfully runs a port scan of the local machine.
Running Nmap as root returns an error stating "route_dst_generic: Failed to obtain system routes: getsysroutes_dnet: route_open() failed".
Running "nmap -sT localhost" returns the same error. I tried this because the default scan for a root user may be different than a standard user.
I believe I was able to run an Nmap port scan as root on FreeBSD 12.2 in early 2021 but FreeBSD 12.2-RELEASE now fails. I'm sorry but I'm not sure when this began failing but I believe it was sometime in the April 2021 timeframe.
The text was updated successfully, but these errors were encountered: