Class: Arachni::UI::CLI

Inherits:
Object show all
Includes:
Arachni, Output, Arachni::Utilities
Defined in:
lib/arachni/ui/cli/cli.rb,
lib/arachni/ui/cli/rpc/local.rb,
lib/arachni/ui/cli/utilities.rb,
lib/arachni/ui/cli/rpc/remote.rb,
lib/arachni/ui/cli/rpc/instance.rb,
lib/arachni/ui/cli/rpc/dispatcher_monitor.rb

Overview

Provides a command line interface for the Arachni Framework.

Most of the logic is in the Framework class however profiles can only be loaded and saved at this level.

See Also:

Author:

Version:

  • 0.2

Defined Under Namespace

Modules: RPC, Utilities

Constant Summary

Constants included from Arachni

BANNER, Cookie, Form, Header, Link, Severity, VERSION, WEBSITE, WIKI

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Arachni::Utilities

#available_port, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #extract_domain, #follow_protocol?, #form_decode, #form_encode, #form_parse_request_body, #forms_from_document, #forms_from_response, #generate_token, #get_path, #html_decode, #html_encode, #include_path?, #links_from_document, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_query, #parse_set_cookie, #parse_url_vars, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #redundant_path?, #remove_constants, #seed, #skip_page?, #skip_path?, #skip_resource?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parser, #url_sanitize

Methods included from Output

#debug?, #debug_off, #debug_on, #disable_only_positives, #error_logfile, #flush_buffer, #log_error, #mute, #muted?, old_reset_output_options, #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?, reset_output_options, #set_buffer_cap, #set_error_logfile, #uncap_buffer, #unmute, #verbose, #verbose?

Methods included from Arachni

URI, profile?

Constructor Details

#initialize(opts) ⇒ CLI

Initializes the command line interface and the framework

Parameters:



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
# File 'lib/arachni/ui/cli/cli.rb', line 50

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

    #
    # the stdout report is the default one for the CLI,
    # each UI should have it's own default
    #
    # always load the stdout report unless the user requested
    # to see a list of the available reports
    #
    # *do not* forget this check, otherwise the reports registry
    # will desync
    #
    if @opts.reports.empty? && @opts.lsrep.empty?
        @opts.reports['stdout'] = {}
    end

    # instantiate the big-boy!
    @arachni = Framework.new( @opts )

    # echo the banner
    print_banner

    # work on the user supplied arguments
    parse_opts

    @interrupt_handler = nil

    # trap Ctrl+C interrupts
    trap( 'INT' ) { handle_interrupt }

    # trap user signals
    trap ( 'USR1' ) { handle_usr1_interrupt }
    trap ( 'USR2' ) { handle_usr2_interrupt }
end

Instance Attribute Details

#optsOptions (readonly)

Returns:



43
44
45
# File 'lib/arachni/ui/cli/cli.rb', line 43

def opts
  @opts
end

Instance Method Details

#runObject

Runs Arachni



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
# File 'lib/arachni/ui/cli/cli.rb', line 95

def run
    print_status 'Initialising...'

    begin
        # we may need to kill the audit so put it in a thread
        @audit = Thread.new {
            # start the show!
            @arachni.run {
                kill_interrupt_handler
                clear_screen
            }
            print_stats
        }

        @audit.join

        # if the user requested to exit the scan wait for the
        # Thread that takes care of the clean-up to finish
        @exit_handler.join if @exit_handler
    rescue Component::Options::Error::Invalid => e
        print_error e
        print_line
        exit 1
    rescue Arachni::Error => e
        print_error e
        print_info "Run arachni with the '-h' parameter for help."
        print_line
        exit 1
    rescue Exception => e
        print_error e
        print_error_backtrace e
        exit 1
    end
end