Changeset 624


Ignore:
Timestamp:
02/13/2011 03:38:16 AM (2 years ago)
Author:
sullo
Message:
  • Tickets 202, 203: Rewrote set_targets to not accidentally collapse targets, which fixed terminate signal issues
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/CHANGES.txt

    r623 r624  
    99                - Properly close <niktoscan> 
    1010                - Incremented nxmlversion to 1.1 
     11        - Tickets 202, 203: Rewrote set_targets to not accidentally collapse targets, which fixed terminate signal issues 
    1112        - Ticket 201: Rewritten & fixed authorization code work better and make fewer requests 
    1213        - Ticket 195: Update interactive status counts if mutate options are used 
  • trunk/plugins/nikto_core.plugin

    r623 r624  
    898898    my $host_ctr = 1; 
    899899    my @hosts    = split(/,/, $hostlist); 
    900     my @ports    = split(/,/, $portlist) if defined $portlist; 
    901     my (@checkhosts, @results, @marks); 
    902     my $defaultport = ($ssl) ? 443 : 80; 
    903  
    904     # Check for old style portlist and expand 
    905     my @newports; 
    906     foreach my $port (@ports) { 
     900    my @tempports    = split(/,/, $portlist) if defined $portlist; 
     901    my (@ports, @checkhosts, @results, @marks); 
     902 
     903    nprint("- Getting targets", "v"); 
     904 
     905    # Check for portlist and expand 
     906    foreach my $port (@tempports) { 
    907907        if ($port =~ /-/) { 
    908908            my ($start, $end); 
     
    917917            } 
    918918            for (my $i = $start ; $i <= $end ; $i++) { 
    919                 push(@newports, $i); 
     919                push(@ports, $i); 
    920920            } 
    921921        } 
    922922        else { 
    923             push(@newports, $port); 
    924         } 
    925     } 
    926     @ports = @newports; 
    927  
    928     nprint("- Getting targets", "v"); 
    929     if (scalar(@ports) == 1) { 
    930  
    931         # Only one port is set, assume that as the default port 
    932         $defaultport = $ports[0]; 
    933     } 
    934  
    935     # check whether it's a file or an entry 
     923            push(@ports, $port); 
     924        } 
     925    } 
     926 
     927    # no ports explicitly set, so use default port 
     928    if (scalar(@ports) == 0) { 
     929        push(@ports, $defaultport); 
     930        } 
     931 
     932    # check whether -h is a file or an entry 
    936933    foreach my $host (@hosts) { 
    937934        if (-e $host || $host eq "-") { 
     
    944941    } 
    945942 
    946     # Now parse the list of checkhosts 
     943    # Now parse the list of checkhosts, store in %targs by host:port 
     944    my $targs={}; 
    947945    foreach my $host (@checkhosts) { 
    948         my $defhost; 
    949         my $defport; 
    950946        $host =~ s/\s+//g; 
    951947        if (!defined $host) { next; } 
    952         my $markhash = {}; 
    953  
    954         if ($root ne '') {  
    955             $markhash->{'root'} = $root; 
    956             nprint("- Added -root value of '$root' from CLI", "v"); 
    957             } 
     948        my ($defhost, $defport)=''; 
    958949 
    959950        # is it a URL? 
     
    963954            $defhost = $hostdata[2]; 
    964955            $defport = $hostdata[3]; 
     956            $targs{$defhost . ":" . $defport}= ($root ne "") ? $root : '/'; 
    965957 
    966958           if (($hostdata[0] ne '/') && ($hostdata[0] ne '') && ($root eq '')) { 
    967                 $markhash->{'root'} = $hostdata[0]; 
     959                $targs{$defhost . ":" . $defport}= $hostdata[0]; 
    968960                nprint("- Added -root value of '$hostdata[0]' from URI", "v"); 
    969961            } 
     
    971963        else { 
    972964            my @h = split(/\:|\,/, $host); 
    973  
    974965            $defhost = $h[0]; 
    975966            $defport = $h[1]; 
    976         } 
    977  
    978         # Now skip through all ports if port hasn't been added 
    979         if ($defport eq "" && scalar(@ports) > 0) { 
    980  
    981             foreach $port (@ports) { 
    982                 $markhash->{'ident'} = $defhost; 
     967            $targs{$defhost . ":" . $defport} = ($root ne "") ? $root : '/';  
     968        } 
     969} 
     970 
     971foreach my $host (keys %targs) {  
     972        my ($h, $p) = split(/:/, $host); 
     973        if ($p eq '') {  
     974            foreach my $port (@ports) { 
     975                my $markhash = {}; 
     976                if ($root ne '') { $markhash->{'root'} = $root; nprint("- Added -root value of '$root' from CLI", "v"); } 
     977 
     978                $markhash->{'ident'} = $h; 
    983979                $markhash->{'port'}  = $port; 
     980                if ($targs{$host} ne '/') { $markhash->{'root'} = $targs{$host}; } 
    984981                nprint("- Target:$markhash->{'ident'} port:$markhash->{'port'}", "v", $markhash); 
    985982                push(@marks, $markhash); 
    986             } 
    987         } 
    988         else { 
    989             if ($defport eq "") { 
    990                 $defport = $defaultport; 
    991             } 
    992             $markhash->{'ident'} = $defhost; 
    993             $markhash->{'port'}  = $defport; 
    994  
    995             nprint("- Target:$markhash->{'ident'} port:$markhash->{'port'}", "v", $markhash); 
    996             push(@marks, $markhash); 
    997         } 
    998     } 
     983                } 
     984            } 
     985        else { 
     986                my $markhash = {}; 
     987                if ($targs{$host} ne '/') { $markhash->{'root'} = $targs{$host}; } 
     988 
     989                $markhash->{'ident'} = $h; 
     990                $markhash->{'port'}  = $p; 
     991                push(@marks, $markhash); 
     992                } 
     993        } 
    999994 
    1000995    return @marks; 
     
    20622057sub nfetch { 
    20632058    my ($mark, $uri, $method, $data, $headers, $flags, $testid) = @_; 
    2064     sleeper(); 
    20652059    my (%request, %result); 
    20662060    setup_hash(\%request, $mark, $testid); 
     
    21092103 
    21102104    if (!$incache) { 
     2105        sleeper(); 
    21112106        LW2::http_do_request_timeout(\%request, \%result); 
    21122107        $COUNTERS{'totalrequests'}++; 
     
    21142109        # If we got an error, do 1 retry. This should be much more intelligent and configurable! 
    21152110        if (defined $result{'whisker'}->{'error'} || $result{'whisker'}{'code'} eq '') { 
     2111                sleeper(); 
    21162112                LW2::http_do_request_timeout(\%request, \%result); 
    21172113                $COUNTERS{'totalrequests'}++; 
Note: See TracChangeset for help on using the changeset viewer.