Discussion:
nping command line parsing: set source IP address
Perry Hooker
2013-05-15 23:11:38 UTC
Permalink
I've run in to some problems using nping 0.6.25 with the command-line option to set the source IP address (-S, --source-ip) on CentOS 6.2. Specifically, when I specify a numeric source IP address, e.g.

$ nping -c 1 -S 192.168.1.1 127.0.0.1

I get the error message

WARNING: No targets specified, so 0 hosts pinged.

However, the command

$ nping -c 1 -S random 127.0.0.1

functions as expected.

An examination of the

case 'S':

clause in ArgParser.cc reveals that the value of argc is reset to 0 by the call to atoIP. This causes the grab_next_host_spec method in netutil.cc to return NULL before parsing the target argument. Changing the line in grab_next_host_spec function from

return( (optind < argc) ? fakeargv[optind++] : NULL);

to

return fakeargv[optind++];

seems to work around the problem, but I'm unclear as to why this does NOT result in an infinite loop during parsing of target host specifications (at the end of the parseArguments method in ArgParser.cc). Removing the line

fakeargv[argc] = NULL;

in nmap.cc doesn't seem to change this behavior. I'm also not sure why the value of argc is modified in the first place. I suspect it's related to the getopt family of functions, but I'm not sure. Guidance / corrections to my reasoning much appreciated.

rphv
Perry Hooker
2013-05-16 17:01:17 UTC
Permalink
EDIT: The assignment

fakeargv[argc] = NULL;

in nmap.cc has nothing to do with this issue; apologies for the misdirection. Changing grab_next_host_spec() method in netutil.cc to eliminate the comparison between optind and argc works because argv[] is terminated with a null value (per the C++ language standard). I still don't know why the value of argc changes after the call to atoIP(); my best guess is that argc is overwritten by an overzealous reference into argv somewhere down the line.

-----Original Message-----
From: dev [mailto:dev-***@nmap.org] On Behalf Of Perry Hooker
Sent: Wednesday, May 15, 2013 5:12 PM
To: ***@nmap.org
Subject: nping command line parsing: set source IP address

I've run in to some problems using nping 0.6.25 with the command-line option to set the source IP address (-S, --source-ip) on CentOS 6.2. Specifically, when I specify a numeric source IP address, e.g.

$ nping -c 1 -S 192.168.1.1 127.0.0.1

I get the error message

WARNING: No targets specified, so 0 hosts pinged.

However, the command

$ nping -c 1 -S random 127.0.0.1

functions as expected.

An examination of the

case 'S':

clause in ArgParser.cc reveals that the value of argc is reset to 0 by the call to atoIP. This causes the grab_next_host_spec method in netutil.cc to return NULL before parsing the target argument. Changing the line in grab_next_host_spec function from


return( (optind < argc) ? fakeargv[optind++] : NULL);

to

return fakeargv[optind++];

seems to work around the problem, but I'm unclear as to why this does NOT result in an infinite loop during parsing of target host specifications (at the end of the parseArguments method in ArgParser.cc). Removing the line

fakeargv[argc] = NULL;

in nmap.cc doesn't seem to change this behavior. I'm also not sure why the value of argc is modified in the first place. I suspect it's related to the getopt family of functions, but I'm not sure. Guidance / corrections to my reasoning much appreciated.

rphv

_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/
David Fifield
2013-05-17 07:44:37 UTC
Permalink
Post by Perry Hooker
I've run in to some problems using nping 0.6.25 with the command-line
option to set the source IP address (-S, --source-ip) on CentOS 6.2.
Specifically, when I specify a numeric source IP address, e.g.
$ nping -c 1 -S 192.168.1.1 127.0.0.1
I get the error message
WARNING: No targets specified, so 0 hosts pinged.
However, the command
$ nping -c 1 -S random 127.0.0.1
functions as expected.
Thanks for this report. However I can't reproduce this at all. Did you
build Nping from source? Try "make distclean" followed by a rebuild.

David Fifield
Perry Hooker
2013-05-17 16:36:48 UTC
Permalink
Yes, I built Nping from source. "make distclean" followed by rebuild had no effect. FWIW, this behavior also manifests on our servers running RHEL Server release 6.2 Beta (Santiago). Please let me know what details I can provide to help reproduce this behavior.

-----Original Message-----
From: David Fifield [mailto:***@bamsoftware.com]
Sent: Friday, May 17, 2013 1:45 AM
To: Perry Hooker
Cc: ***@nmap.org
Subject: Re: nping command line parsing: set source IP address
Post by Perry Hooker
I've run in to some problems using nping 0.6.25 with the command-line
option to set the source IP address (-S, --source-ip) on CentOS 6.2.
Specifically, when I specify a numeric source IP address, e.g.
$ nping -c 1 -S 192.168.1.1 127.0.0.1
I get the error message
WARNING: No targets specified, so 0 hosts pinged.
However, the command
$ nping -c 1 -S random 127.0.0.1
functions as expected.
Thanks for this report. However I can't reproduce this at all. Did you build Nping from source? Try "make distclean" followed by a rebuild.

David Fifield
David Fifield
2013-05-17 17:47:40 UTC
Permalink
Post by Perry Hooker
Yes, I built Nping from source. "make distclean" followed by rebuild
had no effect. FWIW, this behavior also manifests on our servers
running RHEL Server release 6.2 Beta (Santiago). Please let me know
what details I can provide to help reproduce this behavior.
It might help if you can find another machine that does not exhibit the
behavior, and see what's different about it. I still suspect something
in the local configuration. This is the output I see with 0.6.25 on
Debian 7:

$ ./nping -c 1 -S 192.168.1.1 127.0.0.1

Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT
SENT (0.0017s) Starting TCP Handshake > 127.0.0.1:80
RECV (0.0018s) Possible TCP RST received from 127.0.0.1:80 --> Connection refused

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
TCP connection attempts: 1 | Successful connections: 0 | Failed: 1 (100.00%)
Tx time: 0.00121s | Tx bytes/s: 66115.70 | Tx pkts/s: 826.45
Rx time: 0.00131s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00
Nping done: 1 IP address pinged in 0.00 seconds

$ ./nping -c 1 -S random 127.0.0.1

Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT
SENT (0.0016s) Starting TCP Handshake > 127.0.0.1:80
RECV (0.0017s) Possible TCP RST received from 127.0.0.1:80 --> Connection refused

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
TCP connection attempts: 1 | Successful connections: 0 | Failed: 1 (100.00%)
Tx time: 0.00123s | Tx bytes/s: 64935.06 | Tx pkts/s: 811.69
Rx time: 0.00128s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00
Nping done: 1 IP address pinged in 0.00 seconds

$ sudo ./nping -c 1 -S 192.168.1.1 127.0.0.1

Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT
SENT (0.0602s) ICMP 192.168.1.1 > 127.0.0.1 Echo request (type=8/code=0) ttl=64 id=11543 iplen=28
nping_event_handler(): READ-PCAP killed: Resource temporarily unavailable

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
Raw packets sent: 1 (28B) | Rcvd: 0 (0B) | Lost: 1 (100.00%)
Tx time: 0.00122s | Tx bytes/s: 23007.40 | Tx pkts/s: 821.69
Rx time: 1.00120s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00
Nping done: 1 IP address pinged in 1.06 seconds

$ sudo ./nping -c 1 -S random 127.0.0.1

Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT
SENT (0.0586s) ICMP 88.131.55.162 > 127.0.0.1 Echo request (type=8/code=0) ttl=64 id=54569 iplen=28
nping_event_handler(): READ-PCAP killed: Resource temporarily unavailable

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
Raw packets sent: 1 (28B) | Rcvd: 0 (0B) | Lost: 1 (100.00%)
Tx time: 0.00127s | Tx bytes/s: 22134.39 | Tx pkts/s: 790.51
Rx time: 1.00075s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00
Nping done: 1 IP address pinged in 1.06 seconds

David Fifield
Perry Hooker
2013-05-17 19:37:42 UTC
Permalink
I compiled nmap/nping on a fresh install of CentOS 6.2, and the command worked as expected. This seems to uphold your suspicions about something in the local configuration. My first thought: something to do with the getopt family of commands.

Thank you for the advice thus far.

-----Original Message-----
From: David Fifield [mailto:***@bamsoftware.com]
Sent: Friday, May 17, 2013 11:48 AM
To: Perry Hooker
Cc: ***@nmap.org
Subject: Re: nping command line parsing: set source IP address
Post by Perry Hooker
Yes, I built Nping from source. "make distclean" followed by rebuild
had no effect. FWIW, this behavior also manifests on our servers
running RHEL Server release 6.2 Beta (Santiago). Please let me know
what details I can provide to help reproduce this behavior.
It might help if you can find another machine that does not exhibit the behavior, and see what's different about it. I still suspect something in the local configuration. This is the output I see with 0.6.25 on Debian 7:

$ ./nping -c 1 -S 192.168.1.1 127.0.0.1

Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT SENT (0.0017s) Starting TCP Handshake > 127.0.0.1:80 RECV (0.0018s) Possible TCP RST received from 127.0.0.1:80 --> Connection refused

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A TCP connection attempts: 1 | Successful connections: 0 | Failed: 1 (100.00%) Tx time: 0.00121s | Tx bytes/s: 66115.70 | Tx pkts/s: 826.45 Rx time: 0.00131s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00 Nping done: 1 IP address pinged in 0.00 seconds

$ ./nping -c 1 -S random 127.0.0.1

Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT SENT (0.0016s) Starting TCP Handshake > 127.0.0.1:80 RECV (0.0017s) Possible TCP RST received from 127.0.0.1:80 --> Connection refused

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A TCP connection attempts: 1 | Successful connections: 0 | Failed: 1 (100.00%) Tx time: 0.00123s | Tx bytes/s: 64935.06 | Tx pkts/s: 811.69 Rx time: 0.00128s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00 Nping done: 1 IP address pinged in 0.00 seconds

$ sudo ./nping -c 1 -S 192.168.1.1 127.0.0.1

Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT SENT (0.0602s) ICMP 192.168.1.1 > 127.0.0.1 Echo request (type=8/code=0) ttl=64 id=11543 iplen=28
nping_event_handler(): READ-PCAP killed: Resource temporarily unavailable

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A Raw packets sent: 1 (28B) | Rcvd: 0 (0B) | Lost: 1 (100.00%) Tx time: 0.00122s | Tx bytes/s: 23007.40 | Tx pkts/s: 821.69 Rx time: 1.00120s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00 Nping done: 1 IP address pinged in 1.06 seconds

$ sudo ./nping -c 1 -S random 127.0.0.1

Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT SENT (0.0586s) ICMP 88.131.55.162 > 127.0.0.1 Echo request (type=8/code=0) ttl=64 id=54569 iplen=28
nping_event_handler(): READ-PCAP killed: Resource temporarily unavailable

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A Raw packets sent: 1 (28B) | Rcvd: 0 (0B) | Lost: 1 (100.00%) Tx time: 0.00127s | Tx bytes/s: 22134.39 | Tx pkts/s: 790.51 Rx time: 1.00075s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00 Nping done: 1 IP address pinged in 1.06 seconds

David Fifield
Luis MartinGarcia.
2013-05-18 07:58:16 UTC
Permalink
I have tested this in a Linux Mint box and I can't reproduce it either.

Regards,

Luis MartinGarcia.
Post by Perry Hooker
I compiled nmap/nping on a fresh install of CentOS 6.2, and the command worked as expected. This seems to uphold your suspicions about something in the local configuration. My first thought: something to do with the getopt family of commands.
Thank you for the advice thus far.
-----Original Message-----
Sent: Friday, May 17, 2013 11:48 AM
To: Perry Hooker
Subject: Re: nping command line parsing: set source IP address
Post by Perry Hooker
Yes, I built Nping from source. "make distclean" followed by rebuild
had no effect. FWIW, this behavior also manifests on our servers
running RHEL Server release 6.2 Beta (Santiago). Please let me know
what details I can provide to help reproduce this behavior.
$ ./nping -c 1 -S 192.168.1.1 127.0.0.1
Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT SENT (0.0017s) Starting TCP Handshake > 127.0.0.1:80 RECV (0.0018s) Possible TCP RST received from 127.0.0.1:80 --> Connection refused
Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A TCP connection attempts: 1 | Successful connections: 0 | Failed: 1 (100.00%) Tx time: 0.00121s | Tx bytes/s: 66115.70 | Tx pkts/s: 826.45 Rx time: 0.00131s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00 Nping done: 1 IP address pinged in 0.00 seconds
$ ./nping -c 1 -S random 127.0.0.1
Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT SENT (0.0016s) Starting TCP Handshake > 127.0.0.1:80 RECV (0.0017s) Possible TCP RST received from 127.0.0.1:80 --> Connection refused
Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A TCP connection attempts: 1 | Successful connections: 0 | Failed: 1 (100.00%) Tx time: 0.00123s | Tx bytes/s: 64935.06 | Tx pkts/s: 811.69 Rx time: 0.00128s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00 Nping done: 1 IP address pinged in 0.00 seconds
$ sudo ./nping -c 1 -S 192.168.1.1 127.0.0.1
Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT SENT (0.0602s) ICMP 192.168.1.1 > 127.0.0.1 Echo request (type=8/code=0) ttl=64 id=11543 iplen=28
nping_event_handler(): READ-PCAP killed: Resource temporarily unavailable
Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A Raw packets sent: 1 (28B) | Rcvd: 0 (0B) | Lost: 1 (100.00%) Tx time: 0.00122s | Tx bytes/s: 23007.40 | Tx pkts/s: 821.69 Rx time: 1.00120s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00 Nping done: 1 IP address pinged in 1.06 seconds
$ sudo ./nping -c 1 -S random 127.0.0.1
Starting Nping 0.6.25 ( http://nmap.org/nping ) at 2013-05-17 10:46 PDT SENT (0.0586s) ICMP 88.131.55.162 > 127.0.0.1 Echo request (type=8/code=0) ttl=64 id=54569 iplen=28
nping_event_handler(): READ-PCAP killed: Resource temporarily unavailable
Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A Raw packets sent: 1 (28B) | Rcvd: 0 (0B) | Lost: 1 (100.00%) Tx time: 0.00127s | Tx bytes/s: 22134.39 | Tx pkts/s: 790.51 Rx time: 1.00075s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00 Nping done: 1 IP address pinged in 1.06 seconds
David Fifield
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/
Loading...