class Arachni::Plugin::Base

An abstract class which all plugins must extend.

@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com> @abstract

Attributes

framework[R]

@return [Framework]

options[R]

@return [Hash]

Plugin options.

Public Class Methods

distributable() click to toggle source

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

# File lib/arachni/plugin/base.rb, line 127
def self.distributable
    @distributable = true
end
distributable?() click to toggle source

@note 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`.

# File lib/arachni/plugin/base.rb, line 121
def self.distributable?
    @distributable ||= false
end
gems() click to toggle source

Should return an array of plugin related gem dependencies.

@return [Array]

# File lib/arachni/plugin/base.rb, line 148
def self.gems
    []
end
info() click to toggle source

REQUIRED

@return [Hash] @abstract

# File lib/arachni/plugin/base.rb, line 156
def self.info
    {
        name:        'Abstract plugin class',
        description: %q{Abstract plugin class.},
        author:      'Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>',
        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() click to toggle source

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

# File lib/arachni/plugin/base.rb, line 133
def self.is_distributable
    distributable
end
merge( results ) click to toggle source

@note REQUIRED if {.distributable?} returns ‘true` and the plugin

{#register_results registers results}.

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

# File lib/arachni/plugin/base.rb, line 142
def self.merge( results )
end
new( framework, options ) click to toggle source

@param [Framework] framework @param [Hash] options

Options to pass to the plugin.
# File lib/arachni/plugin/base.rb, line 32
def initialize( framework, options )
    @framework = framework
    @options   = options
end

Public Instance Methods

browser_cluster() click to toggle source
# File lib/arachni/plugin/base.rb, line 188
def browser_cluster
    framework.browser_cluster
end
clean_up() click to toggle source

@note OPTIONAL

Gets called right after {#run} and is used for generic clean-up.

@abstract

# File lib/arachni/plugin/base.rb, line 78
def clean_up
end
framework_abort() click to toggle source

Aborts the {#framework}.

# File lib/arachni/plugin/base.rb, line 99
def framework_abort
    Thread.new do
        framework.abort
    end
end
framework_pause() click to toggle source

Pauses the {#framework}.

# File lib/arachni/plugin/base.rb, line 94
def framework_pause
    @pause_id ||= framework.pause( false )
end
framework_resume() click to toggle source

Resumes the {#framework}.

# File lib/arachni/plugin/base.rb, line 106
def framework_resume
    return if !@pause_id
    framework.resume @pause_id
end
http() click to toggle source
# File lib/arachni/plugin/base.rb, line 184
def http
    framework.http
end
info() click to toggle source
# File lib/arachni/plugin/base.rb, line 176
def info
    self.class.info
end
prepare() click to toggle source

@note 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.

@abstract

# File lib/arachni/plugin/base.rb, line 46
def prepare
end
register_results( results ) click to toggle source

Registers the plugin’s results to {Data::Plugins}.

@param [Object] results

# File lib/arachni/plugin/base.rb, line 199
def register_results( results )
    Data.plugins.store( self, results )
end
restore( state = nil ) click to toggle source

@note OPTIONAL

Gets called instead of {#prepare} when restoring a suspended plugin. If no {#restore} method has been defined, {#prepare} will be called instead.

@param [Object] state State to restore.

@see suspend @abstract

# File lib/arachni/plugin/base.rb, line 58
def restore( state = nil )
end
run() click to toggle source

@note 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.

@abstract

# File lib/arachni/plugin/base.rb, line 70
def run
end
session() click to toggle source
# File lib/arachni/plugin/base.rb, line 180
def session
    framework.session
end
suspend() click to toggle source

@note OPTIONAL

Gets called right before killing the plugin and should return state data to be {Arachni::State::Plugins#store stored} and passed to {#restore}.

@return [Object] State to store.

@see restore @abstract

# File lib/arachni/plugin/base.rb, line 90
def suspend
end
wait_while_framework_running() click to toggle source

Will block until the scan finishes.

# File lib/arachni/plugin/base.rb, line 204
def wait_while_framework_running
    sleep 0.1 while framework.running?
end
with_browser( &block ) click to toggle source
# File lib/arachni/plugin/base.rb, line 192
def with_browser( &block )
    browser_cluster.with_browser( &block )
end