Class: Arachni::Plugin::Base Abstract

Inherits:
Object
  • Object
show all
Includes:
Arachni, Component, Module::Output, Module::Utilities
Defined in:
lib/arachni/plugin/base.rb

Overview

This class is abstract.

An abstract class which all plugins must extend.

Author:

Constant Summary

Constants included from Arachni

BANNER, Cookie, Form, Header, Link, Severity, VERSION, WEBSITE, WIKI

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Module::Utilities

#read_file

Methods included from Utilities

#available_port, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #extract_domain, #follow_protocol?, #form_decode, #form_encode, #form_parse_request_body, #forms_from_document, #forms_from_response, #generate_token, #get_path, #html_decode, #html_encode, #include_path?, #links_from_document, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_query, #parse_set_cookie, #parse_url_vars, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #redundant_path?, #remove_constants, #seed, #skip_page?, #skip_path?, #skip_resource?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parser, #url_sanitize

Methods included from Module::Output

#fancy_name, #print_bad, #print_debug, #print_error, #print_info, #print_line, #print_ok, #print_status, #print_verbose

Methods included from UI::Output

#debug?, #debug_off, #debug_on, #disable_only_positives, #error_logfile, #flush_buffer, #log_error, #mute, #muted?, old_reset_output_options, #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?, reset_output_options, #set_buffer_cap, #set_error_logfile, #uncap_buffer, #unmute, #verbose, #verbose?

Methods included from Arachni

URI, profile?

Constructor Details

#initialize(framework, options) ⇒ Base

Returns a new instance of Base.

Parameters:



69
70
71
72
# File 'lib/arachni/plugin/base.rb', line 69

def initialize( framework, options )
    @framework = framework
    @options   = options
end

Instance Attribute Details

#frameworkObject (readonly)

Returns the value of attribute framework.



63
64
65
# File 'lib/arachni/plugin/base.rb', line 63

def framework
  @framework
end

#optionsObject (readonly)

Returns the value of attribute options.



62
63
64
# File 'lib/arachni/plugin/base.rb', line 62

def options
  @options
end

Class Method Details

.distributableObject

Should the plug-in be distributed across all instances or only run by the master prior to any distributed operations?



112
113
114
# File 'lib/arachni/plugin/base.rb', line 112

def self.distributable
    @distributable = true
end

.distributable?Boolean

OPTIONAL

Only used when in Grid mode.

Should the plug-in be distributed across all instances or only run by the master prior to any distributed operations?

For example, if a plug-in dynamically modifies the framework options in any way and wants these changes to be identical across instances this method should return ‘false’.

Returns:

  • (Boolean)


105
106
107
# File 'lib/arachni/plugin/base.rb', line 105

def self.distributable?
    @distributable ||= false
end

.gemsArray

Should return an array of plugin related gem dependencies.

Returns:



138
139
140
# File 'lib/arachni/plugin/base.rb', line 138

def self.gems
    []
end

.infoObject

REQUIRED

Do not omit any of the info.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/arachni/plugin/base.rb', line 147

def self.info
    {
        name:        'Abstract plugin class',
        description: %q{Abstract plugin class.},
        author:      'Tasos "Zapotek" Laskos <[email protected]>',
        version:     '0.1',
        options:     [
            #                       option name        required?       description                        default
            # Options::Bool.new( 'print_framework', [ false, 'Do you want to print the framework?', false ] ),
            # Options::String.new( 'my_name_is',    [ false, 'What\'s you name?', 'Tasos' ] ),
        ],
        # specify an execution priority group
        # plug-ins will be separated in groups based on this number
        # and lowest will be first
        #
        # if this option is omitted the plug-in will be run last
        #
        priority:    0
    }
end

.is_distributableObject

Should the plug-in be distributed across all instances or only run by the master prior to any distributed operations?



118
119
120
# File 'lib/arachni/plugin/base.rb', line 118

def self.is_distributable
    distributable
end

.merge(results) ⇒ Object

REQUIRED IF self.distributable? returns ‘true’ and the plugins stores results.

Only used when in Grid mode.

Merges an array of results as gathered by the plug-in when run by multiple instances.



130
131
# File 'lib/arachni/plugin/base.rb', line 130

def self.merge( results )
end

.synchronize(&block) ⇒ Object

Provides plugin-wide synchronization.



190
191
192
# File 'lib/arachni/plugin/base.rb', line 190

def self.synchronize( &block )
    (@mutex ||= Mutex.new).synchronize( &block )
end

Instance Method Details

#clean_upObject

OPTIONAL



89
90
# File 'lib/arachni/plugin/base.rb', line 89

def clean_up
end

#httpObject



176
177
178
# File 'lib/arachni/plugin/base.rb', line 176

def http
    framework.http
end

#http_runObject

Provides a thread-safe way to run the queued HTTP requests.



183
184
185
# File 'lib/arachni/plugin/base.rb', line 183

def http_run
    synchronize { http.run }
end

#prepareObject

OPTIONAL



77
78
# File 'lib/arachni/plugin/base.rb', line 77

def prepare
end

#register_results(results) ⇒ Object

Registers the plugin’s results with the framework.

Parameters:



202
203
204
# File 'lib/arachni/plugin/base.rb', line 202

def register_results( results )
    framework.plugins.register_results( self, results )
end

#runObject

REQUIRED



83
84
# File 'lib/arachni/plugin/base.rb', line 83

def run
end

#sessionObject



172
173
174
# File 'lib/arachni/plugin/base.rb', line 172

def session
    framework.session
end

#spiderObject



168
169
170
# File 'lib/arachni/plugin/base.rb', line 168

def spider
    framework.spider
end

#synchronize(&block) ⇒ Object



193
194
195
# File 'lib/arachni/plugin/base.rb', line 193

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

#wait_while_framework_runningObject

Will block until the scan finishes.



209
210
211
# File 'lib/arachni/plugin/base.rb', line 209

def wait_while_framework_running
    ::IO.select( nil, nil, nil, 1 ) while( framework.running? )
end