Hey Folks, I'm having some trouble parsing the results generated by Nmap::Scanner and was hoping you guys could help out. Here's what I've got:
use Nmap::Scanner; use Data::Dumper; my $scanner = new Nmap::Scanner; $scanner->tcp_connect_scan(); $scanner->add_scan_port('1-1024'); $scanner->max_rtt_timeout(3); $scanner->add_target('127.0.0.1'); my $results = $scanner->scan(); print Dumper($results->{'ALLHOSTS'});
The dump suggests that the output is a hash (I think) with the key Nmap::Scanner::Address=Hash(0x1231234). The problem I'm having is reliably accessing the contents of that key since every time the program runs, I get a different hash address. The solution I have so far is to do something like:
This allows me to retrieve the values associated with the key (e.g. ports info), but it can't be the best way to do it. What would you suggest as an alternative? EDIT: Thanks for the help everyone. It gave me a better understanding of what I was trying to do and gave me a few new tools to look into. Much appreciated.for my $key (keys $results->{'ALLHOSTS'}){ print Dumper($results->{'ALLHOSTS'}{$key}->{'ports'}); }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |