Class: Arachni::UI::CLI::RPC::Client::Instance

Inherits:
Object
  • Object
show all
Includes:
Support::Mixins::Terminal, Utilities, Output
Defined in:
ui/cli/rpc/client/instance.rb

Overview

Provides a command-line RPC client/interface for an RPC::Server::Instance.

This interface should be your first stop when looking into using/creating your own RPC client.

Of course, you don't need to have access to the framework or any other Arachni class for your own client, this is used here just to provide some other info to the user.

However, in contrast with everywhere else in the system (where RPC operations are asynchronous), this interface operates in blocking mode as its simplicity does not warrant the extra complexity of asynchronous calls.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support::Mixins::Terminal

#clear_screen, #empty_screen, #flush, #move_to_home, #reprint, #reputs, #restr

Methods included from Utilities

#list_checks, #list_platforms, #list_plugins, #list_reporters, #load_profile, #print_banner, #save_profile

Methods included from Arachni::Utilities

#available_port, available_port_mutex, #bytes_to_kilobytes, #bytes_to_megabytes, #caller_name, #caller_path, #cookie_decode, #cookie_encode, #cookies_from_file, #cookies_from_parser, #cookies_from_response, #exception_jail, #exclude_path?, #follow_protocol?, #form_decode, #form_encode, #forms_from_parser, #forms_from_response, #full_and_absolute_url?, #generate_token, #get_path, #hms_to_seconds, #html_decode, #html_encode, #include_path?, #links_from_parser, #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 Output

#caller_location, #debug?, #debug_level, #debug_level_1?, #debug_level_2?, #debug_level_3?, #debug_level_4?, #debug_off, #debug_on, #disable_only_positives, #error_buffer, #error_log_fd, #error_logfile, #has_error_log?, #included, #log_error, #mute, #muted?, #only_positives, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_exception, #print_debug_level_1, #print_debug_level_2, #print_debug_level_3, #print_debug_level_4, #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, #set_error_logfile, #unmute, #verbose?, #verbose_off, #verbose_on

Constructor Details

#initialize(options, instance, timeout = nil) ⇒ Instance

Returns a new instance of Instance.

Parameters:


47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'ui/cli/rpc/client/instance.rb', line 47

def initialize( options, instance, timeout = nil )
    @options  = options
    @instance = instance
    @timeout  = timeout

    clear_screen
    move_to_home

    # We don't need the framework for much, in this case only for report
    # generation, version number etc.
    @framework = Arachni::Framework.new( @options )
    @issues    = []
end

Instance Attribute Details

#error_log_fileObject (readonly)

Returns the value of attribute error_log_file


41
42
43
# File 'ui/cli/rpc/client/instance.rb', line 41

def error_log_file
  @error_log_file
end

#frameworkObject (readonly)

Returns the value of attribute framework


42
43
44
# File 'ui/cli/rpc/client/instance.rb', line 42

def framework
  @framework
end

Instance Method Details

#runObject


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
# File 'ui/cli/rpc/client/instance.rb', line 61

def run
    timeout_time = Time.now + @timeout.to_i
    timed_out    = false

    begin
        # Start the show!
        @instance.service.scan prepare_rpc_options

        while busy?
            if @timeout && Time.now >= timeout_time
                timed_out = true
                break
            end

            print_progress
            sleep 5
            refresh_progress
        end
    rescue Interrupt
    rescue => e
        print_exception e
    end

    report_and_shutdown

    return if !timed_out
    print_error 'Timeout was reached.'
end