@@ -3,7 +3,7 @@ package Nmap::Parser;
33use strict;
44use XML::Twig;
55
6- our $VERSION = 1.32 ;
6+ our $VERSION = 1.33 ;
77
88
99sub new {
@@ -628,7 +628,7 @@ sub __host_trace_error_tag_hdlr {
628628
629629 my $error_tag = $trace_tag -> first_child(' error' );
630630 if ( defined $error_tag ) {
631-
631+
632632 # If an error happens, always provide a true value even if
633633 # it doesn't contains a useful string
634634 my $errorstr = $error_tag -> {att }-> {errorstr } || 1;
@@ -1118,44 +1118,44 @@ Nmap::Parser - parse nmap scan data with perl
11181118
11191119 use Nmap::Parser;
11201120 my $np = new Nmap::Parser;
1121-
1121+
11221122 $np->parsescan($nmap_path, $nmap_args, @ips);
11231123 #or
11241124 $np->parsefile($file_xml);
1125-
1125+
11261126 my $session = $np->get_session();
11271127 #a Nmap::Parser::Session object
1128-
1128+
11291129 my $host = $np->get_host($ip_addr);
11301130 #a Nmap::Parser::Host object
1131-
1131+
11321132 my $service = $host->tcp_service(80);
11331133 #a Nmap::Parser::Host::Service object
1134-
1134+
11351135 my $os = $host->os_sig();
11361136 #a Nmap::Parser::Host::OS object
1137-
1137+
11381138 #---------------------------------------
1139-
1139+
11401140 my $np2 = new Nmap::Parser;
1141-
1141+
11421142 $np2->callback(\&my_callback);
1143-
1143+
11441144 $np2->parsefile($file_xml);
11451145 #or
11461146 $np2->parsescan($nmap_path, $nmap_args, @ips);
1147-
1147+
11481148 sub my_callback {
1149-
1149+
11501150 my $host = shift;
11511151 #Nmap::Parser::Host object
11521152 #.. see documentation for all methods ...
11531153
11541154 }
11551155
11561156
1157- I<For a full listing of methods see the documentation corresponding to each object. >
1158- You can also visit the website L<http ://apersaud. github.io/ Nmap-Parser/ > for additional installation instructions.
1157+ I<For a full listing of methods see the documentation corresponding to each object. >
1158+ You can also visit the website L<https ://github.com/modernistik/ Nmap-Parser> for additional installation instructions.
11591159
11601160=head1 DESCRIPTION
11611161
@@ -1164,7 +1164,7 @@ It is implemented by parsing the xml scan data that is generated by nmap. This
11641164will enable anyone who utilizes nmap to quickly create fast and robust security scripts
11651165that utilize the powerful port scanning abilities of nmap.
11661166
1167- The latest version of this module can be found on here L<http ://apersaud. github.io/ Nmap-Parser/ >
1167+ The latest version of this module can be found on here L<https ://github.com/modernistik/ Nmap-Parser>
11681168
11691169=head1 OVERVIEW
11701170
@@ -1179,7 +1179,7 @@ operating system signature information (OS guessed names, classes, osfamily..etc
11791179 Nmap::Parser -- Core parser
11801180 |
11811181 +--Nmap::Parser::Session -- Nmap scan session information
1182- |
1182+ |
11831183 +--Nmap::Parser::Host -- General host information
11841184 | |
11851185 | |-Nmap::Parser::Host::Service -- Port service information
@@ -1258,7 +1258,7 @@ you are parsing lots of nmap scan data files with persistent variables.
12581258Sets the parsing mode to be done using the callback function. It takes the parameter
12591259of a code reference or a reference to a function. If no code reference is given,
12601260it resets the mode to normal (no callback).
1261-
1261+
12621262 $np->callback(\&my_function); #sets callback, my_function() will be called
12631263 $np->callback(); #resets it, no callback function called. Back to normal.
12641264
@@ -1423,7 +1423,7 @@ is used as the location in the array. The index starts at 0;
14231423 hostname() eq hostname(0);
14241424 hostname(1); #second hostname found
14251425 hostname(400) eq hostname(1) #nothing at 400; return the name at the last index
1426-
1426+
14271427
14281428=item B<ipv4_addr() >
14291429
@@ -1529,7 +1529,7 @@ a string argument can be given to these functions to filter the list.
15291529
15301530 $host->tcp_ports('open') #returns all only 'open' ports (even 'open|filtered')
15311531 $host->udp_ports('open|filtered'); #matches exactly ports with 'open|filtered'
1532-
1532+
15331533I<Note that if a port state is set to 'open|filtered' (or any combination), it will
15341534be counted as an 'open' port as well as a 'filtered' one.>
15351535
@@ -1560,33 +1560,33 @@ Returns the state of the given port, provided by the port number in $portid.
15601560=item B<udp_open_ports() >
15611561
15621562Returns the list of open TCP|UDP ports respectively. Note that if a port state is
1563- for example, 'open|filtered', it will appear on this list as well.
1563+ for example, 'open|filtered', it will appear on this list as well.
15641564
15651565=item B<tcp_filtered_ports() >
15661566
15671567=item B<udp_filtered_ports() >
15681568
15691569Returns the list of filtered TCP|UDP ports respectively. Note that if a port state is
1570- for example, 'open|filtered', it will appear on this list as well.
1570+ for example, 'open|filtered', it will appear on this list as well.
15711571
15721572=item B<tcp_closed_ports() >
15731573
15741574=item B<udp_closed_ports() >
15751575
15761576Returns the list of closed TCP|UDP ports respectively. Note that if a port state is
1577- for example, 'closed|filtered', it will appear on this list as well.
1577+ for example, 'closed|filtered', it will appear on this list as well.
15781578
15791579=item B<tcp_service($portid) >
15801580
15811581=item B<udp_service($portid) >
15821582
15831583Returns the Nmap::Parser::Host::Service object of a given service running on port,
1584- provided by $portid. See Nmap::Parser::Host::Service for more info.
1584+ provided by $portid. See Nmap::Parser::Host::Service for more info.
15851585
15861586 $svc = $host->tcp_service(80);
15871587 $svc->name;
15881588 $svc->proto;
1589-
1589+
15901590
15911591=back
15921592
@@ -1644,7 +1644,7 @@ Returns the tunnel value. (If available)
16441644=item B<fingerprint() >
16451645
16461646Returns the service fingerprint. (If available)
1647-
1647+
16481648=item B<version() >
16491649
16501650Returns the version of the given product of the running service.
@@ -1794,8 +1794,8 @@ The host name of this hop, if known.
17941794
17951795I think some of us best learn from examples. These are a couple of examples to help
17961796create custom security audit tools using some of the nice features
1797- of the Nmap::Parser module. Hopefully this can double as a tutorial.
1798- More tutorials (articles) can be found at L<http ://apersaud. github.io/ Nmap-Parser/ >
1797+ of the Nmap::Parser module. Hopefully this can double as a tutorial.
1798+ More tutorials (articles) can be found at L<https ://github.com/modernistik/ Nmap-Parser>
17991799
18001800=head2 Real-Time Scanning
18011801
@@ -1823,7 +1823,7 @@ you can use cache_scan(). You must call cache_scan() BEFORE you initiate the par
18231823 my $np = new Nmap::Parser;
18241824
18251825 #telling np to save output
1826- $np->cache_scan('nmap.localhost.xml');
1826+ $np->cache_scan('nmap.localhost.xml');
18271827 $np->parsescan('/usr/bin/nmap','-F','localhost');
18281828 #do other stuff...
18291829
@@ -1841,9 +1841,9 @@ setup before parsing>
18411841 use Nmap::Parser;
18421842 my $np = new Nmap::Parser;
18431843
1844-
1844+
18451845 $np->callback( \&booyah );
1846-
1846+
18471847 $np->parsefile('nmap_results.xml');
18481848 # or use parsescan()
18491849
@@ -1855,7 +1855,7 @@ setup before parsing>
18551855 #when it returns, host object will be deleted from memory
18561856 #(good for processing VERY LARGE files or scans)
18571857 }
1858-
1858+
18591859
18601860=head2 Multiple Instances - (C<no less 'of'; my $self > )
18611861
@@ -1872,43 +1872,43 @@ same hosts, and compare if any new tcp have been open since then
18721872 use vars qw($nmap_exe $nmap_args @ips);
18731873 my $base = new Nmap::Parser;
18741874 my $curr = new Nmap::Parser;
1875-
1876-
1875+
1876+
18771877 $base->parsefile('base_image.xml'); #load previous state
18781878 $curr->parsescan($nmap_exe, $nmap_args, @ips); #scan current hosts
1879-
1880- for my $ip ($curr->get_ips )
1879+
1880+ for my $ip ($curr->get_ips )
18811881 {
18821882 #assume that IPs in base == IPs in curr scan
18831883 my $ip_base = $base->get_host($ip);
18841884 my $ip_curr = $curr->get_host($ip);
18851885 my %port = ();
1886-
1886+
18871887 #find ports that are open that were not open before
18881888 #by finding the difference in port lists
1889- my @diff = grep { $port{$_} < 2}
1890- (map {$port{$_}++; $_}
1889+ my @diff = grep { $port{$_} < 2}
1890+ (map {$port{$_}++; $_}
18911891 ( $ip_curr->tcp_open_ports , $ip_base->tcp_open_ports ));
1892-
1892+
18931893 print "$ip has these new ports open: ".join(',',@diff) if(scalar @diff);
1894-
1894+
18951895 for (@diff){print "$_ seems to be ",$ip_curr->tcp_service($_)->name,"\n";}
1896-
1896+
18971897 }
1898-
1898+
18991899
19001900=head1 SUPPORT
19011901
19021902=head2 Discussion Forum
19031903
19041904If you have questions about how to use the module, or any of its features, you
19051905can post messages to the Nmap::Parser module forum on CPAN::Forum.
1906- L<https://github.com/apersaud /Nmap-Parser/issues>
1906+ L<https://github.com/modernistik /Nmap-Parser/issues>
19071907
19081908=head2 Bug Reports, Enhancements, Merge Requests
19091909
19101910Please submit any bugs or feature requests to:
1911- L<https://github.com/apersaud /Nmap-Parser/issues>
1911+ L<https://github.com/modernistik /Nmap-Parser/issues>
19121912
19131913B<Please make sure that you submit the xml-output file of the scan which you are having
19141914trouble with.> This can be done by running your scan with the I<-oX filename.xml > nmap switch.
@@ -1918,17 +1918,17 @@ Please remove any important IP addresses for security reasons. It saves time in
19181918
19191919 nmap, XML::Twig
19201920
1921- The Nmap::Parser page can be found at: L<http ://apersaud. github.io/ Nmap-Parser/ > .
1921+ The Nmap::Parser page can be found at: L<https ://github.com/modernistik/ Nmap-Parser> .
19221922It contains the latest developments on the module. The nmap security scanner
19231923homepage can be found at: L<http://www.insecure.org/nmap/> .
19241924
19251925=head1 AUTHORS
19261926
1927- Origiinal author, Anthony Persaud L<http ://modernistik.com> . However, special thanks to: Daniel Miller L<https://github.com/bonsaiviking> and Robin Bowes L<http://robinbowes.com> .
1927+ Origiinal author, Anthony Persaud L<https ://www. modernistik.com> . However, special thanks to: Daniel Miller L<https://github.com/bonsaiviking> and Robin Bowes L<http://robinbowes.com> .
19281928Please see Changes file and CONTRIBUTORS file for a list of other great contributors.
19291929
19301930=head1 COPYRIGHT
1931- Copyright (c) <2003-2013 > <Anthony Persaud> L<http ://modernistik.com>
1931+ Copyright (c) <2003-2017 > <Anthony Persaud> L<https ://www. modernistik.com>
19321932
19331933MIT License
19341934
0 commit comments