Class: Arachni::UI::CLI

Inherits:
Object show all
Includes:
Module::Utilities, Output
Defined in:
lib/ui/cli/cli.rb

Overview

Arachni::UI:CLI class

Provides a command line interface for the Arachni Framework.<br/> Most of the logic is in the Framework class however profiles can only<br/> be loaded and saved at this level.

@author: Tasos “Zapotek” Laskos

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

@version: 0.1.6

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Module::Utilities

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

Methods included from 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?

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
# File 'lib/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 = Arachni::Framework.new( @opts  )


    # echo the banner
    banner( )

    # work on the user supplied arguments
    parse_opts( )

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

Instance Attribute Details

#optsOptions (readonly)

Instance options

Returns:



39
40
41
# File 'lib/ui/cli/cli.rb', line 39

def opts
  @opts
end

Instance Method Details

#runObject

Runs Arachni



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

def run( )

    print_status( 'Initing...' )

    begin
        # start the show!
        @arachni.run( ){
            @interrupt_handler.join if @interrupt_handler
        }
        print_stats
    rescue Arachni::Exceptions::NoMods => e
        print_error( e.to_s )
        print_info( "Run arachni with the '-h' parameter for help or " )
        print_info( "with the '--lsmod' parameter to see all available modules." )
        print_line
        exit 0
    rescue Arachni::Exceptions => e
        print_error( e.to_s )
        print_info( "Run arachni with the '-h' parameter for help." )
        print_line
        exit 0
    rescue Exception => e
        exception_jail{ raise e }
        exit 0
    end
end