Class: Arachni::Plugin::Base Abstract
- Inherits:
-
Component::Base
- Object
- Component::Base
- Arachni::Plugin::Base
- Includes:
- Component, MonitorMixin
- Defined in:
- lib/arachni/plugin/base.rb
Overview
An abstract class which all plugins must extend.
Constant Summary
Constants included from Arachni
BANNER, Cookie, Form, Header, JSON, Link, LinkTemplate, Severity, VERSION, WEBSITE, WIKI, XML
Instance Attribute Summary collapse
- #framework ⇒ Framework readonly
-
#options ⇒ Hash
readonly
Plugin options.
Class Method Summary collapse
-
.distributable ⇒ Object
Should the plug-in be distributed across all instances or only run by the master prior to any distributed operations?.
-
.distributable? ⇒ Boolean
Only used when in Grid mode.
-
.gems ⇒ Array
Should return an array of plugin related gem dependencies.
-
.info ⇒ Hash
abstract
REQUIRED.
-
.is_distributable ⇒ Object
Should the plug-in be distributed across all instances or only run by the master prior to any distributed operations?.
-
.merge(results) ⇒ Object
Merges an array of results as gathered by the plug-in when ran by multiple instances.
Instance Method Summary collapse
- #browser_cluster ⇒ Object
-
#clean_up ⇒ Object
abstract
Gets called right after #run and is used for generic clean-up.
-
#framework_abort ⇒ Object
Aborts the #framework.
-
#framework_pause ⇒ Object
Pauses the #framework.
-
#framework_resume ⇒ Object
Resumes the #framework.
- #http ⇒ Object
- #info ⇒ Object
-
#initialize(framework, options) ⇒ Base
constructor
A new instance of Base.
-
#prepare ⇒ Object
abstract
Gets called right after the plugin is initialized and is used to prepare its data or setup hooks.
-
#register_results(results) ⇒ Object
Registers the plugin’s results to Data::Plugins.
-
#restore(state = nil) ⇒ Object
abstract
Gets called instead of #prepare when restoring a suspended plugin.
-
#run ⇒ Object
abstract
Gets called right after #prepare and delivers the plugin payload.
- #session ⇒ Object
- #suspend ⇒ Object abstract
-
#wait_while_framework_running ⇒ Object
Will block until the scan finishes.
- #with_browser(&block) ⇒ Object
Methods inherited from Component::Base
author, description, fullname, #shortname, shortname, shortname=, version
Methods included from Component::Utilities
Methods included from Utilities
#available_port, #bytes_to_kilobytes, #bytes_to_megabytes, #caller_name, #caller_path, #cookie_decode, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #follow_protocol?, #form_decode, #form_encode, #forms_from_document, #forms_from_response, #full_and_absolute_url?, #generate_token, #get_path, #hms_to_seconds, #html_decode, #html_encode, #include_path?, #links_from_document, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_set_cookie, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #random_seed, #redundant_path?, #regexp_array_match, #remove_constants, #request_parse_body, #seconds_to_hms, #skip_page?, #skip_path?, #skip_resource?, #skip_response?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parse_query, #uri_parser, #uri_rewrite
Methods included from Component::Output
#depersonalize_output, #depersonalize_output?, #intercept_print_message
Methods included from UI::Output
#debug?, #debug_off, #debug_on, #disable_only_positives, #included, #mute, #muted?, #only_positives, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_level_1, #print_debug_level_2, #print_debug_level_3, #print_error, #print_error_backtrace, #print_exception, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?, reset_output_options, #unmute, #verbose?, #verbose_on
Methods included from Arachni
URI, jruby?, null_device, profile?, windows?
Constructor Details
#initialize(framework, options) ⇒ Base
Returns a new instance of Base.
32 33 34 35 |
# File 'lib/arachni/plugin/base.rb', line 32 def initialize( framework, ) @framework = framework @options = end |
Instance Attribute Details
#framework ⇒ Framework (readonly)
27 28 29 |
# File 'lib/arachni/plugin/base.rb', line 27 def framework @framework end |
#options ⇒ Hash (readonly)
Returns Plugin options.
24 25 26 |
# File 'lib/arachni/plugin/base.rb', line 24 def @options end |
Class Method Details
.distributable ⇒ Object
Should the plug-in be distributed across all instances or only run by the master prior to any distributed operations?
127 128 129 |
# File 'lib/arachni/plugin/base.rb', line 127 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`.
121 122 123 |
# File 'lib/arachni/plugin/base.rb', line 121 def self.distributable? @distributable ||= false end |
.gems ⇒ Array
Should return an array of plugin related gem dependencies.
148 149 150 |
# File 'lib/arachni/plugin/base.rb', line 148 def self.gems [] end |
.info ⇒ Hash
REQUIRED
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/arachni/plugin/base.rb', line 156 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_distributable ⇒ Object
Should the plug-in be distributed across all instances or only run by the master prior to any distributed operations?
133 134 135 |
# File 'lib/arachni/plugin/base.rb', line 133 def self.is_distributable distributable end |
.merge(results) ⇒ Object
REQUIRED if distributable? returns ‘true` and the plugin registers results.
Merges an array of results as gathered by the plug-in when ran by multiple instances.
142 143 |
# File 'lib/arachni/plugin/base.rb', line 142 def self.merge( results ) end |
Instance Method Details
#browser_cluster ⇒ Object
188 189 190 |
# File 'lib/arachni/plugin/base.rb', line 188 def browser_cluster framework.browser_cluster end |
#clean_up ⇒ Object
OPTIONAL
Gets called right after #run and is used for generic clean-up.
78 79 |
# File 'lib/arachni/plugin/base.rb', line 78 def clean_up end |
#framework_abort ⇒ Object
Aborts the #framework.
99 100 101 102 103 |
# File 'lib/arachni/plugin/base.rb', line 99 def framework_abort Thread.new do framework.abort end end |
#framework_pause ⇒ Object
Pauses the #framework.
94 95 96 |
# File 'lib/arachni/plugin/base.rb', line 94 def framework_pause @pause_id ||= framework.pause end |
#framework_resume ⇒ Object
Resumes the #framework.
106 107 108 109 |
# File 'lib/arachni/plugin/base.rb', line 106 def framework_resume return if !@pause_id framework.resume @pause_id end |
#http ⇒ Object
184 185 186 |
# File 'lib/arachni/plugin/base.rb', line 184 def http framework.http end |
#info ⇒ Object
176 177 178 |
# File 'lib/arachni/plugin/base.rb', line 176 def info self.class.info end |
#prepare ⇒ Object
OPTIONAL
Gets called right after the plugin is initialized and is used to prepare its data or setup hooks.
This method should not block as the system will wait for it to return prior to progressing.
46 47 |
# File 'lib/arachni/plugin/base.rb', line 46 def prepare end |
#register_results(results) ⇒ Object
Registers the plugin’s results to Data::Plugins.
199 200 201 |
# File 'lib/arachni/plugin/base.rb', line 199 def register_results( results ) Data.plugins.store( self, results ) end |
#restore(state = nil) ⇒ Object
58 59 |
# File 'lib/arachni/plugin/base.rb', line 58 def restore( state = nil ) end |
#run ⇒ Object
REQUIRED
Gets called right after #prepare and delivers the plugin payload.
This method will be ran in its own thread, in parallel to any other system operation. However, once its job is done, the system will wait for this method to return prior to exiting.
70 71 |
# File 'lib/arachni/plugin/base.rb', line 70 def run end |
#session ⇒ Object
180 181 182 |
# File 'lib/arachni/plugin/base.rb', line 180 def session framework.session end |
#wait_while_framework_running ⇒ Object
Will block until the scan finishes.
204 205 206 |
# File 'lib/arachni/plugin/base.rb', line 204 def wait_while_framework_running sleep 0.1 while framework.running? end |
#with_browser(&block) ⇒ Object
192 193 194 |
# File 'lib/arachni/plugin/base.rb', line 192 def with_browser( &block ) browser_cluster.with_browser( &block ) end |