Class: Arachni::Module::Base Abstract

Inherits:
Object
  • Object
show all
Includes:
Auditor, Output
Defined in:
lib/arachni/module/base.rb

Overview

This class is abstract.

Arachni’s base module class<br/> To be extended by Arachni::Modules.

Defines basic structure and provides utilities to modules.

@author: Tasos “Zapotek” Laskos

<[email protected]>
<[email protected]>

@version: 0.2

Constant Summary

Constants included from Auditor

Auditor::OPTIONS, Auditor::RDIFF_OPTIONS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Auditor

#__rdiff_audit_id, #__rdiff_audited!, #__rdiff_audited?, add_timeout_audit_block, add_timeout_candidate, #audit, #audit_elems, #audit_rdiff, #audit_rdiff_elem, #audit_timeout, #audit_timeout_debug_msg, audit_timeout_phase_2, audit_timeout_stabilize, #call_on_timing_blocks, call_on_timing_blocks, current_timeout_audit_operations_cnt, included, #log, #log_issue, #log_remote_file, #log_remote_file_if_exists, #match_and_log, #method_missing, on_timing_attacks, #override_instance_scope?, #redundant, #register_results, #remote_file_exist?, running_timeout_attacks?, #skip?, timeout_audit_blocks, timeout_audit_operations_cnt, timeout_audit_run, timeout_loaded_modules, #timing_attack

Methods included from Output

#o_print_bad, #o_print_debug, #o_print_error, #o_print_info, #o_print_line, #o_print_ok, #o_print_status, #o_print_verbose, #print_bad, #print_debug, #print_error, #print_info, #print_line, #print_ok, #print_status, #print_verbose

Methods included from UI::Output

#buffer, #debug!, #debug?, #flush_buffer, #mute!, #muted?, #only_positives!, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_pp, #print_error, #print_error_backtrace, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?, #uncap_buffer!, #unmute!, #verbose!, #verbose?

Constructor Details

#initialize(page) ⇒ Base

Initializes the module attributes, HTTP client and Trainer

Parameters:

  • page (Page)

See Also:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/arachni/module/base.rb', line 62

def initialize( page )

    @page  = page
    @http  = Arachni::HTTP.instance
    @http.trainer.set_page( @page )

    # update the cookies
    if( !@page.cookiejar.empty? )
        @http.update_cookies( @page.cookiejar )
    end

    #
    # This is slightly tricky...
    #
    # Each loaded module is instantiated for each page,
    # however modules share the elements of each page and access them
    # via the ElementsDB.
    #
    # Since the ElementDB is dynamically updated by the Trainer
    # during the audit, is should only be initialized *once*
    # for each page and not overwritten every single time a module is instantiated.
    #
    @@__last_url ||= ''
    if( @@__last_url != @page.url )
        @http.trainer.page = @page.dup
        @http.trainer.init_forms( @page.forms )
        @http.trainer.init_links( @page.links )
        @http.trainer.init_cookies( @page.cookies )
        @@__last_url = @page.url
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Arachni::Module::Auditor

Instance Attribute Details

#httpArachni::Module::HTTP (readonly)

Arachni::HTTP instance for the modules

Returns:

  • (Arachni::Module::HTTP)


45
46
47
# File 'lib/arachni/module/base.rb', line 45

def http
  @http
end

#pagePage (readonly)

Arachni::Page instance

Returns:

  • (Page)


52
53
54
# File 'lib/arachni/module/base.rb', line 52

def page
  @page
end

Class Method Details

.infoObject

ABSTRACT - REQUIRED

Provides information about the module. Don’t take this lightly and don’t ommit any of the info.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/arachni/module/base.rb', line 131

def self.info
    {
        :name           => 'Base module abstract class',
        :description    => %q{Provides an abstract class the modules should implement.},
        #
        # Arachni needs to know what elements the module plans to audit
        # before invoking it.
        # If a page doesn't have any of those elements
        # there's no point in instantiating the module.
        #
        # If you want the module to run no-matter what leave the array
        # empty.
        #
        # 'Elements'       => [
        #     Issue::Element::FORM,
        #     Issue::Element::LINK,
        #     Issue::Element::COOKIE,
        #     Issue::Element::HEADER
        # ],
        :elements       => [],
        :author         => 'zapotek',
        :version        => '0.1',
        :references     => {
        },
        :targets        => { 'Generic' => 'all' },
        :issue   => {
            :description => %q{},
            :cwe         => '',
            #
            # Severity can be:
            #
            # Issue::Severity::HIGH
            # Issue::Severity::MEDIUM
            # Issue::Severity::LOW
            # Issue::Severity::INFORMATIONAL
            #
            :severity    => '',
            :cvssv2       => '',
            :remedy_guidance    => '',
            :remedy_code => '',
        }
    }
end

Instance Method Details

#clean_upObject

ABSTRACT - OPTIONAL

This is called after run() has finished executing,



115
116
# File 'lib/arachni/module/base.rb', line 115

def clean_up
end

#frameworkObject

Returns the framework.



121
122
123
# File 'lib/arachni/module/base.rb', line 121

def framework
    @framework
end

#prepareObject

ABSTRACT - OPTIONAL

It provides you with a way to setup your module’s data and methods.



99
100
# File 'lib/arachni/module/base.rb', line 99

def prepare
end

#runObject

ABSTRACT - REQUIRED

This is used to deliver the module’s payload whatever it may be.



107
108
# File 'lib/arachni/module/base.rb', line 107

def run
end

#set_framework(framework) ⇒ Object



175
176
177
# File 'lib/arachni/module/base.rb', line 175

def set_framework( framework )
    @framework = framework
end