Re: Nmap, tty and Perl
Hi sara, I am not looking for direct HTML rendering, rather that nmap will give more updates during the process, at the moment it just tells you at the beging "hello" and when its done "here are the results". If you want to get an update on its progress you need to "press" a key on the tty. I will look into zenmap, thanks for the hint. On Sat, Jun 27, 2009 at 11:25 PM, sara fink wrote: > Hello Noam > > I see that you use -oX. You have another flag that you can use --stylesheet > --stylesheet : XSL stylesheet to transform XML output to HTML > > Have you tried that? From Html you can convert to other formats. > > As for the more "interactively" to the user, I am not sure exactly > what you mean. --packet-trace is interactively enough? Or you want > some bar that shows the progress of the scan like "---50%->" > > If the later is what you are looking for, then in zenmap during a scan > it shows how much in % it already scanned. > > I hope I gave you a different point of view. > > On 6/25/09, Noam Rathaus wrote: >> 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 ' ',@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? >> >> ___ >> Linux-il mailing list >> Linux-il@cs.huji.ac.il >> http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il >> > > ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: Nmap, tty and Perl
Hello Noam I see that you use -oX. You have another flag that you can use --stylesheet --stylesheet : XSL stylesheet to transform XML output to HTML Have you tried that? From Html you can convert to other formats. As for the more "interactively" to the user, I am not sure exactly what you mean. --packet-trace is interactively enough? Or you want some bar that shows the progress of the scan like "---50%->" If the later is what you are looking for, then in zenmap during a scan it shows how much in % it already scanned. I hope I gave you a different point of view. On 6/25/09, Noam Rathaus wrote: > 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 ' ',@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? > > ___ > Linux-il mailing list > Linux-il@cs.huji.ac.il > http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il > ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: Nmap, tty and Perl
On Thu, Jun 25, 2009 at 10:59 AM, Noam Rathaus wrote: > 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": I don't know much about nmap but have you looked at either of the following modules ? http://search.cpan.org/dist/Nmap-Scanner/ http://search.cpan.org/dist/Nmap-Parser/ Gabor http://www.perl.org.il/ ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: Nmap, tty and Perl
Gabor, I did - but these two packages appear to be left-ware, they haven't been updated it quite a while. Nmap-Scanner = October 29, 2006 Nmap-Parser = 07 Nov 2008 The first appears much more dead then the second one, which is a shame as the first one is more comprehensive than the second one. On Thu, Jun 25, 2009 at 12:32 PM, Gabor Szabo wrote: > On Thu, Jun 25, 2009 at 12:19 PM, Noam Rathaus > wrote: >> Gabor, >> >> Those two are great packages, but they don't get a more frequent >> progressbar than that which is spit out by Nmap, which is problematic >> if you want to show it more "interactively" to the user. >> >> >> BTW: >> 1) the first one has several bugs, for example it gets stuck as it >> waits for the IO which never comes :D - but it is easy to fix... just >> remove the $error join which is found in the Parser >> 2) the second one is synchronic only (doesn't support asynchronic), >> which is problematic > > Have you reported those bugs (feature request) ? > > You know it is very easy to report a bug, just send an e-mail to > > bug-Nmap-Scanner at rt.cpan.org > bug-Nmap-Parser at rt.cpan.org > > with details of what you have encountered. > > Gabor > > ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: Nmap, tty and Perl
On Thu, Jun 25, 2009 at 12:19 PM, Noam Rathaus wrote: > Gabor, > > Those two are great packages, but they don't get a more frequent > progressbar than that which is spit out by Nmap, which is problematic > if you want to show it more "interactively" to the user. > > > BTW: > 1) the first one has several bugs, for example it gets stuck as it > waits for the IO which never comes :D - but it is easy to fix... just > remove the $error join which is found in the Parser > 2) the second one is synchronic only (doesn't support asynchronic), > which is problematic Have you reported those bugs (feature request) ? You know it is very easy to report a bug, just send an e-mail to bug-Nmap-Scanner at rt.cpan.org bug-Nmap-Parser at rt.cpan.org with details of what you have encountered. Gabor ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: Nmap, tty and Perl
Hi Noam! A few comments on your Perl code. On Thursday 25 June 2009 10:59:47 Noam Rathaus wrote: > 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. You should add "use strict;" and "use warnings;". They prevent many common errors. 2. The FileHandle module was largely superseded by IO::File, IO::Socket, etc. You should use them instead. > $| = 1; > my $nmap = "/usr/bin/nmap"; > my @ips = ('192.168.1.*'); > > my $cmdline = " $nmap $args -v -v -v -sT -p 1-65535 -oX - ".(join ' > ',@ips); print "cmdline: $cmdline\n"; > Where is $args declared and defined? Also consider using http://search.cpan.org/dist/String-ShellQuote/ . > my ($readfh, $writefh, $errorfh) = (FileHandle->new(), > FileHandle->new(), FileHandle->new()); > This can be more elegantly written as map { IO::Handle->new() } (1 .. 3); > my $pid = 0; > > $pid = open3($writefh, $readfh, $errorfh, $cmdline) || die "Can't open > pipe to $cmdline: $!\n"; > > while(<$readfh>) { > print $_; > print $writefh "A"; > } > Perhaps read one character at a time here? (Or set $/ ?) > print STDERR "done\n"; > > == > Regards, Shlomi Fish > 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? > > ___ > Linux-il mailing list > Linux-il@cs.huji.ac.il > http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il -- - Shlomi Fish http://www.shlomifish.org/ Interview with Ben Collins-Sussman - http://xrl.us/bjn8s God gave us two eyes and ten fingers so we will type five times as much as we read. ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: Nmap, tty and Perl
Gabor, Those two are great packages, but they don't get a more frequent progressbar than that which is spit out by Nmap, which is problematic if you want to show it more "interactively" to the user. BTW: 1) the first one has several bugs, for example it gets stuck as it waits for the IO which never comes :D - but it is easy to fix... just remove the $error join which is found in the Parser 2) the second one is synchronic only (doesn't support asynchronic), which is problematic On Thu, Jun 25, 2009 at 12:10 PM, Gabor Szabo wrote: > On Thu, Jun 25, 2009 at 10:59 AM, Noam Rathaus > wrote: >> 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": > > I don't know much about nmap but have you looked at either of the > following modules ? > > http://search.cpan.org/dist/Nmap-Scanner/ > http://search.cpan.org/dist/Nmap-Parser/ > > Gabor > http://www.perl.org.il/ > > ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Nmap, tty and Perl
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 ' ',@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? ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il