Class: Arachni::RPC::XML::Server::Instance

Inherits:
Base show all
Includes:
Module::Utilities, UI::Output
Defined in:
lib/rpc/xml/server/instance.rb

Overview

XMLRPC Server class

Provides an XML-RPC server to assist with general integration and UI development.

Only instantiated by the Dispatcher to provide support for multiple and concurent XMLRPC clients/scans.

@author: Tasos “Zapotek” Laskos

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

@version: 0.1.3

Instance Method Summary collapse

Methods included from Module::Utilities

#exception_jail, #get_path, #normalize_url, #read_file, #seed

Methods included from UI::Output

#buffer, #debug!, #debug?, #flush_buffer, #mute!, #muted?, #only_positives!, #only_positives?, #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?, #unmute!, #verbose!, #verbose?

Methods inherited from Base

#add_handler, #alive?

Constructor Details

#initialize(opts) ⇒ Instance

Initializes the XML-RPC interface, the HTTP(S) server and the framework.

Parameters:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/rpc/xml/server/instance.rb', line 55

def initialize( opts )

    prep_framework
    banner

    @opts = opts
    super( @opts )

    if @opts.debug
        debug!
    end


    if @opts.reroute_to_logfile
        reroute_to_file( @opts.dir['root'] +
            "logs/XMLRPC-Server - #{Process.pid}:#{@opts.rpc_port} - #{Time.now.asctime}.log" )
    else
        reroute_to_file( false )
    end

    set_handlers

    # trap interupts and exit cleanly when required
    trap( 'HUP' ) { shutdown }
    trap( 'INT' ) { shutdown }

end

Instance Method Details

#outputArray<Hash>

Flushes the output buffer and returns all pending system messages.

All messages are classified based on their type.

Returns:

  • (Array<Hash>)


114
115
116
# File 'lib/rpc/xml/server/instance.rb', line 114

def output
    flush_buffer( )
end

#resetObject

Resets the framework leaving it lemon fresh for the next scan.

If you reuse without reseting, Arachni will eat your kitten!<br/> (And I don’t mean sexually…)



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/rpc/xml/server/instance.rb', line 89

def reset

    print_status( 'Resetting...' )

    exception_jail {
        @framework.modules.clear
        Arachni.reset
        Arachni::Options.instance.reset
        prep_framework
        set_handlers
        output
    }

    print_status( 'Done.' )

    return true
end

#runObject

Starts the HTTP(S) server and the XML-RPC service.



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/rpc/xml/server/instance.rb', line 132

def run

    begin
        print_status( 'Starting the server...' )
        # start the show!
        super
    rescue Exception => e
        exception_jail{ raise e }
        exit 0
    end
end

#shutdownObject Also known as: shutdown!

Makes the HTTP(S) server go bye-bye…Lights out!



121
122
123
124
125
126
# File 'lib/rpc/xml/server/instance.rb', line 121

def shutdown
    print_status( 'Shutting down...' )
    super
    print_status( 'Done.' )
    return true
end