Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: [patch] The most minor issue ever: set noninteractive on -iL -
From: David Fifield <david () bamsoftware com>
Date: Tue, 3 Apr 2012 18:17:49 -0700

On Wed, Mar 28, 2012 at 03:01:57PM -0400, Patrick Donnelly wrote:
On Wed, Mar 28, 2012 at 2:14 PM, David Fifield <david () bamsoftware com> wrote:
On Wed, Mar 28, 2012 at 12:07:25PM -0500, Daniel Miller wrote:
List,

While digging through the option parsing in nmap.cc for a
presentation, I noticed that the input of hostnames (-iL or -i)
could come from stdin. I think if this is used, then
o.noninteractive should be set, since there would be no way to get
keystrokes:
Index: nmap.cc
===================================================================
--- nmap.cc    (revision 28355)
+++ nmap.cc    (working copy)
@@ -1048,6 +1048,7 @@
      }
      if (!strcmp(optarg, "-")) {
        o.inputfd = stdin;
+        o.noninteractive = true;
      } else {
        o.inputfd = fopen(optarg, "r");
        if (!o.inputfd) {

I doubt this really matters much, but I thought I'd mention it.

Thanks, Dan, but I think this is incorrect. Nmap doesn't get runtime
interaction keystrokes from stdin, but from the tty. I just tested it
and this works:

nmap --scan-delay 10ms -iL - < input.txt

But this doesn't:

cat input.txt | nmap --scan-delay 10ms -iL -

Probably there is some subshell interaction with the tty that prevents
the second example from working.

The second example doesn't work because, in nmap_tty.cc, Nmap closes
the tty FD if it is not the foreground process group leader. In
tty_init:

#ifndef __CYGWIN32__
    if (tcgetpgrp(tty_fd) != getpid()) {
        close(tty_fd); return;
    }
#endif

getpid should maybe be getpgrp so that Nmap accepts terminal input
even when it's part of a pipeline (i.e. not the process group leader).

I tried this (getpgrp) but it didn't seem to change anything.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/

  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
AlienVault