Changeset 449


Ignore:
Timestamp:
06/18/2010 01:39:41 AM (3 years ago)
Author:
sullo
Message:

Fix for #133: regular expression matching causes errors.
Removed char_escape and some other regexs in favor of the faster quotemeta().
Optimized rm_active_content() a little by shuffling code and reducing some mem copies/regexs. Needs more work.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/CHANGES.txt

    r442 r449  
     12010-06-17 
     2        - Fix for #133: regular expression matching causes errors. Removed char_escape and some other 
     3          regexs in favor of the faster quotemeta(). Also set many regexs to non-capturing for speed. 
     4        - Optimized rm_active_content() a little by shuffling code and reducing some mem copies/regexs. Needs more work. 
    152010-06-15 
    26        - Fix for #127: dav methods are treated specially and reported all at once 
  • trunk/plugins/nikto_apacheusers.plugin

    r392 r449  
    4848    (my $result, $content) = nfetch($mark, "/~root", "GET", "", "", "", "apacheusers: known user"); 
    4949 
    50     $content = char_escape($content); 
     50    $content = quotemeta($content); 
    5151    if ($content =~ /forbidden/i)    # good on "root" 
    5252    { 
     
    5454                                        "GET", "", "", "", "apacheusers: invalid user"); 
    5555 
    56         $content = char_escape($content); 
     56        $content = quotemeta($content); 
    5757        if ($content !~ /forbidden/i)    # Good, it gave an error instead of forbidden 
    5858        { 
  • trunk/plugins/nikto_core.plugin

    r447 r449  
    282282 
    283283    # Try to remove active content which could mess up the file's signature 
    284     my $cont = $_[0]; 
    285     my $file = $_[1]; 
    286  
    287     # filename 
    288     if ($file ne '') { 
    289         $file =~ s/([^a-zA-Z0-9\s])/\\$1/g; 
    290         $cont =~ s/$file//g; 
    291     } 
     284    my ($cont, $file) = @_; 
    292285 
    293286    # Dates 
     
    301294    # URI, if provided, plus encoded versions of it 
    302295    # $_[1] has unescaped file name, and $file has escaped. use appropriate one! 
    303     if (defined $file) { 
    304  
    305         # match pages which link to themselves w/diff args 
    306         my $e = $file; 
    307         $e    =~ s/^\/$file\??//; 
    308         $cont =~ s/$e//gs; 
    309  
    310         # again but with the index in place 
    311         $e = $file; 
    312         $cont =~ s/$e//gs; 
     296    if ($file ne '') { 
     297        $file = quotemeta($file); 
     298        $cont =~ s/$file//g; 
    313299 
    314300        # base 64 
    315         $e = LW2::encode_base64($_[1]); 
     301        my $e = LW2::encode_base64($_[1]); 
    316302        $cont =~ s/$e//gs; 
    317303 
     
    330316 
    331317        # url encoding, query portion 
    332         if ($file =~ /\?/) { 
    333             $e = $file; 
    334             $e =~ s/\?(.*$)//; 
    335             my $qs = $1; 
     318        if ($file =~ /\?(.*$)/) { 
     319            my $qs = $1; 
     320 
     321            # match pages which link to themselves w/diff args 
     322            $cont =~ s/$qs//gs; 
     323 
     324            # url encoded 
    336325            $qs =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; 
    337             $e .= "?$qs"; 
    338             $cont =~ s/$e//gs; 
     326            $cont =~ s/$qs//gs; 
    339327        } 
    340328    } 
     
    20262014                $db_extensions{$ext} = 1; 
    20272015 
    2028                 # This escapes regex characters in the conditionals.  
    2029                 # This will have to change if regex is ever allowed in the db 
    2030                 for (my $y = 5 ; $y <= 9 ; $y++) { $item[$y] =~ s/([^a-zA-Z0-9\s])/\\$1/g; } 
     2016                # Escape chars in the conditionals.  This must change if regexs are allowed in the db. 
     2017                for (my $y = 5 ; $y <= 9 ; $y++) { $item[$y] = quotemeta($item[$y]); } 
    20312018 
    20322019                $NIKTO{total_checks}++; 
     
    20582045sub max_test_id { 
    20592046    return (sort { $a <=> $b } keys %TESTS)[-1]; 
    2060 } 
    2061  
    2062 ####################################################################### 
    2063 sub char_escape { 
    2064     $_[0] =~ s/([^a-zA-Z0-9 ])/\\$1/g; 
    2065     return $_[0]; 
    20662047} 
    20672048 
  • trunk/plugins/nikto_robots.plugin

    r448 r449  
    4848        my @DOC = split(/\n/, $CONTENT); 
    4949        foreach my $line (@DOC) { 
    50             $line = char_escape($line); 
     50            $line = quotemeta($line); 
    5151            if ($line =~ /allow/i) 
    5252            { 
Note: See TracChangeset for help on using the changeset viewer.