Changeset 622


Ignore:
Timestamp:
02/11/2011 06:36:22 PM (2 years ago)
Author:
sullo
Message:

More fixes for nmap grepable output!

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/nikto.pl

    r616 r622  
    22use strict; 
    33 
    4 #VERSION,2.1.3 
     4#VERSION,2.1.4 
    55# $Id$ 
    66use Getopt::Long; 
     
    4848$VARIABLES{'DIV'}         = "-" x 75; 
    4949$VARIABLES{'name'}        = "Nikto"; 
    50 $VARIABLES{'version'}     = "2.1.3"; 
     50$VARIABLES{'version'}     = "2.1.4"; 
    5151$VARIABLES{'configfile'}  = "/etc/nikto.conf";    ### Change if it's having trouble finding it 
    5252 
  • trunk/plugins/nikto_core.plugin

    r621 r622  
    10121012    my ($file) = @_; 
    10131013    my (@results, $hostdesc); 
    1014     my $nmap = 0; 
    1015  
     1014    my ($nmap, $lineno) = 0; 
     1015    
    10161016    open(IN, $file) || die print STDERR "+ ERROR: Cannot open '$file':$@\n"; 
    10171017    while (<IN>) { 
    10181018        my $found = 0; 
     1019        $lineno++; 
    10191020 
    10201021        # Check whether this is a greppable nmap file 
    10211022        chomp; 
     1023        #nprint("\nParsing line $lineno: $_", "d"); 
    10221024        $nmap = 1 if (/^# Nmap/); 
    10231025        s/\#.*$//; 
     
    10281030            if (($_ !~ /Host/) || ($_ !~ /Ports/) || ($_ !~ /open/) || ($_ !~ /(?:http|ssl)/i)) { next; } 
    10291031 
     1032            # parse out the line 
     1033            my @fields = split("\t", $_); 
     1034 
    10301035            # Get the host name 
    1031             my @line = split(/ /); 
    1032             $_ =~ /\(([^\)]+)/; 
    1033             $hostdesc = ($1 ne "") ? $1 : $line[1]; 
     1036            $fields[0] =~ /Host:\s+([\d\.]+)\s+\(([^\)]+)?\)/; 
     1037            $hostdesc = ($2 ne "") ? $2 : $1; 
    10341038 
    10351039            # Parse the ports list from: 
    10361040            # Host: 1.0.0.0 ()  Ports: 80/open/tcp//http///, 8000/open/tcp//http-alt/// 
    1037             for (my $i = 3 ; $i <= $#line ; $i++) { 
    1038                 if (($line[$i] !~ /open\/tcp/) || ($line[$i] !~ /http/)) { next; } 
    1039                     $line[$i] =~ /^(\d+)\//; 
     1041            $fields[1]=~s/^Ports: //; 
     1042            my @ports = parse_csv($fields[1]); 
     1043            foreach my $nmp (@ports) {  
     1044                if (($nmp !~ /(?:80|443)?\/open\/tcp/) || ($nmp !~ /(?:http|ssl)/i)) {  
     1045                        nprint("\tNon web port identified on line $lineno: $hostdesc port: $nmp","d"); 
     1046                        next; 
     1047                        } 
     1048                    $nmp =~ /^(?:\s+)?(\d+)\//; 
     1049                    nprint("\tWeb port identified on line $lineno: $hostdesc port $1 ","d"); 
    10401050                    push(@results, $hostdesc . ":" . $1); 
    1041                 } 
     1051                } 
    10421052            } 
    10431053        else { 
Note: See TracChangeset for help on using the changeset viewer.