<commit_before>=begin
  $Id$

                  Arachni
  Copyright (c) 2010 <NAME> <<EMAIL>>

  This is free software; you can copy and distribute and modify
  this program under the term of the GPL v2.0 License
  (See LICENSE file for details)

=end

module Arachni

module Modules
module Recon
  
#
# Common directories discovery module.
#
# Looks for common, possibly sensitive, directories on the server. 
#
# @author: Anastasios "Zapotek" Laskos
#                                      <<EMAIL>>
#                                      <<EMAIL>>
# @version: $Rev: 385 $
#
# @see http://cwe.mitre.org/data/definitions/538.html
#
#
class CommonDirectories < Arachni::Module::Base

    # register us with the system
    include Arachni::Module::Registrar
    
    include Arachni::Module::Utilities
    
    def initialize( page )
        super( page )

        @__common_directories = 'directories.txt' 
 
        # to keep track of the requests and not repeat them
        @@__audited ||= []
        @results   = []
    end

    def run( )

        print_status( "Scanning..." )

        # ugly crap but it works, as far as I can tell...
        path = Module::Utilities.get_path( @page.url )
        
        get_data_file( @__common_directories ) {
            |dirname|
            
            url  = path + dirname + '/'
            
            next if @@__audited.include?( url )
            print_debug( "Checking for #{url}" )
            
            res  = @http.get( url )
            @@__audited << url

            __log_results( res, dirname, url ) if( res.code == "200" )
        }

        
        # register our results with the system
        register_results( @results )
    end

    
    def self.info
        {
            'Name'           => 'CommonDirectories',
            'Description'    => %q{Tries to find common directories on the server.},
            'Elements'       => [ ],
            'Author'         => 'zapotek',
            'Version'        => '$Rev: 385 $',
            'References'     => {},
            'Targets'        => { 'Generic' => 'all' },
                
            'Vulnerability'   => {
                'Name'        => %q{A common directory exists on the server.},
                'Description' => %q{},
                'CWE'         => '538',
                'Severity'    => Vulnerability::Severity::MEDIUM,
                'CVSSV2'       => '',
                'Remedy_Guidance'    => '',
                'Remedy_Code' => '',
            }

        }
    end
    
    #
    # Adds a vulnerability to the @results array<br/>
    # and outputs an "OK" message with the dirname and its url.
    #
    # @param  [Net::HTTPResponse]  res   the HTTP response
    # @param  [String]  dirname   the discovered dirname 
    # @param  [String]  url   the url of the discovered file
    #
    def __log_results( res, dirname, url )
        
        # append the result to the results hash
        @results << Vulnerability.new( {
            'var'          => 'n/a',
            'url'          => url,
            'injected'     => dirname,
            'id'           => dirname,
            'regexp'       => 'n/a',
            'regexp_match' => 'n/a',
            'elem'         => Vulnerability::Element::LINK,
            'response'     => res.body,
            'headers'      => {
                'request'    => 'n/a',
                'response'   => 'n/a',    
            }
        }.merge( self.class.info ) )
                
        # inform the user that we have a match
        print_ok( "Found #{dirname} at\t" + url )
    end

end
end
end
end
<commit_msg>common_directories: removed "include Arachni::Module::Utilities", it was redundant<commit_after>=begin
  $Id$

                  Arachni
  Copyright (c) 2010 <NAME> <<EMAIL>>

  This is free software; you can copy and distribute and modify
  this program under the term of the GPL v2.0 License
  (See LICENSE file for details)

=end

module Arachni

module Modules
module Recon
  
#
# Common directories discovery module.
#
# Looks for common, possibly sensitive, directories on the server. 
#
# @author: Anastasios "Zapotek" Laskos
#                                      <<EMAIL>>
#                                      <<EMAIL>>
# @version: $Rev: 385 $
#
# @see http://cwe.mitre.org/data/definitions/538.html
#
#
class CommonDirectories < Arachni::Module::Base

    # register us with the system
    include Arachni::Module::Registrar
    
    def initialize( page )
        super( page )

        @__common_directories = 'directories.txt' 
 
        # to keep track of the requests and not repeat them
        @@__audited ||= []
        @results   = []
    end

    def run( )

        print_status( "Scanning..." )

        # ugly crap but it works, as far as I can tell...
        path = Module::Utilities.get_path( @page.url )
        
        get_data_file( @__common_directories ) {
            |dirname|
            
            url  = path + dirname + '/'
            
            next if @@__audited.include?( url )
            print_debug( "Checking for #{url}" )
            
            res  = @http.get( url )
            @@__audited << url

            __log_results( res, dirname, url ) if( res.code == "200" )
        }

        
        # register our results with the system
        register_results( @results )
    end

    
    def self.info
        {
            'Name'           => 'CommonDirectories',
            'Description'    => %q{Tries to find common directories on the server.},
            'Elements'       => [ ],
            'Author'         => 'zapotek',
            'Version'        => '$Rev: 385 $',
            'References'     => {},
            'Targets'        => { 'Generic' => 'all' },
                
            'Vulnerability'   => {
                'Name'        => %q{A common directory exists on the server.},
                'Description' => %q{},
                'CWE'         => '538',
                'Severity'    => Vulnerability::Severity::MEDIUM,
                'CVSSV2'       => '',
                'Remedy_Guidance'    => '',
                'Remedy_Code' => '',
            }

        }
    end
    
    #
    # Adds a vulnerability to the @results array<br/>
    # and outputs an "OK" message with the dirname and its url.
    #
    # @param  [Net::HTTPResponse]  res   the HTTP response
    # @param  [String]  dirname   the discovered dirname 
    # @param  [String]  url   the url of the discovered file
    #
    def __log_results( res, dirname, url )
        
        # append the result to the results hash
        @results << Vulnerability.new( {
            'var'          => 'n/a',
            'url'          => url,
            'injected'     => dirname,
            'id'           => dirname,
            'regexp'       => 'n/a',
            'regexp_match' => 'n/a',
            'elem'         => Vulnerability::Element::LINK,
            'response'     => res.body,
            'headers'      => {
                'request'    => 'n/a',
                'response'   => 'n/a',    
            }
        }.merge( self.class.info ) )
                
        # inform the user that we have a match
        print_ok( "Found #{dirname} at\t" + url )
    end

end
end
end
end

{'fraction_non_alphanumeric': 0.11693492915118998, 'fraction_numerical': 0.006053102214885128, 'mean_word_length': 1.404100529100529, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3205339', 'n_tokens_mistral': 2177, 'n_tokens_neox': 2074, 'n_words': 576}