Module: Arachni::RPC::Server::Framework::Slave

Included in:
MultiInstance
Defined in:
lib/arachni/rpc/server/framework/slave.rb

Overview

Holds methods for slave Instances.

Author:

Instance Method Summary collapse

Instance Method Details

#process_pages(pages) ⇒ Object

Parameters:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/arachni/rpc/server/framework/slave.rb', line 78

def process_pages( pages )
    pages.each { |page| push_to_page_queue Page.from_rpc_data( page ), true }

    return if @audit_page_running
    @audit_page_running = true

    # Thread.abort_on_exception = true
    Thread.new do
        exception_jail( false ) { audit }

        sitrep( issues: @issue_buffer.dup, audit_done: true )
        @issue_buffer.clear
        @audit_page_running = false
    end

    nil
end

#set_master(url, token) ⇒ Bool

Sets the URL and authentication token required to connect to this Instance’s master and makes this Instance a slave.

Parameters:

  • url (String)

    Master’s URL in ‘hostname:port` form.

  • token (String)

    Master’s authentication token.

Returns:

  • (Bool)

    ‘true` on success, `false` if the instance is already part of a multi-Instance operation.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/arachni/rpc/server/framework/slave.rb', line 30

def set_master( url, token )
    # If we're already a member of a multi-Instance operation bail out.
    return false if !solo?

    options.scope.do_not_crawl

    # Make sure the desired plugins are loaded before #prepare runs them.
    plugins.load options.plugins if options.plugins

    # Start the clock and run the plugins.
    prepare

    Thread.new { browser_cluster }

    @master = connect_to_instance( url: url, token: token )

    # Buffer for logged issues that are to be sent to the master.
    @issue_buffer = []

    # Don't store issues locally -- will still filter duplicate issues though.
    Data.issues.do_not_store

    # Buffer discovered issues...
    Data.issues.on_new do |issue|
        @issue_buffer << issue
    end
    # ... and flush it on each page audit.
    after_page_audit do
        sitrep( issues: @issue_buffer.dup )
        @issue_buffer.clear
    end

    print_status "Enslaved by: #{url}"

    true
end

#slave?Bool

Returns ‘true` if this instance is a slave, `false` otherwise.

Returns:

  • (Bool)

    ‘true` if this instance is a slave, `false` otherwise.



69
70
71
72
# File 'lib/arachni/rpc/server/framework/slave.rb', line 69

def slave?
    # If we don't have a connection to the master then we're not a slave.
    !!@master
end