Class: Arachni::Module::Manager

Inherits:
ComponentManager show all
Includes:
Utilities, UI::Output
Defined in:
lib/arachni/module/manager.rb

Overview

Arachni::Module::Manager class

Holds and manages the modules and their results.

@author: Tasos “Zapotek” Laskos

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

@version: 0.1.1

Direct Known Subclasses

RPC::Server::Module::Manager

Constant Summary

Constants inherited from ComponentManager

ComponentManager::EXCLUDE, ComponentManager::WILDCARD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#exception_jail, #get_path, #hash_keys_to_str, #normalize_url, #read_file, #seed, #uri_decode, #uri_encode, #uri_parse, #uri_parser, #url_sanitize

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?

Methods inherited from ComponentManager

#[], #available, #load, #name_to_path, #parse, #path_to_name, #paths, #prep_opts, #wilcard_to_names

Constructor Details

#initialize(opts) ⇒ Manager

Returns a new instance of Manager.

Parameters:



46
47
48
49
# File 'lib/arachni/module/manager.rb', line 46

def initialize( opts )
    super( opts.dir['modules'], Arachni::Modules )
    @opts = opts
end

Class Method Details

.do_not_store!Object



82
83
84
# File 'lib/arachni/module/manager.rb', line 82

def self.do_not_store!
    @@do_not_store = true
end

.issue_setObject



123
124
125
126
127
# File 'lib/arachni/module/manager.rb', line 123

def self.issue_set
    @@issue_mutex.synchronize {
        @@issue_set
    }
end

.issue_set_id_from_elem(mod_name, elem) ⇒ Object



115
116
117
118
119
120
# File 'lib/arachni/module/manager.rb', line 115

def self.issue_set_id_from_elem( mod_name, elem )
    elem_url  = URI( elem.action )
    elem_url_str  = elem_url.scheme + "://" + elem_url.host + elem_url.path

    return "#{mod_name}:#{elem.type}:#{elem.altered}:#{elem_url_str}"
end

.issue_set_id_from_issue(issue) ⇒ Object



107
108
109
110
111
# File 'lib/arachni/module/manager.rb', line 107

def self.issue_set_id_from_issue( issue )
    issue_url = URI( issue.url )
    issue_url_str = issue_url.scheme + "://" + issue_url.host + issue_url.path
    return "#{issue.mod_name}:#{issue.elem}:#{issue.var}:#{issue_url_str}"
end

.on_register_results(&block) ⇒ Object



76
77
78
# File 'lib/arachni/module/manager.rb', line 76

def self.on_register_results( &block )
    @@on_register_results << block
end

.register_results(results) ⇒ Object

Class method

Registers module results with…well..us.

Parameters:



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/arachni/module/manager.rb', line 94

def self.register_results( results )

    @@on_register_results.each { |block| block.call( results ) }
    return if @@do_not_store


    @@issue_mutex.synchronize {
        @@results |= results
        results.each { |issue| @@issue_set << self.issue_set_id_from_issue( issue ) }
    }
end

.resultsObject

Class method

Gets module results

Parameters:



137
138
139
140
141
# File 'lib/arachni/module/manager.rb', line 137

def self.results
    @@issue_mutex.synchronize {
        @@results
    }
end

Instance Method Details

#do_not_store!Object



85
# File 'lib/arachni/module/manager.rb', line 85

def do_not_store!() self.class.do_not_store! end

#issue_setObject



128
# File 'lib/arachni/module/manager.rb', line 128

def issue_set() self.class.issue_set end

#issue_set_id_from_elem(mod_name, elem) ⇒ Object



121
# File 'lib/arachni/module/manager.rb', line 121

def issue_set_id_from_elem( mod_name, elem ) self.class.issue_set_id_from_elem( mod_name, elem ) end

#issue_set_id_from_issue(issue) ⇒ Object



112
# File 'lib/arachni/module/manager.rb', line 112

def issue_set_id_from_issue( issue ) self.class.issue_set_id_from_issue( issue ) end

#on_register_results(&block) ⇒ Object



79
# File 'lib/arachni/module/manager.rb', line 79

def on_register_results( &block ) self.class.on_register_results( &block ) end

#register_results(results) ⇒ Object



105
# File 'lib/arachni/module/manager.rb', line 105

def register_results( results ) self.class.register_results( results ) end

#resultsObject



142
# File 'lib/arachni/module/manager.rb', line 142

def results() self.class.results end

#run(page, framework = nil) ⇒ Object

Runs all modules against ‘page’.

Parameters:



57
58
59
# File 'lib/arachni/module/manager.rb', line 57

def run( page, framework = nil )
    keys.each { |mod| exception_jail( false ){ run_one( mod, page, framework ) } }
end

#run_one(mod, page, framework = nil) ⇒ Object

Runs a single module against ‘page’.

Parameters:



68
69
70
71
72
73
74
# File 'lib/arachni/module/manager.rb', line 68

def run_one( mod, page, framework = nil )
    mod_new = mod.new( page )
    mod_new.set_framework( framework ) if framework
    mod_new.prepare
    mod_new.run
    mod_new.clean_up
end