Class: Arachni::Modules::Audit::SQLInjection

Inherits:
Arachni::Module::Base show all
Includes:
Arachni::Module::Registrar, Arachni::UI::Output
Defined in:
modules/audit/sqli.rb

Overview

SQL Injection recon module.
It audits links, forms and cookies.

@author: Anastasios “Zapotek” Laskos

                                     <tasos.laskos@gmail.com>
                                     <zapotek@segfault.gr>

@version: $Rev: 371 $

See Also:

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Arachni::Module::Registrar

#add_storage, #get_storage, #get_store, included, #register_results

Methods included from Arachni::UI::Output

#debug!, #debug?, #only_positives!, #only_positives?, #print_debug, #print_debug_backtrace, #print_debug_pp, #print_error, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #verbose!, #verbose?

Methods inherited from Arachni::Module::Base

#clean_up, deps, #get_cookie_simple, #get_cookies, #get_cookies_simple, #get_data_file, #get_form_simple, #get_forms, #get_forms_simple, #get_links, #get_links_simple, #get_request_headers, #get_response_headers

Methods included from Arachni::Module::Auditor

#audit_cookies, #audit_forms, #audit_headers, #audit_links, #get_matches, #inject_each_var

Methods included from Arachni::Module::Trainer

#train

Methods included from Arachni::Module::ElementDB

#init_cookies, #init_forms, #init_links, #update_cookies, #update_forms, #update_links, #work_on_cookies, #work_on_forms, #work_on_links

Constructor Details

- (SQLInjection) initialize(page)

A new instance of SQLInjection



41
42
43
44
45
46
47
48
49
50
# File 'modules/audit/sqli.rb', line 41

def initialize( page )
    super( page )

    # initialize variables 
    @__id = []
    @__injection_strs = []
    
    # initialize the results hash
    @results = []
end

Class Method Details

+ (Object) info



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'modules/audit/sqli.rb', line 109

def self.info
    {
        'Name'           => 'SQLInjection',
        'Description'    => %q{SQL injection recon module},
        'Elements'       => [
            Vulnerability::Element::FORM,
            Vulnerability::Element::LINK,
            Vulnerability::Element::COOKIE
        ],
        'Author'         => 'zapotek',
        'Version'        => '$Rev: 371 $',
        'References'     => {
            'UnixWiz'    => 'http://unixwiz.net/techtips/sql-injection.html',
            'Wikipedia'  => 'http://en.wikipedia.org/wiki/SQL_injection',
            'SecuriTeam' => 'http://www.securiteam.com/securityreviews/5DP0N1P76E.html',
            'OWASP'      => 'http://www.owasp.org/index.php/SQL_Injection'
        },
        'Targets'        => { 'Generic' => 'all' },
            
        'Vulnerability'   => {
            'Name'        => %q{SQL Injection},
            'Description' => %q{SQL code can be injected into the web application.},
            'CWE'         => '89',
            'Severity'    => Vulnerability::Severity::HIGH,
            'CVSSV2'       => '9.0',
            'Remedy_Guidance'    => '',
            'Remedy_Code' => '',
        }

    }
end

Instance Method Details

- (Object) prepare



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'modules/audit/sqli.rb', line 52

def prepare( )
    
    #
    # it's better to save big arrays to a file
    # a big array is ugly, messy and can't be updated as easily
    #
    # but don't open the file yourself, use get_data_file( filename )
    # with a block and read each line
    #
    # keep your files under modules/<modtype>/<modname>/
    #
    @__regexp_ids_file = 'regexp_ids.txt'
    
    # prepare the strings that will hopefully cause the webapp
    # to output SQL error messages
    @__injection_strs = [
        '\'',
        '--',
        ';',
        '`'
    ]
    
end

- (Object) run



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'modules/audit/sqli.rb', line 76

def run( )
    
    # iterate through the regular expression strings
    @__injection_strs.each {
        |str|
        
        # send the bad characters in @__injection_strs via the page forms
        # and pass a block that will check for a positive result
        audit_forms( str ) {
            |url, res, var|
            __log_results( Vulnerability::Element::FORM, var, res, str, url )
        }
        
        # send the bad characters in @__injection_strs via link vars
        # and pass a block that will check for a positive result        
        audit_links( str ) {
            |url, res, var|
            __log_results( Vulnerability::Element::LINK, var, res, str, url )
        }
                
        # send the bad characters in @__injection_strs via cookies
        # and pass a block that will check for a positive result
        audit_cookies( str ) {
            |url, res, var|
            __log_results( Vulnerability::Element::COOKIE, var, res, str, url )
        }
    }
    
    # register our results with the framework
    register_results( @results )
end