Callbacks – (not our $normal *69)

This is probably the easiest way to write a script with using Nmap::Parser, if you don’t need the general scan session information. During the parsing process, the parser will obtain information of every host. The callback function (in this case ‘booyah()’) is called after the parsing of every host (sequentially). When the callback returns, the parser will delete all information of the host it had sent to the callback. This callback function is called for every host that the parser encounters. The callback function must be setup before parsing

 use Nmap::Parser;
 my $np = new Nmap::Parser;

 $np->callback( \&booyah );

 $np->parsefile('nmap_results.xml');
    # or use parsescan()

 sub booyah {
    my $host = shift; #Nmap::Parser::Host object, just parsed
    print 'IP: ',$host->addr,"\n";
         # ... do more stuff with $host ...

    #when it returns, host object will be deleted from memory
    #(good for processing VERY LARGE files or scans)
 }
This entry was posted in General. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>