Class: Arachni::UI::CLI

Inherits:
Object
  • Object
show all
Includes:
Output
Defined in:
lib/ui/cli/cli.rb

Overview

Arachni::UI:CLI class

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.

@author: Anastasios “Zapotek” Laskos

                                     <tasos.laskos@gmail.com>
                                     <zapotek@segfault.gr>

@version: 0.1-pre

See Also:

Constant Summary

PROFILE_EXT =

The extension of the profile files.

Returns:

  • (String)
'.afp'

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Output

#debug!, #debug?, #only_positives!, #only_positives?, #print_debug, #print_debug_backtrace, #print_debug_pp, #print_error, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #verbose!, #verbose?

Constructor Details

- (CLI) initialize(opts)

Initializes the command line interface and the framework

Parameters:



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

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.size == 0 && !@opts.lsrep )
        @opts.reports << 'stdout'
    end
    
    # instantiate the big-boy!
    @arachni = Arachni::Framework.new( @opts  )
    
    # echo the banner
    ( )
    
    # work on the user supplied arguments
    parse_opts( )
end

Instance Attribute Details

- (Options) opts (readonly)

Instance options

Returns:



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

def opts
  @opts
end

Instance Method Details

- (Object) run

Runs Arachni



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

def run( )
    
    print_status( 'Initing...' )
            
    begin
        
        # this will output only if debug mode is on
        ls_loaded( )
        
        # start the show!
        @arachni.run( )
        
    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
        print_error( e.inspect )
        print_debug( 'Backtrace:' )
        print_debug_backtrace( e )
        print_line
        exit 0
    end
end