Changeset 457


Ignore:
Timestamp:
06/19/2010 03:27:39 AM (3 years ago)
Author:
sullo
Message:

tidying up... a few other minor changes.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/nikto.conf

    r442 r457  
    1717# RFI URL. This remote file should return a phpinfo call, for example: <?php phpinfo(); ?> 
    1818# You may use the one below, if you like. 
    19 #RFIURL=http://cirt.net/rfiinc.txt? 
     19RFIURL=http://cirt.net/rfiinc.txt? 
    2020 
    2121# IDs never to alert on (Note: this only works for IDs loaded from db_tests) 
  • trunk/nikto.pl

    r452 r457  
    55use Getopt::Long; 
    66Getopt::Long::Configure('no_ignore_case'); 
     7 
    78# use LW2;                   ### Change this line to use a different installed version 
    89 
     
    9091require "$NIKTOCONFIG{'PLUGINDIR'}/nikto_single.plugin"; 
    9192require "$NIKTOCONFIG{'PLUGINDIR'}/LW2.pm"; 
    92  
    9393 
    9494my ($a, $b) = split(/\./, $LW2::VERSION); 
     
    148148# Open reporting 
    149149report_head($CLI{'format'}, $CLI{'file'}); 
     150 
    150151# Load db_tests 
    151152set_scan_items(); 
     
    175176    %FoF = (); 
    176177 
    177     nfetch($mark, "/", "GET", "", "", { nocache => 1, noprefetch => 1, nopostfetch => 1 }, "getinfo"); 
    178          
     178    nfetch($mark, "/", "GET", "", "", { nocache => 1, noprefetch => 1, nopostfetch => 1 }, 
     179           "getinfo"); 
     180 
    179181    if ($CLI{'findonly'}) { 
    180182        my $protocol = "http"; 
  • trunk/plugins/nikto_apacheusers.plugin

    r449 r457  
    3030            scan_method => \&nikto_apacheusers, 
    3131            copyright   => "2008 CIRT Inc.", 
    32             options     =>  { 
    33                                 enumerate   => "Flag to indicate whether to attempt to enumerate users", 
    34                                 dictionary => "Filename for a dictionary file of users", 
    35                                 size        => "Maximum size of username if bruteforcing", 
    36                                 home        => "Look for ~user to enumerate", 
    37                                 cgiwrap     => "User cgi-bin/cgiwrap to enumerate" 
    38                             } 
    39             }; 
     32            options     => { 
     33                         enumerate  => "Flag to indicate whether to attempt to enumerate users", 
     34                         dictionary => "Filename for a dictionary file of users", 
     35                         size       => "Maximum size of username if bruteforcing", 
     36                         home       => "Look for ~user to enumerate", 
     37                         cgiwrap    => "User cgi-bin/cgiwrap to enumerate" 
     38                         } 
     39              }; 
    4040    return $id; 
    4141} 
     
    4343sub nikto_apacheusers { 
    4444    my ($mark, $parameters) = @_; 
    45     my $apacheusers=0; 
    46      
     45    my $apacheusers = 0; 
     46 
    4747    # First ensure that the server is vulnerable 
    4848    (my $result, $content) = nfetch($mark, "/~root", "GET", "", "", "", "apacheusers: known user"); 
     
    6666                ); 
    6767        } 
    68         $apacheusers=1; 
    69     } 
    70      
     68        $apacheusers = 1; 
     69    } 
     70 
    7171    # If we can't enumerate users then return 
    7272    return unless ($apacheusers == 1); 
     73 
    7374    # If we haven't been asked to enumerate users then return 
    74     return unless (defined $parameters->{'enumerate'} && 
    75                    $parameters->{'enumerate'} == 1); 
    76      
     75    return unless (defined $parameters->{'enumerate'} 
     76                   && $parameters->{'enumerate'} == 1); 
     77 
    7778    # Now we can attempt to enumerate the users 
    7879    my ($url, $dictfile, $size); 
     
    9495            my $curl = "$cgidir" . "cgiwrap"; 
    9596            (my $result, $content) = 
    96                 nfetch($mark, $curl, "GET", "", "", "", "user_enum_apache: cgiwrap"); 
     97              nfetch($mark, $curl, "GET", "", "", "", "user_enum_apache: cgiwrap"); 
    9798            if ($content =~ /check your URL/i) { 
    9899                push(@cgiwraps, "$curl"); 
  • trunk/plugins/nikto_auth.plugin

    r452 r457  
    4242 
    4343sub nikto_auth_load { 
     44 
    4445    # Load up the database as soon as we can 
    45      
    46     $REALMS=init_db("db_realms"); 
     46 
     47    $REALMS        = init_db("db_realms"); 
    4748    %REALMSMATCHED = (); 
    4849} 
     
    5051sub nikto_auth_pre { 
    5152    my ($mark, $parameters, $request, $result) = @_; 
     53 
    5254    # If we know the realm then don't bother guessing it 
    5355    # See whether we've already guessed it 
    54      
     56 
    5557    my ($uridir) = $request->{'whisker'}->{'uri'}; 
    5658    $uridir =~ s#/[^/]*$#/#g; 
    5759 
    58     if (exists $REALMSMATCHED{$mark->{'hostname'}}{$uridir}) { 
     60    if (exists $REALMSMATCHED{ $mark->{'hostname'} }{$uridir}) { 
     61 
    5962        # Just set up the auth and return the valid result 
    60         LW2::auth_set($REALMSMATCHED{$mark->{'hostname'}}{$uridir}{'authtype'}, $request, $REALMSMATCHED{$mark->{'hostname'}}{$uridir}{'id'}, $REALMSMATCHED{$mark->{'hostname'}}{$uridir}{'password'}); 
     63        LW2::auth_set($REALMSMATCHED{ $mark->{'hostname'} }{$uridir}{'authtype'}, 
     64                      $request, 
     65                      $REALMSMATCHED{ $mark->{'hostname'} }{$uridir}{'id'}, 
     66                      $REALMSMATCHED{ $mark->{'hostname'} }{$uridir}{'password'} 
     67                      ); 
     68 
    6169        # Patch to fix short reads 
    6270        $request->{'whisker'}->{'allow_short_reads'} = 1; 
     
    6876sub nikto_auth { 
    6977    my ($mark, $parameters, $request, $result) = @_; 
    70     my ($authtype)  = 'basic'; 
    71     my ($body)      = $result->{'whisker'}->{'data'}; 
    72     my ($uri)       = $result->{'whisker'}->{'uri'}; 
    73     my ($method)    = $result->{'whisker'}->{'method'} || "GET"; 
     78    my ($authtype) = 'basic'; 
     79    my ($body)     = $result->{'whisker'}->{'data'}; 
     80    my ($uri)      = $result->{'whisker'}->{'uri'}; 
     81    my ($method)   = $result->{'whisker'}->{'method'} || "GET"; 
    7482    my ($realm, $save_auth); 
    7583 
     
    7886        return $request, $result; 
    7987    } 
    80      
     88 
    8189    # Save to revert 
    8290    $save_auth = $result{'www-authenticate'}; 
    83      
     91 
    8492    # Split up www-authenticate to realm and method 
    8593    my @authenticate = split(/ /, $result->{'www-authenticate'}); 
     
    94102        $authtype = $authenticate[0]; 
    95103        $realm    = $authenticate[1]; 
    96         $realm    =~ s/^realm=//; 
     104        $realm =~ s/^realm=//; 
    97105    } 
    98      
     106 
    99107    nprint("+ $uri - Requires Authentication for realm '$realm'") if $OUTPUT{'show_auth'}; 
    100108 
     
    102110    foreach my $entry (@{$REALMS}) { 
    103111        unless ($realm =~ /$entry->{'realm'}/i || $entry->{realm} eq '@ANY') { next; } 
    104          
     112 
    105113        if ($result->{'www-authenticate'} =~ /^ntlm/i) { 
    106             $authtype='ntlm'; 
    107         }        
     114            $authtype = 'ntlm'; 
     115        } 
     116 
    108117        # Set up LW hash 
    109118        LW2::auth_set($authtype, $request, $entry->{'id'}, $entry->{'password'}); 
     119 
    110120        # Patch to fix short reads 
    111                 $request->{'whisker'}->{'allow_short_reads'} = 1; 
    112         LW2::http_fixup_request($request);      
     121        $request->{'whisker'}->{'allow_short_reads'} = 1; 
     122        LW2::http_fixup_request($request); 
     123 
    113124        # pause if needed 
    114125        if ($CLI{'pause'} > 0) { sleep $CLI{'pause'}; } 
     
    118129        dump_var("Auth Request",  $request); 
    119130        dump_var("Auth Response", $result); 
    120          
     131 
    121132        if ($result{'www-authenticate'} =~ /^ntlm/i) { 
     133 
    122134            # Deal with ntlm 
    123135            my @ntlm_x = split(/ /, $result{'www-authenticate'}); 
     
    129141        my $uridir = $request->{'whisker'}->{'uri'}; 
    130142        $uridir =~ s#/[^/]*$#/#g; 
    131         
     143 
    132144        if ($result->{'www-authenticate'} eq '' 
    133145            && !defined $result->{'whisker'}->{'error'}) { 
    134              
    135             my $message="Default account found for '$realm' at $uridir ($request->{'whisker'}->{'uri'}) (ID '$entry->{'id'}', PW '$entry->{'password'}'). $entry->{message}"; 
     146 
     147            my $message = 
     148              "Default account found for '$realm' at $uridir ($request->{'whisker'}->{'uri'}) (ID '$entry->{'id'}', PW '$entry->{'password'}'). $entry->{message}"; 
    136149            if ($entry->{'id'} eq '' && $entry->{'password'} eq '') { 
    137                 $message="Blank credentials found at $uridir ($request{whisker}->{uri}), $entry->{'realm'}: $entry->{'msg'}" 
     150                $message = 
     151                  "Blank credentials found at $uridir ($request{whisker}->{uri}), $entry->{'realm'}: $entry->{'msg'}"; 
    138152            } 
    139             unless ( $entry->{'checked'} == 1) { 
    140                 add_vulnerability( 
    141                     $mark, 
    142                     $message, 
    143                     $entry->{tid}, 
    144                     0, 
    145                     "GET", 
    146                     $uridir, 
    147                     $result 
    148                     ); 
     153            unless ($entry->{'checked'} == 1) { 
     154                add_vulnerability($mark, $message, $entry->{tid}, 0, "GET", $uridir, $result); 
    149155                $entry->{checked} = 1; 
    150156            } 
     
    153159            LW2::http_do_request_timeout($request, $result);    # test auth 
    154160            $NIKTO{'totalrequests'}++; 
    155              
     161 
    156162            # Set up so we don't have to repeat in future 
    157163            # / isn't a valid entry in a hash  - more stupid perl 
    158164 
    159             $REALMSMATCHED{$mark->{hostname}}{$uridir}{'id'}=$entry->{'id'}; 
    160             $REALMSMATCHED{$mark->{hostname}}{$uridir}{'password'}=$entry->{'password'}; 
    161             $REALMSMATCHED{$mark->{hostname}}{$uridir}{'authtype'}=$authtype; 
     165            $REALMSMATCHED{ $mark->{hostname} }{$uridir}{'id'}       = $entry->{'id'}; 
     166            $REALMSMATCHED{ $mark->{hostname} }{$uridir}{'password'} = $entry->{'password'}; 
     167            $REALMSMATCHED{ $mark->{hostname} }{$uridir}{'authtype'} = $authtype; 
    162168 
    163169            # and leave 
  • trunk/plugins/nikto_content_search.plugin

    r436 r457  
    2424 
    2525sub nikto_content_search_init { 
    26     my $id = { name         => "content_search", 
    27                full_name    => "Content Search", 
    28                author       => "Sullo", 
    29                description  => "Search resultant content for interesting strings", 
    30                recon_method => \&nikto_content_search_load, 
    31                recon_weight => 1, 
     26    my $id = { name             => "content_search", 
     27               full_name        => "Content Search", 
     28               author           => "Sullo", 
     29               description      => "Search resultant content for interesting strings", 
     30               recon_method     => \&nikto_content_search_load, 
     31               recon_weight     => 1, 
    3232               postfetch_method => \&nikto_content_search, 
    3333               postfetch_weight => 20, 
    34                copyright    => "2010 CIRT Inc" 
     34               copyright        => "2010 CIRT Inc" 
    3535               }; 
    3636 
     
    3939 
    4040sub nikto_content_search_load { 
     41 
    4142    # Load up the database as soon as we can 
    42      
    43     $CONTENTSEARCH=init_db("db_content_search"); 
    44     %CSMATCHED = (); 
     43 
     44    $CONTENTSEARCH = init_db("db_content_search"); 
     45    %CSMATCHED     = (); 
    4546 
    4647    # to try and speed it up - precompile the regular expressions 
     
    5253sub nikto_content_search { 
    5354    my ($mark, $parameters, $request, $result) = @_; 
    54      
     55 
    5556    my $body   = $result->{'whisker'}->{'data'}; 
    5657    my $file   = $result->{'whisker'}->{'uri'}; 
     
    5859 
    5960    foreach my $testid (@$CONTENTSEARCH) { 
    60         if ($body =~ $testid->{'compiled'} && 
    61             !exists $CSMATCHED{$mark->{'hostname'}}{$file}) { 
     61        if ($body =~ $testid->{'compiled'} 
     62            && !exists $CSMATCHED{ $mark->{'hostname'} }{$file}) { 
     63 
    6264            # Check whether we've already matched it 
    6365            my $outmessage = "$file: $testid->{'message'}"; 
    64             add_vulnerability($mark, $outmessage, 
    65                               $testid->{'nikto_id'}, 
    66                               $testid->{'osvdb'}, 
     66            add_vulnerability($mark, $outmessage, $testid->{'nikto_id'}, $testid->{'osvdb'}, 
    6767                              $method, $file); 
    68             $CSMATCHED{$mark->{'hostname'}}{$file} = 1; 
     68            $CSMATCHED{ $mark->{'hostname'} }{$file} = 1; 
    6969        } 
    7070    } 
  • trunk/plugins/nikto_core.plugin

    r456 r457  
    130130    if ((defined $CLI{'file'}) && ($CLI{'file'} eq "-")) { return; } 
    131131 
    132     # print to scan details to standard output if the users wants another format and is saving results to a file 
     132# print to scan details to standard output if the users wants another format and is saving results to a file 
    133133    $line =~ s/(CVE\-[12][0-9]{4}-[0-9]{4})/http:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name\=$1/g; 
    134134    $line =~ s/(CA\-[12][0-9]{3}-[0-9]{2})/http:\/\/www.cert.org\/advisories\/$1.html/g; 
    135135    $line =~ s/BID\-([0-9]{4})/http:\/\/www.securityfocus.com\/bid\/$1/g; 
    136     $line =~ s/(MS[0-9]{2}\-[0-9]{3})/http:\/\/www.microsoft.com\/technet\/security\/bulletin\/$1.asp/gi; 
     136    $line =~ 
     137      s/(MS[0-9]{2}\-[0-9]{3})/http:\/\/www.microsoft.com\/technet\/security\/bulletin\/$1.asp/gi; 
    137138    print "$line\n"; 
    138139 
     
    287288    $cont =~ s/(?:[0-9]{4}|[0-9]{1,2})[-.\/][0-9]{1,2}[-.\/](?:[0-9]{4}|[0-9]{1,2})//g; 
    288289    $cont =~ s/(?:([0-9]{2}:[0-9]{2}(?::[0-9]{2})?)|(?:[0-9]{8,14}|[0-9]{6}))//g; 
    289     $cont =~ s/(?:mon|tue|wed|thu|fri|sat|sun),? [0-9]{1,2} (?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) [0-9]{4} (?:[0-9]{2}:[0-9]{2}:?(?:[0-9]{2})?)?//ig; 
    290     $cont =~ s/(?:[0-9]{2,4})? ?(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)(?:[0-9]{2,4})?\/?(?:[0-9]{2})?(?:[0-9]{2})?//gi; 
     290    $cont =~ 
     291      s/(?:mon|tue|wed|thu|fri|sat|sun),? [0-9]{1,2} (?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) [0-9]{4} (?:[0-9]{2}:[0-9]{2}:?(?:[0-9]{2})?)?//ig; 
     292    $cont =~ 
     293      s/(?:[0-9]{2,4})? ?(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)(?:[0-9]{2,4})?\/?(?:[0-9]{2})?(?:[0-9]{2})?//gi; 
    291294    $cont =~ s/[0-9\.]+ second//gi;    # page load time 
    292295    $cont =~ s/[0-9]+ queries//gi;     # wordpress 
     
    317320        # url encoding, query portion 
    318321        if ($file =~ /\?(.*$)/) { 
    319             my $qs = $1; 
    320  
    321             # match pages which link to themselves w/diff args 
    322             $cont =~ s/$qs//gs; 
     322            my $qs = $1; 
     323 
     324            # match pages which link to themselves w/diff args 
     325            $cont =~ s/$qs//gs; 
    323326 
    324327            # url encoded 
    325             $qs =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; 
     328            $qs   =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; 
    326329            $cont =~ s/$qs//gs; 
    327330        } 
     
    339342        $sslprint = "$NIKTO{'DIV'}\n"; 
    340343        $sslprint .= 
    341             "+ SSL Info:        Ciphers: $mark->{'ssl_cipher'}\n" . 
    342             "                   Info:    $mark->{'ssl_cert_issuer'}\n" .  
    343             "                   Subject: $mark->{'ssl_cert_subject'}"; 
     344            "+ SSL Info:        Ciphers: $mark->{'ssl_cipher'}\n" 
     345          . "                   Info:    $mark->{'ssl_cert_issuer'}\n" 
     346          . "                   Subject: $mark->{'ssl_cert_subject'}"; 
    344347    } 
    345348 
     
    424427    $NIKTO{'mutate_opts'}{'5'} = 
    425428      "Attempt to brute force sub-domain names, assume that the host name is the parent domain"; 
    426     $NIKTO{'mutate_opts'}{'6'} = "Attempt to guess directory names from the supplied dictionary file"; 
     429    $NIKTO{'mutate_opts'}{'6'} = 
     430      "Attempt to guess directory names from the supplied dictionary file"; 
    427431 
    428432    ### CLI STUFF 
     
    505509    # screen output 
    506510    if (defined $CLI{'display'}) { 
    507         if ($CLI{'display'} =~ /d/i) { $OUTPUT{'debug'}   = 1; } 
    508         if ($CLI{'display'} =~ /v/i) { $OUTPUT{'verbose'} = 1; } 
    509         if ($CLI{'display'} =~ /s/i) { $OUTPUT{'scrub'}   = 1; } 
    510         if ($CLI{'display'} =~ /e/i) { $OUTPUT{'errors'}  = 1; } 
    511         if ($CLI{'display'} =~ /p/i) { $OUTPUT{'progress'} = 1; } 
     511        if ($CLI{'display'} =~ /d/i) { $OUTPUT{'debug'}          = 1; } 
     512        if ($CLI{'display'} =~ /v/i) { $OUTPUT{'verbose'}        = 1; } 
     513        if ($CLI{'display'} =~ /s/i) { $OUTPUT{'scrub'}          = 1; } 
     514        if ($CLI{'display'} =~ /e/i) { $OUTPUT{'errors'}         = 1; } 
     515        if ($CLI{'display'} =~ /p/i) { $OUTPUT{'progress'}       = 1; } 
    512516        if ($CLI{'display'} =~ /1/i) { $OUTPUT{'show_redirects'} = 1; } 
    513         if ($CLI{'display'} =~ /2/i) { $OUTPUT{'show_cookies'} = 1; } 
    514         if ($CLI{'display'} =~ /3/i) { $OUTPUT{'show_ok'} = 1; } 
    515         if ($CLI{'display'} =~ /4/i) { $OUTPUT{'show_auth'} = 1; } 
    516         } 
     517        if ($CLI{'display'} =~ /2/i) { $OUTPUT{'show_cookies'}   = 1; } 
     518        if ($CLI{'display'} =~ /3/i) { $OUTPUT{'show_ok'}        = 1; } 
     519        if ($CLI{'display'} =~ /4/i) { $OUTPUT{'show_auth'}      = 1; } 
     520    } 
    517521 
    518522    # port(s) 
     
    622626 
    623627    # POSIX support for status? 
    624     $NIKTO{'POSIX'}{'support'}=0; 
     628    $NIKTO{'POSIX'}{'support'} = 0; 
    625629    eval "use POSIX qw(:termios_h)"; 
    626     if ( !$@ ) { 
    627         eval "use Time::HiRes qw(ualarm)"; 
    628         if ( !$@ ) { 
    629                 $NIKTO{'POSIX'}{'support'}=1;  
    630                 $NIKTO{'POSIX'}{'echo'} = ECHO | ECHOK | ICANON; 
    631                 $NIKTO{'POSIX'}{'noecho'} = $oterm & ~$echo; 
    632                 $NIKTO{'POSIX'}{'fd_stdin'} = fileno(STDIN); 
    633                 $NIKTO{'POSIX'}{'term'} = POSIX::Termios->new(); 
    634                 $NIKTO{'POSIX'}{'term'}->getattr($fd_stdin); 
    635                 $NIKTO{'POSIX'}{'oterm'} = $NIKTO{'POSIX'}{'term'}->getlflag(); 
    636                 } 
    637         } 
     630    if (!$@) { 
     631        eval "use Time::HiRes qw(ualarm)"; 
     632        if (!$@) { 
     633            $NIKTO{'POSIX'}{'support'}  = 1; 
     634            $NIKTO{'POSIX'}{'fd_stdin'} = fileno(STDIN); 
     635            $NIKTO{'POSIX'}{'term'}     = POSIX::Termios->new(); 
     636            $NIKTO{'POSIX'}{'term'}->getattr($fd_stdin); 
     637            $NIKTO{'POSIX'}{'oterm'}  = $NIKTO{'POSIX'}{'term'}->getlflag(); 
     638            $NIKTO{'POSIX'}{'echo'}   = ECHOE | ECHO | ECHOK | ICANON; 
     639            $NIKTO{'POSIX'}{'noecho'} = $oterm & ~$echo; 
     640        } 
     641    } 
    638642    return; 
    639643} 
     
    641645############################################################################### 
    642646sub reset_term { 
    643         $NIKTO{'POSIX'}{'term'}->setlflag($NIKTO{'POSIX'}{'oterm'}); 
    644         $NIKTO{'POSIX'}{'support'}=0;  
    645         } 
     647    $NIKTO{'POSIX'}{'term'}->setlflag($NIKTO{'POSIX'}{'oterm'}); 
     648    $NIKTO{'POSIX'}{'support'} = 0; 
     649} 
    646650 
    647651############################################################################### 
    648652sub safe_quit { 
    649         $mark->{'end_time'} = time(); 
    650         report_host_end($mark); 
    651         report_close($mark); 
    652         reset_term(); 
    653         exit(1); 
    654         } 
     653    $mark->{'end_time'} = time(); 
     654    report_host_end($mark); 
     655    report_close($mark); 
     656    reset_term(); 
     657    exit(1); 
     658} 
    655659 
    656660############################################################################### 
    657661sub check_input { 
    658         my $key = readkey(); 
    659         if ($key eq '') { return; } 
    660  
    661         lc($key); 
    662         if ($key eq ' ') {  
    663         my $line = sprintf("- Completed: %d tests, approximately %.0f%% complete", $NIKTO{'totalrequests'}, ($NIKTO{'totalrequests'} / $NIKTO{'total_checks'}) * 100); 
    664         if ($NIKTO{'current_plugin'} ne '') { $line .= " (in plugin $NIKTO{'current_plugin'})"; } 
     662    my $key = readkey(); 
     663    if ($key eq '') { return; } 
     664 
     665    lc($key); 
     666    if ($key eq ' ') { 
     667        my $line = sprintf("- Completed: %d tests, approximately %.0f%% complete", 
     668                           $NIKTO{'totalrequests'}, 
     669                           ($NIKTO{'totalrequests'} / $NIKTO{'total_checks'}) * 100); 
     670        if ($NIKTO{'current_plugin'} ne '') { $line .= " (in plugin $NIKTO{'current_plugin'})"; } 
    665671        nprint($line); 
    666         return; 
    667     } 
    668         elsif ($key eq 'v') {  
    669                 if ($OUTPUT{'verbose'}) { $OUTPUT{'verbose'}=0; } 
    670                 else { $OUTPUT{'verbose'}=1; } 
    671         } 
    672         elsif ($key eq 'd') {  
    673                 if ($OUTPUT{'debug'}) { $OUTPUT{'debug'}=0; } 
    674                 else { $OUTPUT{'debug'}=1; } 
    675         } 
    676         elsif ($key eq 'e') {  
    677                 if ($OUTPUT{'errors'}) { $OUTPUT{'errors'}=0; } 
    678                 else { $OUTPUT{'errors'}=1; } 
    679         } 
    680         elsif ($key eq 'p') {  
    681                 if ($OUTPUT{'progress'}) { $OUTPUT{'progress'}=0; } 
    682                 else { $OUTPUT{'progress'}=1; } 
    683         } 
    684         elsif ($key eq 'r') {  
    685                 if ($OUTPUT{'show_redirects'}) { $OUTPUT{'show_redirects'}=0; } 
    686                 else { $OUTPUT{'show_redirects'}=1; } 
    687         } 
    688         elsif ($key eq 'c') {  
    689                 if ($OUTPUT{'show_cookies'}) { $OUTPUT{'show_cookies'}=0; } 
    690                 else { $OUTPUT{'show_cookies'}=1; } 
    691         } 
    692         elsif ($key eq 'o') {  
    693                 if ($OUTPUT{'show_ok'}) { $OUTPUT{'show_ok'}=0; } 
    694                 else { $OUTPUT{'show_ok'}=1; } 
    695         } 
    696         elsif ($key eq 'a') {  
    697                 if ($OUTPUT{'show_auth'}) { $OUTPUT{'show_auth'}=0; } 
    698                 else { $OUTPUT{'show_auth'}=1; } 
    699         } 
    700        elsif (($key eq 'q') || (ord($key) eq 3)){  
    701                 safe_quit(); 
    702         } 
    703         return; 
     672        return; 
     673    } 
     674    elsif ($key eq 'v') { 
     675        if   ($OUTPUT{'verbose'}) { $OUTPUT{'verbose'} = 0; } 
     676        else                      { $OUTPUT{'verbose'} = 1; } 
     677    } 
     678    elsif ($key eq 'd') { 
     679        if   ($OUTPUT{'debug'}) { $OUTPUT{'debug'} = 0; } 
     680        else                    { $OUTPUT{'debug'} = 1; } 
     681    } 
     682    elsif ($key eq 'e') { 
     683        if   ($OUTPUT{'errors'}) { $OUTPUT{'errors'} = 0; } 
     684        else                     { $OUTPUT{'errors'} = 1; } 
     685    } 
     686    elsif ($key eq 'p') { 
     687        if   ($OUTPUT{'progress'}) { $OUTPUT{'progress'} = 0; } 
     688        else                       { $OUTPUT{'progress'} = 1; } 
     689    } 
     690    elsif ($key eq 'r') { 
     691        if   ($OUTPUT{'show_redirects'}) { $OUTPUT{'show_redirects'} = 0; } 
     692        else                             { $OUTPUT{'show_redirects'} = 1; } 
     693    } 
     694    elsif ($key eq 'c') { 
     695        if   ($OUTPUT{'show_cookies'}) { $OUTPUT{'show_cookies'} = 0; } 
     696        else                           { $OUTPUT{'show_cookies'} = 1; } 
     697    } 
     698    elsif ($key eq 'o') { 
     699        if   ($OUTPUT{'show_ok'}) { $OUTPUT{'show_ok'} = 0; } 
     700        else                      { $OUTPUT{'show_ok'} = 1; } 
     701    } 
     702    elsif ($key eq 'a') { 
     703        if   ($OUTPUT{'show_auth'}) { $OUTPUT{'show_auth'} = 0; } 
     704        else                        { $OUTPUT{'show_auth'} = 1; } 
     705    } 
     706    elsif (($key eq 'q') || (ord($key) eq 3)) { 
     707        safe_quit(); 
     708    } 
     709    return; 
    704710} 
    705711 
    706712############################################################################### 
    707713sub readkey { 
    708         if (!$NIKTO{'POSIX'}{'support'}) { return; } 
    709  
    710         my $key; 
    711         $NIKTO{'POSIX'}{'term'}->setlflag($NIKTO{'POSIX'}{'noecho'}); 
    712         $NIKTO{'POSIX'}{'term'}->setattr($NIKTO{'POSIX'}{'fd_stdin'}, TCSANOW); 
    713         eval { 
    714                 local $SIG{ALRM} = sub { die; }; 
    715                 ualarm(1_000); 
    716                 sysread(STDIN, $key, 1); 
    717                 ualarm(0); 
    718                 }; 
    719         $NIKTO{'POSIX'}{'term'}->setlflag($NIKTO{'POSIX'}{'oterm'}); 
    720         $NIKTO{'POSIX'}{'term'}->setattr($NIKTO{'POSIX'}{'fd_stdin'}, TCSANOW); 
    721  
    722         return $key; 
    723         } 
     714    if (!$NIKTO{'POSIX'}{'support'}) { return; } 
     715 
     716    my $key; 
     717    $NIKTO{'POSIX'}{'term'}->setlflag($NIKTO{'POSIX'}{'noecho'}); 
     718    $NIKTO{'POSIX'}{'term'}->setattr($NIKTO{'POSIX'}{'fd_stdin'}, TCSANOW); 
     719    eval { 
     720        local $SIG{ALRM} = sub { die; }; 
     721        ualarm(1_000); 
     722        sysread(STDIN, $key, 1); 
     723        ualarm(0); 
     724    }; 
     725    $NIKTO{'POSIX'}{'term'}->setlflag($NIKTO{'POSIX'}{'oterm'}); 
     726    $NIKTO{'POSIX'}{'term'}->setattr($NIKTO{'POSIX'}{'fd_stdin'}, TCSANOW); 
     727 
     728    return $key; 
     729} 
    724730 
    725731############################################################################### 
     
    12351241            $m->{ssl} = ($checkssl eq "HTTP") ? 0 : 1; 
    12361242            proxy_check($m); 
    1237             my ($res, $content) = nfetch($m, "/", $method, "", \%headers, { noerror => 1, noprefetch => 1, nopostfetch => 1 }, "Port Check"); 
     1243            my ($res, $content) = 
     1244              nfetch($m, "/", $method, "", \%headers, 
     1245                     { noerror => 1, noprefetch => 1, nopostfetch => 1 }, 
     1246                     "Port Check"); 
    12381247 
    12391248            if ($res) { 
     
    13991408        } 
    14001409 
    1401         if (!$run) { next; } 
     1410        if (!$run) { next; } 
    14021411 
    14031412        my $oldverbose = $OUTPUT{'verbose'}; 
     
    14141423            $OUTPUT{'debug'} = 1; 
    14151424        } 
    1416         unless ($type eq "prefetch" || $type eq "postfetch") { $NIKTO{'current_plugin'}=$plugin->{'full_name'}; } 
     1425        unless ($type eq "prefetch" || $type eq "postfetch") { 
     1426            $NIKTO{'current_plugin'} = $plugin->{'full_name'}; 
     1427        } 
    14171428        &{ $plugin->{ $type . '_method' } }($mark, $plugin->{'parameters'}, $request, $result); 
    14181429        $OUTPUT{'verbose'} = $oldverbose; 
     
    15841595    # check main nikto versions 
    15851596    foreach my $remotefile (keys %REMOTE) { 
    1586         my @l = split(/\./, $LOCAL{$remotefile}); 
    1587         my @r = split(/\./, $REMOTE{$remotefile}); 
    1588         my $update=0; 
    1589         if ($LOCAL{$remotefile} eq '') { $update=1; } 
    1590         elsif ($r[0] > $l[0]) { $update=1; } 
    1591         elsif ($r[1] > $l[1]) { $update=1; } 
    1592         elsif ($r[2] > $l[2]) { $update=1; } 
    1593  
    1594         if ($update) { 
    1595                 if ($remotefile eq "nikto") { 
    1596                                 nprint "+ Nikto has been updated to $REMOTE{$remotefile}, local copy is $NIKTO{'version'}\n"; 
    1597                                 nprint "+ No update has taken place. Please upgrade Nikto by visiting http://$server/\n"; 
    1598                                 if ($remotemsg ne "") { nprint "+ $server message: $remotemsg\n"; } 
    1599                                 exit; 
    1600                         } 
    1601                 push(@DBTOGET, $remotefile); 
    1602                 if ($remotefile !~ /^db_/) { $code_updates = 1; } 
    1603                 } 
    1604         } 
     1597        my @l = split(/\./, $LOCAL{$remotefile}); 
     1598        my @r = split(/\./, $REMOTE{$remotefile}); 
     1599        my $update = 0; 
     1600        if ($LOCAL{$remotefile} eq '') { $update = 1; } 
     1601        elsif ($r[0] > $l[0]) { $update = 1; } 
     1602        elsif ($r[1] > $l[1]) { $update = 1; } 
     1603        elsif ($r[2] > $l[2]) { $update = 1; } 
     1604 
     1605        if ($update) { 
     1606            if ($remotefile eq "nikto") { 
     1607                nprint 
     1608                  "+ Nikto has been updated to $REMOTE{$remotefile}, local copy is $NIKTO{'version'}\n"; 
     1609                nprint 
     1610                  "+ No update has taken place. Please upgrade Nikto by visiting http://$server/\n"; 
     1611                if ($remotemsg ne "") { nprint "+ $server message: $remotemsg\n"; } 
     1612                exit; 
     1613            } 
     1614            push(@DBTOGET, $remotefile); 
     1615            if ($remotefile !~ /^db_/) { $code_updates = 1; } 
     1616        } 
     1617    } 
    16051618 
    16061619    # replace local files if updated 
     
    16401653 
    16411654############################################################################### 
    1642 # read_data ( prompt, mode ) 
    1643 # read STDIN data from the user 
    1644 # portions of this (POSIX code) were taken from the 
    1645 # Term::ReadPassword module by Tom Phoenix <rootbeer@redcat.com> (many thanks). 
    1646 # it has been modified to not require Term::ReadLine, but still requires 
    1647 # POSIX::Termios of it's a POSIX machine 
     1655# portions of this sub were taken from the Term::ReadPassword module. 
     1656# It has been modified to not require Term::ReadLine, but still requires 
     1657# POSIX::Termios if it's a POSIX machine 
    16481658############################################################################### 
    16491659sub read_data { 
    1650     if ($NIKTOCONFIG{PROMPTS} =~ /no/i) { return; } 
     1660    if ($NIKTOCONFIG{PROMPTS} eq 'no') { return; } 
    16511661    my ($prompt, $mode, $POSIX) = @_; 
    1652     my $input = ""; 
     1662    my $input; 
    16531663 
    16541664    my %SPECIAL = ("\x03" => 'INT',    # Control-C, Interrupt 
     
    16581668                   "\x0a" => 'ENT',    # LF, Enter 
    16591669                   ); 
    1660  
    1661     # if we're on a non-POSIX machine we can't not-echo the 
    1662     # characters, so just use getc to avoid the dependency on 
    1663     # POSIX::Termios. We would be best to get rid of this 
    1664     # entirely and use another way... 
    16651670 
    16661671    if ($NIKTO{'POSIX'}{'support'}) { 
     
    19041909 
    19051910    if ((!defined $CLI{'nocache'}) && (!$flags_nocache)) { 
    1906         my $key =  $mark->{'ip'} 
    1907                    . $mark->{'hostname'} 
    1908                    . $mark->{'port'} 
    1909                    . $mark->{'ssl'} 
    1910                    . $method 
    1911                    . $uri 
    1912                    . $postdata; 
     1911        my $key = 
     1912            $mark->{'ip'} 
     1913          . $mark->{'hostname'} 
     1914          . $mark->{'port'} 
     1915          . $mark->{'ssl'} 
     1916          . $method 
     1917          . $uri 
     1918          . $postdata; 
    19131919 
    19141920        $CACHE{$key}{'method'}  = $method; 
     
    19561962    if (($NIKTO{'totalrequests'} % 10) == 0) { 
    19571963        check_input(); 
    1958         } 
     1964    } 
    19591965 
    19601966    if (defined $CLI{'root'}) { 
     
    19621968    } 
    19631969    else { 
    1964         $request{'whisker'}->{'uri'} = $uri; 
     1970        $request{'whisker'}->{'uri'} = $uri; 
    19651971    } 
    19661972    $request{'whisker'}->{'method'} = $method; 
     
    19731979    # check for extra HTTP headers 
    19741980    if (defined $headers) { 
     1981 
    19751982        # loop through the hash ref passed and add each header to request 
    19761983        while (my ($key, $value) = each(%$headers)) { 
     
    20092016 
    20102017        # Snarf what we can from the whisker hash and put in mark 
    2011                 if (!exists $result{'whisker'}->{'error'}) {             
    2012                         if (!exists $mark->{'banner'}) { 
    2013                                 $mark->{'banner'} = $result{'server'}; 
    2014                         } 
    2015                         else { 
    2016                                 # Check banner hasn't changed 
    2017                                 if (exists $result{'server'} && $mark->{'banner'} ne $result{'server'} && !exists $mark->{'bannerchanged'}) { 
    2018                                         nprint("+ Server banner has changed from $mark->{banner} to $result{server}, this may suggest a WAF is in place"); 
    2019                                         $mark->{'bannerchanged'} = 1; 
    2020                                 } 
    2021                         } 
    2022                          
    2023                         if (!exists $mark->{'ssl_cipher'} && $mark->{'ssl'}) { 
    2024                                 # Grab ssl details 
    2025                                 $mark->{'ssl_cipher'} = $result{'whisker'}->{'ssl_cipher'}; 
    2026                                 $mark->{'ssl_cert_issuer'} = $result{'whisker'}->{'ssl_cert_issuer'}; 
    2027                                 $mark->{'ssl_cert_subject'} = $result{'whisker'}->{'ssl_cert_subject'}; 
    2028                         } 
    2029                 } 
     2018        if (!exists $result{'whisker'}->{'error'}) { 
     2019            if (!exists $mark->{'banner'}) { 
     2020                $mark->{'banner'} = $result{'server'}; 
     2021            } 
     2022            else { 
     2023 
     2024                # Check banner hasn't changed 
     2025                if (   exists $result{'server'} 
     2026                    && $mark->{'banner'} ne $result{'server'} 
     2027                    && !exists $mark->{'bannerchanged'}) { 
     2028                    nprint( 
     2029                        "+ Server banner has changed from $mark->{banner} to $result{server}, this may suggest a WAF is in place" 
     2030                        ); 
     2031                    $mark->{'bannerchanged'} = 1; 
     2032                } 
     2033            } 
     2034 
     2035            if (!exists $mark->{'ssl_cipher'} && $mark->{'ssl'}) { 
     2036 
     2037                # Grab ssl details 
     2038                $mark->{'ssl_cipher'}       = $result{'whisker'}->{'ssl_cipher'}; 
     2039                $mark->{'ssl_cert_issuer'}  = $result{'whisker'}->{'ssl_cert_issuer'}; 
     2040                $mark->{'ssl_cert_subject'} = $result{'whisker'}->{'ssl_cert_subject'}; 
     2041            } 
     2042        } 
    20302043    } 
    20312044    nprint("- $result{'whisker'}{'code'} for $method:\t$uri", "v"); 
     
    21182131                $db_extensions{$ext} = 1; 
    21192132 
    2120                 # Escape chars in the conditionals.  This must change if regexs are allowed in the db. 
     2133              # Escape chars in the conditionals.  This must change if regexs are allowed in the db. 
    21212134                for (my $y = 5 ; $y <= 9 ; $y++) { $item[$y] = quotemeta($item[$y]); } 
    21222135 
  • trunk/plugins/nikto_headers.plugin

    r440 r457  
    2828         description => "Performs various checks against the headers returned from a HTTP request.", 
    2929         postfetch_method => \&nikto_headers_postfetch, 
    30          scan_method => \&nikto_headers, 
    31          copyright   => "2008 CIRT Inc." 
     30         scan_method      => \&nikto_headers, 
     31         copyright        => "2008 CIRT Inc." 
    3232         }; 
    33     
     33 
    3434    # some global variables 
    3535    use vars qw/%HFOUND/; 
     
    4040sub nikto_headers_postfetch { 
    4141    my ($mark, $parameters, $request, $result) = @_; 
    42     
     42 
    4343    if (exists $result->{'whisker'}->{'error'}) { 
    4444        return $request, $result; 
     
    5959    my ($mark, $result, $header, $message, $tid) = @_; 
    6060 
    61     if (exists $result->{$header}) 
    62     { 
    63         my $key = LW2::md5(  $mark->{'ip'} 
    64                            . $mark->{'hostname'} 
    65                            . $mark->{'port'} 
    66                            . $mark->{'ssl'} 
    67                            . $result->{'whisker'}->{'method'} 
    68                            . $header); 
     61    if (exists $result->{$header}) { 
     62        my $key = 
     63          LW2::md5(  $mark->{'ip'} 
     64                   . $mark->{'hostname'} 
     65                   . $mark->{'port'} 
     66                   . $mark->{'ssl'} 
     67                   . $result->{'whisker'}->{'method'} 
     68                   . $header); 
    6969 
    7070        if (!exists $HFOUND{$key}) { 
    7171            my $value = $result->{$header}; 
    7272            $HFOUND{$key} = $value; 
    73          
    74             add_vulnerability($mark, $message . " " . $value, $tid, "0", 
     73 
     74            add_vulnerability($mark, $message . " " . $value, 
     75                              $tid, "0", 
    7576                              $result->{'whisker'}->{'method'}, 
    7677                              $result->{'whisker'}->{'uri'}); 
  • trunk/plugins/nikto_httpoptions.plugin

    r443 r457  
    7272        foreach my $m (split /,? /, $allow_methods) { 
    7373            my $method = eval_methods($m, "Allow", $dbarray, $mark); 
    74             if ($method ne "") { $davmethods{$method} = 1 }; 
     74            if ($method ne "") { $davmethods{$method} = 1 } 
    7575        } 
    7676    } 
     
    8080        foreach my $m (split /,? /, $public_methods) { 
    8181            my $method = eval_methods($m, "Public", $dbarray, $mark); 
    82             if ($method ne "") { $davmethods{$method} = 1 }; 
     82            if ($method ne "") { $davmethods{$method} = 1 } 
    8383        } 
    8484    } 
    85      
     85 
    8686    if (scalar(keys(%davmethods)) > 0) { 
    8787        $message = "WebDAV enabled ("; 
     
    9292        add_vulnerability($mark, "$message", "999977", "0"); 
    9393    } 
     94 
    9495    # Check for other weirdness 
    9596    # IIS Debug 
     
    109110    %headers = ("Host"           => "", 
    110111                "Content-Length" => "0",); 
    111     ($res, $content) = nfetch($mark, "/", "PROPFIND", "", \%headers, { noclean => 1 }, "httpoptions: PROPFIND"); 
     112    ($res, $content) = 
     113      nfetch($mark, "/", "PROPFIND", "", \%headers, { noclean => 1 }, "httpoptions: PROPFIND"); 
    112114    if ($res == 207) { 
    113115        if ($content =~ "<a:href>http://") { 
     
    124126    %headers = ("Host" => "Nikto",); 
    125127    foreach my $method (split(/ /, "TRACE TRACK")) { 
     128 
    126129        # Check for all flavours of HTTP 
    127130        foreach my $version (split(/ /, "1.0 1.1")) { 
     
    159162    # Now search database for the method. 
    160163    foreach my $item (@$dbarray) { 
    161         if ($method eq "PROPPATCH" || $method eq "SEARCH" || 
    162             $method eq "PROPFIND" || $method eq "COPY" || 
    163             $method eq "LOCK" || $method eq "UNLOCK") { 
     164        if (   $method eq "PROPPATCH" 
     165            || $method eq "SEARCH" 
     166            || $method eq "PROPFIND" 
     167            || $method eq "COPY" 
     168            || $method eq "LOCK" 
     169            || $method eq "UNLOCK") { 
    164170            return $method; 
    165171        } 
     
    167173        if ($item->{'method'} eq $method) { 
    168174            if ($item->{'nikto_id'} eq "0") { 
     175 
    169176                # is webdav 
    170177                return $method; 
     
    177184        } 
    178185    } 
    179         
     186 
    180187    return ""; 
    181188} 
  • trunk/plugins/nikto_report_nbe.plugin

    r391 r457  
    4141 
    4242    # Write header 
    43     print OUT "timestamps|network|host|port|nikto_id|prio|$NIKTO{'name'} v$NIKTO{'version'}/$NIKTO{'core_version'}\n"; 
     43    print OUT 
     44      "timestamps|network|host|port|nikto_id|prio|$NIKTO{'name'} v$NIKTO{'version'}/$NIKTO{'core_version'}\n"; 
    4445    return OUT; 
    4546} 
    4647 
    4748sub nbe_item { 
    48         my ($handle, $mark, $item) = @_; 
    49         foreach my $uri (split(' ', $item->{'uri'})) { 
    50                 my ( $line, $network ); 
    51                 if ( $item->{'mark'}->{'hostname'} && $item->{'mark'}->{'port'} && $item->{'nikto_id'} ) { 
    52                         if ($item->{'mark'}->{'hostname'} =~ /^(\d+\.\d+\.\d+)\.\d+$/) { 
    53                                 $network = $1; 
    54                         } 
    55                         $line.="results|"; 
    56                         $line.="$network|"; 
    57                         $line.="$item->{'mark'}->{'hostname'}|"; 
    58                         $line.="$item->{'mark'}->{'port'}|"; 
    59                         $line.="$item->{'nikto_id'}|"; 
    60                         $line.="Security Warning|"; 
    61                         if ($item->{'osvdb'})  { $line.="OSVDB-$item->{'osvdb'}: " }; 
    62                         if ($item->{'method'}) { $line.="$item->{'method'} " }; 
    63                         if ($uri)            { $line.="${'uri'}: " }; 
    64                         $line.=$item->{'message'}; 
    65                         print $handle "$line\n"; 
    66                 } else { 
    67                         my $debug = "Data provided:\n$handle, $mark, $item"; 
    68                         $debug.= "\nContents of \$mark:"; 
    69                         foreach my $key ( sort keys %$mark ) { 
    70                                 $debug .= "\n$key - $mark->{$key}"; 
    71                         } 
    72                         $debug.= "\nContents of \$item:"; 
    73                         foreach my $key ( sort keys %$item ) { 
    74                                 $debug .= "\n$key - $item->{$key}"; 
    75                         } 
    76                         $debug.= "\nContents of \$item->{mark}:"; 
    77                         foreach my $key ( sort keys %{$item->{mark}} ) { 
    78                                 $debug .= "\n$key - $item->{mark}->{$key}"; 
    79                         } 
    80                         #die $debug; 
    81                         nprint("+ Invalid reporting line: $debug"); 
    82                 } 
    83         } 
     49    my ($handle, $mark, $item) = @_; 
     50    foreach my $uri (split(' ', $item->{'uri'})) { 
     51        my ($line, $network); 
     52        if ($item->{'mark'}->{'hostname'} && $item->{'mark'}->{'port'} && $item->{'nikto_id'}) { 
     53            if ($item->{'mark'}->{'hostname'} =~ /^(\d+\.\d+\.\d+)\.\d+$/) { 
     54                $network = $1; 
     55            } 
     56            $line .= "results|"; 
     57            $line .= "$network|"; 
     58            $line .= "$item->{'mark'}->{'hostname'}|"; 
     59            $line .= "$item->{'mark'}->{'port'}|"; 
     60            $line .= "$item->{'nikto_id'}|"; 
     61            $line .= "Security Warning|"; 
     62            if ($item->{'osvdb'})  { $line .= "OSVDB-$item->{'osvdb'}: " } 
     63            if ($item->{'method'}) { $line .= "$item->{'method'} " } 
     64            if ($uri)              { $line .= "${'uri'}: " } 
     65            $line .= $item->{'message'}; 
     66            print $handle "$line\n"; 
     67        } 
     68        else { 
     69            my $debug = "Data provided:\n$handle, $mark, $item"; 
     70            $debug .= "\nContents of \$mark:"; 
     71            foreach my $key (sort keys %$mark) { 
     72                $debug .= "\n$key - $mark->{$key}"; 
     73            } 
     74            $debug .= "\nContents of \$item:"; 
     75            foreach my $key (sort keys %$item) { 
     76                $debug .= "\n$key - $item->{$key}"; 
     77            } 
     78            $debug .= "\nContents of \$item->{mark}:"; 
     79            foreach my $key (sort keys %{ $item->{mark} }) { 
     80                $debug .= "\n$key - $item->{mark}->{$key}"; 
     81            } 
     82 
     83            #die $debug; 
     84            nprint("+ Invalid reporting line: $debug"); 
     85        } 
     86    } 
    8487} 
    8588 
  • trunk/plugins/nikto_report_xml.plugin

    r450 r457  
    188188    foreach my $c (split(//, $invar)) { 
    189189        my $n = ord($c); 
    190         if (($n > 127) || ($n < 32) || ($n == 38) || ($n == 60) || ($n == 62) | ($n == 34)) { $outvar .= sprintf '%#x', $n; } 
     190        if (($n > 127) || ($n < 32) || ($n == 38) || ($n == 60) || ($n == 62) | ($n == 34)) { 
     191            $outvar .= sprintf '%#x', $n; 
     192        } 
    191193        else { $outvar .= $c; } 
    192         } 
     194    } 
    193195    return $outvar; 
    194196} 
  • trunk/plugins/nikto_robots.plugin

    r449 r457  
    4040    (my $RES, $CONTENT) = nfetch($mark, "/robots.txt", "GET", "", \%headers, "", "robots"); 
    4141 
    42     if (($RES eq 200) || ($RES eq $FoF{'okay'}{'response'})) 
    43     { 
     42    if (($RES eq 200) || ($RES eq $FoF{'okay'}{'response'})) { 
    4443        if (is_404("robots.txt", $CONTENT, $RES, $headers{'location'})) { return; } 
    4544 
     
    4948        foreach my $line (@DOC) { 
    5049            $line = quotemeta($line); 
    51             if ($line =~ /allow/i) 
    52             { 
     50            if ($line =~ /allow/i) { 
    5351                chomp($line); 
    5452                $line =~ s/\#.*$//; 
  • trunk/plugins/nikto_subdomain.plugin

    r439 r457  
    3232 
    3333    return $id; 
    34     } 
     34} 
    3535 
    3636sub nikto_subdomain { 
     
    4848               "v"); 
    4949        return; 
    50         } 
     50    } 
    5151 
    5252    # Check if the start of the domain is "www" 
     
    5555        # Remove the www. 
    5656        $host =~ s/^www\.//; 
    57         } 
     57    } 
    5858 
    5959    my $nocache_enabled = 0; 
     
    7272            add_vulnerability($mark, "Subdomain $item->{'subdomain'} found", $item->{'nikto_id'}, 
    7373                              0); 
    74             }    # End if 
     74        }    # End if 
    7575 
    76         }    # End foreach 
     76    }    # End foreach 
    7777    if (!$nocache_enabled) { undef $CLI{'nocache'}; } 
    78     }    # End sub 
     78}    # End sub 
    7979 
    80801; 
  • trunk/plugins/nikto_tests.plugin

    r452 r457  
    3636                 }; 
    3737    return $id; 
    38     } 
     38} 
    3939 
    4040sub nikto_tests { 
     
    5959            # auth is now done in nfetch 
    6060            if ($res eq 200) { 
    61                 nprint("+ $uri - 200/OK Response could be $TESTS{$checkid}{'message'}") if $OUTPUT{'show_ok'}; 
    62                 } 
     61                nprint("+ $uri - 200/OK Response could be $TESTS{$checkid}{'message'}") 
     62                  if $OUTPUT{'show_ok'}; 
     63            } 
    6364            elsif ($res =~ /30(?:[0-3]|7)/) { 
    6465                nprint(  "+ $uri - Redirects ($res) to " 
     
    6667                       . " , $TESTS{$checkid}{'message'}") 
    6768                  if $OUTPUT{'show_redirects'}; 
    68                 } 
     69            } 
    6970 
    7071            my $m1_method = my $m1o_method = my $m1a_method = my $f2_method = my $f1_method = 
     
    8384                if ($content =~ /$TESTS{$checkid}{'match_1'}/) { 
    8485                    $positive = 1; 
    85                     } 
    86                 } 
     86                } 
     87            } 
    8788            else { 
    8889                if (($res eq $TESTS{$checkid}{'match_1'}) || ($res eq $FoF{'okay'}{'response'})) { 
    8990                    $positive = 1; 
    90                     } 
    91                 } 
     91                } 
     92            } 
    9293 
    9394            # no match, check optional match 
     
    9697                    if ($content =~ /$TESTS{$checkid}{'match_1_or'}/) { 
    9798                        $positive = 1; 
    98                         } 
    99                     } 
     99                    } 
     100                } 
    100101                else { 
    101102                    if (   ($res eq $TESTS{$checkid}{'match_1_or'}) 
    102103                        || ($res eq $FoF{'okay'}{'response'})) { 
    103104                        $positive = 1; 
    104                         } 
    105                     } 
    106                 } 
     105                    } 
     106                } 
     107            } 
    107108 
    108109            # matched on something, check fails/ands 
     
    111112                    if ($f1_method eq "content") { 
    112113                        if ($content =~ /$TESTS{$checkid}{'fail_1'}/) { next; } 
    113                         } 
     114                    } 
    114115                    else { 
    115116                        if ($res eq $TESTS{$checkid}{'fail_1'}) { next; } 
    116                         } 
    117                     } 
     117                    } 
     118                } 
    118119                if ($TESTS{$checkid}{'fail_2'} ne "") { 
    119120                    if ($f2_method eq "content") { 
    120121                        if ($content =~ /$TESTS{$checkid}{'fail_2'}/) { next; } 
    121                         } 
     122                    } 
    122123                    else { 
    123124                        if ($res eq $TESTS{$checkid}{'fail_2'}) { next; } 
    124                         } 
    125                     } 
     125                    } 
     126                } 
    126127                if ($TESTS{$checkid}{'match_1_and'} ne "") { 
    127128                    if ($m1a_method eq "content") { 
    128129                        if ($content !~ /$TESTS{$checkid}{'match_1_and'}/) { next; } 
    129                         } 
     130                    } 
    130131                    else { 
    131132                        if ($res ne $TESTS{$checkid}{'match_1_and'}) { next; } 
    132                         } 
    133                     } 
     133                    } 
     134                } 
    134135 
    135136                # if it's an index.php, check for normal /index.php to see if it's a FP 
     
    137138                    my $content = rm_active_content($content, $uri); 
    138139                    if (LW2::md4($content) eq $FoF{'index.php'}{'match'}) { next; } 
    139                     } 
     140                } 
    140141 
    141142                # lastly check for a false positive based on file extension or type 
    142143                if (($m1_method eq "code") || ($m1o_method eq "code")) { 
    143144                    if (is_404($uri, $content, $res, $headers{'location'})) { next; } 
    144                     } 
     145                } 
    145146 
    146147                $TESTS{$checkid}{'osvdb'} =~ s/\s+/ OSVDB\-/g; 
     
    149150                                  $TESTS{$checkid}{'osvdb'}, 
    150151                                  $TESTS{$checkid}{'method'}, $uri); 
    151                 } 
    152             } 
     152            } 
     153        } 
    153154 
    154155        # Percentages 
    155         if ($OUTPUT{'progress'}) { 
    156                 if ($parameters->{'report'}) { 
    157                     $progress++; 
    158                     if (($progress % $parameters->{'report'}) == 0) { 
    159                         my $line = sprintf("- Tests completed: %d %.0f%%", 
    160                                    $progress, ($progress / $NIKTO{total_checks}) * 100); 
    161                 nprint($line); 
    162                 } 
    163             } 
    164         } 
    165         }    # end check loop 
     156        if ($OUTPUT{'progress'}) { 
     157            if ($parameters->{'report'}) { 
     158                $progress++; 
     159                if (($progress % $parameters->{'report'}) == 0) { 
     160                    my $line = sprintf("- Tests completed: %d %.0f%%", 
     161                                       $progress, ($progress / $NIKTO{total_checks}) * 100); 
     162                    nprint($line); 
     163                } 
     164            } 
     165        } 
     166    }    # end check loop 
    166167 
    167168    # Perform mutation tests 
    168169    if ($parameters->{'passfiles'}) { 
    169170        passchecks($mark); 
    170         } 
     171    } 
    171172    if ($parameters->{'all'}) { 
    172173        allchecks($mark); 
    173         } 
     174    } 
    174175 
    175176    return; 
    176     } 
     177} 
    177178 
    178179sub passchecks { 
     
    203204                    # dir/file 
    204205                    testfile($mark, "$cgi$dir$file", "passfiles", "299998"); 
    205                     } 
    206                 } 
    207             } 
    208         } 
    209     } 
     206                } 
     207            } 
     208        } 
     209    } 
     210} 
    210211 
    211212sub allchecks { 
     
    231232                $dir  =~ s/([^a-zA-Z0-9])/\\$1/g; 
    232233                $file =~ s/$dir//; 
    233                 } 
     234            } 
    234235            if (($file ne "") && ($file !~ /^\?/)) { 
    235236                $FILES{$file} = ""; 
    236                 } 
    237             } 
    238         } 
     237            } 
     238        } 
     239    } 
    239240 
    240241    # Now do a check for each item - just check the return status, nothing else 
     
    242243        foreach my $file (keys %FILES) { 
    243244            testfile($mark, "$dir$file", "all checks", 299999); 
    244             } 
    245         } 
    246     } 
     245        } 
     246    } 
     247} 
    247248 
    248249sub testfile { 
     
    254255        nprint("+ ERROR: $uri returned an error: $error", "e"); 
    255256        return; 
    256         } 
     257    } 
    257258    if ($res == 200) { 
    258259        add_vulnerability($mark, "$uri: file found during $name mutation", "$tid", "0", "GET"); 
    259         } 
    260     } 
     260    } 
     261} 
    261262 
    2622631; 
Note: See TracChangeset for help on using the changeset viewer.