Changeset 76


Ignore:
Timestamp:
09/20/2008 04:21:51 PM (5 years ago)
Author:
deity
Message:

Reduce warnings in nikto

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/config.txt

    r46 r76  
    5959# server do not implement the HEAD method 
    6060CHECKMETHODS=HEAD GET 
     61 
     62CLIOPTS=-Format html -output report.html 
  • trunk/docs/CHANGES.txt

    r75 r76  
     12008-09-20 plugins/nikto_core.plugin plugins/nikto_cgi.plugin nikto.pl 
     2        - Fixes to ensure nikto produces less perl warnings 
    132008-09-16 plugins/nikto_core.plugin plugins/nikto_httpoptions.plugin 
    24        - Fix for ticket #37 
  • trunk/nikto.pl

    r75 r76  
    8484$request{'whisker'}->{'lowercase_incoming_headers'} = 1; 
    8585$request{'whisker'}->{'timeout'}                    = $CLI{timeout} || 10; 
    86 if ($CLI{evasion} ne "") { $request{'whisker'}->{'encode_anti_ids'} = $CLI{evasion}; } 
     86if (defined $CLI{evasion}) { $request{'whisker'}->{'encode_anti_ids'} = $CLI{evasion}; } 
    8787$request{'User-Agent'} = $NIKTO{useragent}; 
    8888$request{'whisker'}->{'retry'} = 0; 
     
    126126    else { 
    127127        $request{'whisker'}->{'host'} = $TARGETS{$CURRENT_HOST_ID}{hostname} || $TARGETS{$CURRENT_HOST_ID}{ip}; 
    128         if ($TARGETS{$CURRENT_HOST_ID}{vhost} ne '') { $request{'Host'} = $TARGETS{$CURRENT_HOST_ID}{vhost}; } 
     128        if (defined $TARGETS{$CURRENT_HOST_ID}{vhost}) { $request{'Host'} = $TARGETS{$CURRENT_HOST_ID}{vhost}; } 
    129129        foreach $CURRENT_PORT (keys %{$TARGETS{$CURRENT_HOST_ID}{ports}}) 
    130130        { 
     
    133133            $request{'whisker'}->{'ssl'}     = $TARGETS{$CURRENT_HOST_ID}{ports}{$CURRENT_PORT}{ssl}; 
    134134            $request{'whisker'}->{'version'} = $NIKTOCONFIG{DEFAULTHTTPVER}; 
    135             if ($NIKTOCONFIG{'STATIC-COOKIE'} ne "") { $request{'Cookie'} = $NIKTOCONFIG{'STATIC-COOKIE'}; } 
     135            if (defined $NIKTOCONFIG{'STATIC-COOKIE'}) { $request{'Cookie'} = $NIKTOCONFIG{'STATIC-COOKIE'}; } 
    136136            $TARGETS{$CURRENT_HOST_ID}{total_vulns} = 0; 
    137137            delete $TARGETS{$CURRENT_HOST_ID}{positives}; 
     
    192192 
    193193    # add CONFIG{CLIOPTS} to ARGV if defined... 
    194     if ($NIKTOCONFIG{CLIOPTS} ne "") 
     194    if (defined $NIKTOCONFIG{CLIOPTS}) 
    195195    { 
    196196        my @t = split(/ /, $NIKTOCONFIG{CLIOPTS}); 
     
    206206    # get the correct path to 'plugins' 
    207207    # if defined in config.txt file... most accurate, we hope 
    208     if (($NIKTOCONFIG{EXECDIR} ne "") && (-d "$NIKTOCONFIG{EXECDIR}/plugins")) 
     208    if ((defined $NIKTOCONFIG{EXECDIR}) && (-d "$NIKTOCONFIG{EXECDIR}/plugins")) 
    209209    { 
    210210        $NIKTO{execdir}     = $NIKTOCONFIG{EXECDIR}; 
     
    213213    } 
    214214 
    215     if ($NIKTO{execdir} eq "") 
     215    unless (defined $NIKTO{execdir}) 
    216216    {    # try pwd 
    217217        if (-d "$ENV{PWD}/plugins") 
  • trunk/plugins/nikto_cgi.plugin

    r54 r76  
    5353         ($res, $CONTENT)=fetch($possiblecgidir,"GET"); 
    5454         nprint("Checked for CGI dir\t$possiblecgidir\tgot:$res","d"); 
    55          if (content_present($res) eq true) 
     55         if (content_present($res) eq TRUE) 
    5656         { 
    5757            $gotvalid++;  
  • trunk/plugins/nikto_core.plugin

    r75 r76  
    215215 chomp($line); 
    216216 # don't print debug & verbose to output file... 
    217  if ($_[1] eq "d") 
    218         {  
    219                 if ($OUTPUT{debug}) { print "D:" . localtime() . " $line\n"; } 
    220                 return; 
    221         } 
    222  elsif ($_[1] eq "v") 
    223         {  
    224                 if ($OUTPUT{verbose}) { print "V:" . localtime() . " $line\n"; } 
    225                 return; 
    226         } 
    227   
     217 if (defined $_[1]) 
     218 { 
     219    if ($_[1] eq "d") 
     220    {  
     221       if ($OUTPUT{debug}) { print "D:" . localtime() . " $line\n"; } 
     222       return; 
     223    } 
     224    elsif ($_[1] eq "v") 
     225    {  
     226       if ($OUTPUT{verbose}) { print "V:" . localtime() . " $line\n"; } 
     227       return; 
     228    } 
     229 }  
    228230 # print errors to STDERR 
    229231 if ($line =~ /ERROR\:/) { print STDERR "$line\n"; } 
     
    324326 LW2::http_do_request_timeout(\%request,\%result); 
    325327 dump_var("Result Hash", \%result); 
    326  if ($result{location} ne "")  
     328 if (defined $result{location})  
    327329  {  
    328330   nprint("- Root page / redirects to: $result{location}"); 
     
    393395   $ext=$REQS{$file}; 
    394396   $FoF{$ext}{response} = $result{'whisker'}->{'code'}; 
    395    if ($result{location} ne "")  
     397   if (defined $result{location})  
    396398     {  
    397399        $FoF{$ext}{location} = $result{location}; 
     
    492494  
    493495 # URI, if provided, plus encoded versions of it 
    494  if ($_[1] ne '')  
     496 if (defined $_[1])  
    495497        {  
    496498                my $e = $_[1]; 
     
    560562 nprint("+ Target Hostname:    $TARGETS{$CURRENT_HOST_ID}{hostname}");  
    561563 nprint("+ Target Port:        $CURRENT_PORT"); 
    562  if (($CLI{vhost} ne $TARGETS{$CURRENT_HOST_ID}{hostname}) && ($CLI{vhost} ne "")) 
     564 if ((defined $CLI{vhost}) && ($CLI{vhost} ne $TARGETS{$CURRENT_HOST_ID}{hostname})) 
    563565     { nprint("+ Virtual Host:   $CLI{vhost}"); } 
    564  if ($request{'whisker'}->{'proxy_host'} ne "")  
     566 if (defined $request{'whisker'}->{'proxy_host'})  
    565567     { nprint("- Proxy:       $request{'whisker'}->{'proxy_host'}:$request{'whisker'}->{'proxy_port'}"); } 
    566  if ($NIKTO{hostid} ne "") { nprint("- Host Auth:       ID: $NIKTO{hostid}, PW: $NIKTO{hostpw}, Realm: $NIKTO{hostdomain}","v"); } 
     568 if (defined $NIKTO{hostid}) { nprint("- Host Auth:       ID: $NIKTO{hostid}, PW: $NIKTO{hostpw}, Realm: $NIKTO{hostdomain}","v"); } 
    567569 if ($TARGETS{$CURRENT_HOST_ID}{ports}{$CURRENT_PORT}{ssl}) { nprint($SSLPRINT); } 
    568  for (my $i=1;$i<=(keys %{$NIKTO{anti_ids}});$i++) { if ($CLI{evasion} =~ /$i/) { nprint("+ Using IDS Evasion:  $NIKTO{anti_ids}{$i}"); }} 
    569  for (my $i=1;$i<=(keys %{$NIKTO{mutate_opts}});$i++) { if ($CLI{mutate} =~ /$i/) { nprint("+ Using Mutation:     $NIKTO{mutate_opts}{$i}"); }} 
     570 if (defined $NIKTO{anti_ids} && defined $CLI{evasion}) 
     571 { 
     572    for (my $i=1;$i<=(keys %{$NIKTO{anti_ids}});$i++) { if ($CLI{evasion} =~ /$i/) { nprint("+ Using IDS Evasion:  $NIKTO{anti_ids}{$i}"); }} 
     573 } 
     574 if (defined $NIKTO{mutate_opts} && defined $CLI{mutate}) 
     575 { 
     576    for (my $i=1;$i<=(keys %{$NIKTO{mutate_opts}});$i++) { if ($CLI{mutate} =~ /$i/) { nprint("+ Using Mutation:     $NIKTO{mutate_opts}{$i}"); }} 
     577 } 
    570578 nprint("+ Start Time:         $TARGETS{$CURRENT_HOST_ID}{ports}{$CURRENT_PORT}{start_time_disp}"); 
    571579 nprint($DIV); 
     
    759767 
    760768 # screen output 
    761  if ($CLI{display} =~ /d/i)  { $OUTPUT{debug}=1; } 
    762  if ($CLI{display} =~ /v/i)  { $OUTPUT{verbose}=1; } 
     769 if (defined $CLI{display}) 
     770 { 
     771    if ($CLI{display} =~ /d/i)  { $OUTPUT{debug}=1; } 
     772    if ($CLI{display} =~ /v/i)  { $OUTPUT{verbose}=1; } 
     773 } 
    763774  
    764775 # port(s) 
    765  $CLI{ports}=~s/^\s+//; 
    766  $CLI{ports}=~s/\s+$//; 
    767  #if ($CLI{ports} eq "") { $CLI{ports}=80; } 
    768  if ($CLI{ports} =~ /[^0-9\-\, ]/) { nprint("+ ERROR: Invalid port option '$CLI{ports}'"); exit; } 
     776 if (defined $CLI{ports}) 
     777 { 
     778    $CLI{ports}=~s/^\s+//; 
     779    $CLI{ports}=~s/\s+$//; 
     780    #if ($CLI{ports} eq "") { $CLI{ports}=80; } 
     781    if ($CLI{ports} =~ /[^0-9\-\, ]/) { nprint("+ ERROR: Invalid port option '$CLI{ports}'"); exit; } 
     782 } 
    769783 
    770784 # Fixup 
    771  $CLI{root} =~ s/\/$//; 
    772  if (($CLI{root} !~ /^\//) && ($CLI{root} ne "")) { $CLI{root} = "/$CLI{root}"; } 
    773  
    774  if ($CLI{hostauth} ne "") 
     785 if (defined $CLI{root}) 
     786 { 
     787    $CLI{root} =~ s/\/$//; 
     788    if (($CLI{root} !~ /^\//) && ($CLI{root} ne "")) { $CLI{root} = "/$CLI{root}"; } 
     789 } 
     790 
     791 if (defined $CLI{hostauth}) 
    775792 { 
    776793  my @x=split(/:/,$CLI{hostauth}); 
     
    781798  $NIKTO{hostdomain} = $x[2]; 
    782799 }  
    783  $CLI{evasion}=~s/[^0-9]//g; 
    784  
    785  $NIKTO{useragent}="Mozilla/4.75 ($NIKTO{name}/$NIKTO{version} $request{'User-Agent'})"; 
     800 
     801 if (defined $CLI{evasion}) 
     802 { 
     803    $CLI{evasion}=~s/[^0-9]//g; 
     804 } 
     805 
     806 $NIKTO{useragent}="Mozilla/4.75 ($NIKTO{name}/$NIKTO{version})"; 
    786807  
    787808 # SSL Test 
     
    789810  
    790811 # Notices 
    791  my $notice; 
    792  if ($CLI{root} ne '')  
     812 my $notice=""; 
     813 if (defined $CLI{root})  
    793814   { $notice .= "Prepending '$CLI{root}' to requests"; } 
    794815 if ($CLI{pause} > 0)  
     
    917938         { 
    918939            # First get the host name 
    919             my $host, $ip; 
     940            my ($host, $ip); 
    920941            my @line=split(/ /); 
    921942            my @name=split(/\(|\)/, $line[2]); 
     
    10041025            } 
    10051026             
    1006             if ($CLI{vhost} ne '') { $TARGETS{$host_ctr}{vhost}=$CLI{vhost}; } 
    1007             nprint("- Target id:$host_ctr:ident:$TARGETS{$host_ctr}{ident}:ports_in:$TARGETS{$host_ctr}{ports_in}:vhost:$$TARGETS{$host_ctr}{vhost}=$CLI{vhost}:","d"); 
    1008  
     1027            if (defined $CLI{vhost}) 
     1028            { 
     1029               $TARGETS{$host_ctr}{vhost}=$CLI{vhost}; 
     1030               nprint("- Target id:$host_ctr:ident:$TARGETS{$host_ctr}{ident}:ports_in:$TARGETS{$host_ctr}{ports_in}:vhost:$$TARGETS{$host_ctr}{vhost}=$CLI{vhost}:","d"); 
     1031            } 
    10091032            nprint( 
    10101033                "- Target id:$host_ctr:ident:$TARGETS{$host_ctr}{ident}:ports_in:$TARGETS{$host_ctr}{ports_in}:","d" 
     
    11031126 my @dbs=qw/db_404_strings  db_outdated  db_realms  db_tests  db_variables/; 
    11041127 my $prefix = $_[0]; 
     1128 
     1129 unless (defined $prefix) 
     1130 { 
     1131    $prefix=""; 
     1132 } 
    11051133 
    11061134 # verify required files 
     
    17781806 $request{'whisker'}->{'uri'}="/"; 
    17791807 
    1780  if ($request{'whisker'}->{'proxy_host'} ne "")  # proxy is set up 
     1808 if (defined $request{'whisker'}->{'proxy_host'})  # proxy is set up 
    17811809 { 
    17821810  LW2::http_close(\%request);  # force-close any old connections 
     
    18301858 my @FILES_TMP = (); 
    18311859 
    1832  opendir(directory,$DIR) || die print STDERR "+ ERROR: Can't open directory '$DIR': $@"; 
    1833  foreach my $file (readdir(directory)) 
     1860 opendir(DIRECTORY,$DIR) || die print STDERR "+ ERROR: Can't open directory '$DIR': $@"; 
     1861 foreach my $file (readdir(DIRECTORY)) 
    18341862  { 
    18351863   if ($file =~ /^\./)    { next; } # skip hidden files, '.' and '..' 
     
    18371865   else { push (@FILES_TMP,$file); } 
    18381866   } 
    1839 closedir(directory); 
     1867closedir(DIRECTORY); 
    18401868  
    18411869return @FILES_TMP; 
     
    18551883sub content_present 
    18561884{ 
    1857    my $result=false; 
     1885   my $result=FALSE; 
    18581886   my $res=$_[0]; 
    18591887 
     
    18621890      if ($res eq $found) 
    18631891      { 
    1864          $result=true; 
     1892         $result=TRUE; 
    18651893      } 
    18661894   } 
     
    18721900 if ($CLI{pause} > 0) { sleep $CLI{pause}; } 
    18731901 LW2::http_close(\%request);  # force-close any old connections 
    1874  $request{'whisker'}->{'uri'}    = $CLI{root} . $_[0];   # prepend -root option value 
     1902 if (defined $CLI{root}) 
     1903 { 
     1904    $request{'whisker'}->{'uri'}    = $CLI{root} . $_[0];   # prepend -root option value 
     1905 } 
    18751906 $request{'whisker'}->{'method'} = $_[1]; 
    18761907 $request{'whisker'}->{'http_eol'}=$http_eol; 
     
    18801911 my $header_hash=$_[3]; 
    18811912 
    1882  if ($_[2] ne "") 
     1913 if (defined $_[2]) 
    18831914  {  
    18841915        my $r=$_[2]; 
     
    19271958 %TESTS = (); 
    19281959 $TARGETS{$CURRENT_HOST_ID}{total_checks}=0; 
    1929  my @SKIPLIST = split(/ /,$NIKTOCONFIG{SKIPIDS}); 
     1960 my @SKIPLIST=(); 
     1961 if (defined $NIKTOCONFIG{SKIPIDS}) 
     1962 { 
     1963    @SKIPLIST = split(/ /,$NIKTOCONFIG{SKIPIDS}); 
     1964 } 
    19301965   
    19311966 # now load checks 
     
    19421977      
    19431978   # check tuning options 
    1944    if (($CLI{tuning} ne "") && ($item[2] ne "")) 
     1979   if ((defined $CLI{tuning}) && (defined $item[2])) 
    19451980     { 
    19461981      if ($CLI{tuning} =~ /x/) 
     
    22582293         for (my $i=0; $i<=$#contents; $i++) 
    22592294         { 
    2260             $hashref->{@headers[$i]} = @contents[$i]; 
     2295            $hashref->{$headers[$i]} = $contents[$i]; 
    22612296         } 
    22622297         push(@dbarray, $hashref); 
Note: See TracChangeset for help on using the changeset viewer.