Nmap, tty and Perl
Noam Rathaus
noamr at beyondsecurity.com
Thu Jun 25 10:59:47 IDT 2009
Hi,
I am trying to get nmap to be a bit more "friendly" by wrapping it
inside a perl script that will cause it to spit out a status by
"sending it a character":
==
#!/usr/bin/perl
use IPC::Open3;
use POSIX ":sys_wait_h";
use FileHandle;
$| = 1;
my $nmap = "/usr/bin/nmap";
my @ips = ('192.168.1.*');
my $cmdline = " $nmap $args -v -v -v -sT -p 1-65535 -oX - ".(join ' ', at ips);
print "cmdline: $cmdline\n";
my ($readfh, $writefh, $errorfh) = (FileHandle->new(),
FileHandle->new(), FileHandle->new());
my $pid = 0;
$pid = open3($writefh, $readfh, $errorfh, $cmdline) || die "Can't open
pipe to $cmdline: $!\n";
while(<$readfh>) {
print $_;
print $writefh "A";
}
print STDERR "done\n";
==
nmap will give out a progress if keyWasPressed is detected the code
for this is found inside nmap_tty.cc which basically does:
if ((c = tty_getchar()) >= 0) {
For some reason the above code doesn't do it, is it because its not
being sent via tty? if so is there a way to fool it?
More information about the Linux-il
mailing list