Class: Arachni::UI::RPC
- Includes:
- Module::Utilities, Output
- Defined in:
- lib/arachni/ui/rpc/rpc.rb
Overview
Provides an self sufficient Arachni RPC client.
It mimics the standard CLI interface’s functionality albeit in a client-server fashion.
This should be your first stop when looking into creating your own RPC client. <br/> Of course you don’t need to instantiate the framework or any other Arachni related classes in your own client, this is just to provide some other info to the user.
@author: Tasos “Zapotek” Laskos
<[email protected]>
<[email protected]>
@version: 0.2
Instance Method Summary collapse
-
#initialize(opts) ⇒ RPC
constructor
A new instance of RPC.
- #run ⇒ Object
Methods included from Module::Utilities
#exception_jail, #get_path, #hash_keys_to_str, #normalize_url, #read_file, #seed, #uri_decode, #uri_encode, #uri_parse, #uri_parser, #url_sanitize
Methods included from Output
#buffer, #debug!, #debug?, #flush_buffer, #mute!, #muted?, #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?, #uncap_buffer!, #unmute!, #verbose!, #verbose?
Constructor Details
#initialize(opts) ⇒ RPC
Returns a new instance of RPC.
44 45 46 47 48 49 50 51 52 53 54 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/arachni/ui/rpc/rpc.rb', line 44 def initialize( opts ) @opts = opts # if we have a load profile load it and merge it with the # user supplied options if( @opts.load_profile ) load_profile( @opts.load_profile ) end debug! if @opts.debug # we don't need the framework for much, # in this case only for report generation, version number etc. @framework = Arachni::Framework.new( @opts ) # print banner message # if the user needs help, output it and exit if opts.help usage exit 0 end # if the user wants to see the available reports, output them and exit if !opts.lsrep.empty? lsrep exit end if opts.show_profile print_profile( ) exit 0 end if opts.save_profile exception_jail{ save_profile( opts.save_profile ) } exit 0 end # Check for missing url if( !@opts.url && @opts.lsmod.empty? ) print_bad( "Missing url argument." ) exit 0 end begin @dispatcher = Arachni::RPC::Client::Dispatcher.new( @opts, @opts.server ) # get a new instance and assign the url we're going to audit as the # 'owner' @instance = @dispatcher.dispatch( @opts.url.to_s ) # start the RPC client @server = Arachni::RPC::Client::Instance.new( @opts, @instance['url'], @instance['token'] ) rescue Exception => e print_error( "Could not connect to server." ) print_debug( "Error: #{e.to_s}." ) print_debug_backtrace( e ) exit 0 end # if the user wants to see the available reports, output them and exit if !opts.lsplug.empty? lsplug( @server.framework.lsplug ) shutdown exit end # if the user wants to see the available modules # grab them from the server, output them, exit and shutdown the server. if !opts.lsmod.empty? lsmod( @server.framework.lsmod ) shutdown exit end # # we could just execute pause() upon an interrupt but RPC I/O # needs to be synchronized otherwise we'll get an HTTP exception # @pause = false trap( 'INT' ){ @pause = true } begin parse_opts rescue Exception => e print_error( 'Error: ' + e.to_s ) print_debug_backtrace( e ) begin shutdown rescue end exit end end |
Instance Method Details
#run ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/arachni/ui/rpc/rpc.rb', line 144 def run exception_jail { print_status 'Running framework...' @server.framework.run print_line # grab the RPC server output while a scan is running while( @server.framework.busy? ) output pause if @pause # things will get crazy if we don't block a bit I think... # we'll see... ::IO::select( nil, nil, nil, 2 ) end puts } report shutdown end |