ResultScraping

From timswiki
Revision as of 18:39, 21 April 2012 by Wikiadmin (talk | contribs) (Created page with "==Results Scraping== Here is a simple Perl script (scrape.pl) which dumps out the open ports: #!/usr/bin/perl use strict; use warnings; use HTML::TableExtract; ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Results Scraping

Here is a simple Perl script (scrape.pl) which dumps out the open ports:


 #!/usr/bin/perl
 use strict;
 use warnings;
 use HTML::TableExtract;
 
 my $scan = "";
 
 {
       local $/=undef;
       open FILE, "ipv6.html" or die "Couldn't open ipv6 file: $!";
       $scan = <FILE>;
       close FILE;
 }
 my $te = new HTML::TableExtract();
 $te->parse($scan);
 
 # my $pingtable = $te->table(0,0);
 my $porttable = $te->table(0,1);
 
 # Currently prints out the OPEN ports
 foreach my $row ($porttable->rows)
 {
       foreach my $ele ( @$row )
       {
               # Port 7 = RFSD
               if (defined $ele)
               {
                       if ($ele =~ m/Port\s+(\d+)\s+=\s+([A-Z]+)/)
                       {
                               my $port = $1;
                               my $state = $2;
                               if ($state =~ m/OPEN/)
                               {
                                        printf("PORT %5d was %s\n",$port,$state);
                               }
                       }
               }
       }
 }
 

Typical Scraped results

 $ ./scrape.pl
 PORT    22 was OPEN
 PORT    25 was OPEN
 PORT    80 was OPEN
 PORT   443 was OPEN
 $ 




<adsense>1</adsense>