Module: Arachni::UI::Output

Extended by:
Output
Included in:
Component::Manager, Framework, Module::Output, Parser, Plugin::Formatter, RPC::Server::Dispatcher, RPC::Server::Dispatcher::Node, RPC::Server::Instance, Report::Base, Session, Spider, CLI, DispatcherMonitor, Output, RPC, Arachni::URI, Arachni::URI
Defined in:
lib/arachni/ui/cli/output.rb,
lib/arachni/ui/foo/output.rb,
lib/arachni/rpc/server/output.rb

Overview

RPC Output module

It basically classifies and buffers all system messages until it’s time to flush the buffer and send them over the wire.

Author:

Constant Summary collapse

@@verbose =

verbosity flag

if it’s on verbose messages will be enabled

false
@@debug =

debug flag

if it’s on debugging messages will be enabled

false
@@only_positives =

only_positives flag

if it’s on status messages will be disabled

false
@@mute =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.old_reset_output_optionsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/arachni/rpc/server/output.rb', line 35

def self.reset_output_options
    # verbosity flag
    #
    # if it's on verbose messages will be enabled
    @@verbose = false

    # debug flag
    #
    # if it's on debugging messages will be enabled
    @@debug   = false

    @@mute = false

    # only_positives flag
    #
    # if it's on status messages will be disabled
    @@only_positives  = false

    @@reroute_to_file = false

    @@opened = false
end

.reset_output_optionsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/arachni/ui/cli/output.rb', line 31

def self.reset_output_options
    # verbosity flag
    #
    # if it's on verbose messages will be enabled
    @@verbose = false

    # debug flag
    #
    # if it's on debugging messages will be enabled
    @@debug   = false

    @@mute = false

    # only_positives flag
    #
    # if it's on status messages will be disabled
    @@only_positives  = false

    @@reroute_to_file = false

    @@opened = false
end

Instance Method Details

#debug?Bool

Returns the @@debug flag

Returns:

  • (Bool)

    @@debug

See Also:



272
273
274
# File 'lib/arachni/ui/cli/output.rb', line 272

def debug?
    @@debug
end

#debug_offObject



262
263
264
# File 'lib/arachni/ui/cli/output.rb', line 262

def debug_off
    @@debug = false
end

#debug_onvoid Also known as: debug

This method returns an undefined value.

Sets the @@debug flag to true

See Also:



257
258
259
# File 'lib/arachni/ui/cli/output.rb', line 257

def debug_on
    @@debug = true
end

#disable_only_positivesObject



286
287
288
# File 'lib/arachni/ui/cli/output.rb', line 286

def disable_only_positives
    @@only_positives = false
end

#flush_bufferArray<Hash>

Empties the output buffer and returns all messages.

Messages are classified by their type.

Returns:



53
54
55
56
57
# File 'lib/arachni/rpc/server/output.rb', line 53

def flush_buffer
    buf = @@output_buffer.dup
    @@output_buffer.clear
    buf
end

#muteObject



300
301
302
# File 'lib/arachni/ui/cli/output.rb', line 300

def mute
    @@mute = true
end

#muted?Boolean

Returns:

  • (Boolean)


308
309
310
# File 'lib/arachni/ui/cli/output.rb', line 308

def muted?
    @@mute
end

#only_positivesvoid

This method returns an undefined value.

Sets the @@only_positives flag to true

See Also:



282
283
284
# File 'lib/arachni/ui/cli/output.rb', line 282

def only_positives
    @@only_positives = true
end

#only_positives?Bool

Returns the @@only_positives flag

Returns:

  • (Bool)

    @@only_positives

See Also:

  • #only_positives!


296
297
298
# File 'lib/arachni/ui/cli/output.rb', line 296

def only_positives?
    @@only_positives
end

Same as print_error but the message won’t be printed to stderr.

Used mainly to draw attention to something that didn’t behave as expected rather than display an actual error.

Parameters:

  • str (String) (defaults to: '')


99
100
101
102
# File 'lib/arachni/ui/cli/output.rb', line 99

def print_bad( str = '', unmute = false )
    return if muted? && !unmute
    print_color( '[-]', 31, str, $stdout, unmute )
end

This method returns an undefined value.

Prints a debugging message

Obeys @@debug

Parameters:

  • str (String) (defaults to: '')

See Also:



156
157
158
159
# File 'lib/arachni/ui/cli/output.rb', line 156

def print_debug( str = '', unmute = false )
    return if !debug?
    print_color( '[!]', 36, str, $stderr, unmute )
end

Prints the backtrace of an exception

Obeys @@debug

Parameters:

  • e (Exception)

See Also:



185
186
187
188
# File 'lib/arachni/ui/cli/output.rb', line 185

def print_debug_backtrace( e )
    return if !debug?
    e.backtrace.each{ |line| print_debug( line ) }
end

Pretty prints an object, used for debugging, needs some improvement but it’ll do for now

Obeys @@debug

Parameters:

See Also:



171
172
173
174
# File 'lib/arachni/ui/cli/output.rb', line 171

def print_debug_pp( obj = nil )
    return if !debug?
    pp obj
end

This method returns an undefined value.

Prints an error message

It ignores all flags, error messages will be output under all circumstances.

Parameters:

  • str (String) (defaults to: '')

    error string



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/arachni/ui/cli/output.rb', line 63

def print_error( str = '' )
    print_color( '[-]', 31, str, $stderr, true )
    File.open( 'error.log', 'a' ) do |f|
        if !@@opened
            f.puts
            f.puts "#{Time.now} " + ( "-" * 80 )

            begin
                h = {}
                ENV.each { |k, v| h[k] = v }
                f.puts 'ENV:'
                f.puts h.to_yaml

                f.puts "-" * 80

                f.puts 'OPTIONS:'
                f.puts Arachni::Options.instance.to_yaml
            rescue
            end

            f.puts "-" * 80
        end
        print_color( "[#{Time.now}]", 31, str, f, true )
    end

    @@opened = true
end


190
191
192
# File 'lib/arachni/ui/cli/output.rb', line 190

def print_error_backtrace( e )
    e.backtrace.each{ |line| print_error( line ) }
end

This method returns an undefined value.

Prints an info message

Obeys @@only_positives

Parameters:

  • str (String) (defaults to: '')

See Also:



129
130
131
132
# File 'lib/arachni/ui/cli/output.rb', line 129

def print_info( str = '', unmute = false )
    return if only_positives?
    print_color( '[~]', 30, str, $stdout, unmute )
end

This method returns an undefined value.

Prints a line of message

Obeys @@only_positives

Parameters:

  • str (String) (defaults to: '')

See Also:



220
221
222
223
224
225
226
227
228
229
# File 'lib/arachni/ui/cli/output.rb', line 220

def print_line( str = '', unmute = false )
    return if only_positives?
    return if muted? && !unmute

    # we may get IO errors...freaky stuff...
    begin
        puts str
    rescue
    end
end

This method returns an undefined value.

Prints a good message, something that went very very right, like the discovery of a vulnerability

Disregards all flags.

Parameters:

  • str (String) (defaults to: '')


142
143
144
# File 'lib/arachni/ui/cli/output.rb', line 142

def print_ok( str = '', unmute = false )
    print_color( '[+]', 32, str, $stdout, unmute )
end

This method returns an undefined value.

Prints a status message

Obeys @@only_positives

Parameters:

  • str (String) (defaults to: '')

See Also:



114
115
116
117
# File 'lib/arachni/ui/cli/output.rb', line 114

def print_status( str = '', unmute = false )
    return if only_positives?
    print_color( '[*]', 34, str, $stdout, unmute )
end

This method returns an undefined value.

Prints a verbose message

Obeys @@verbose

Parameters:

  • str (String) (defaults to: '')

See Also:



205
206
207
208
# File 'lib/arachni/ui/cli/output.rb', line 205

def print_verbose( str = '', unmute = false )
    return if !verbose?
    print_color( '[v]', 37, str, $stdout, unmute )
end

#reroute_to_file(file) ⇒ Object



187
188
189
# File 'lib/arachni/rpc/server/output.rb', line 187

def reroute_to_file( file )
    @@reroute_to_file = file
end

#reroute_to_file?Boolean

Returns:

  • (Boolean)


191
192
193
# File 'lib/arachni/rpc/server/output.rb', line 191

def reroute_to_file?
    @@reroute_to_file
end

#set_buffer_cap(cap) ⇒ Object



59
60
61
# File 'lib/arachni/rpc/server/output.rb', line 59

def set_buffer_cap( cap )
    @@output_buffer_cap = cap
end

#uncap_bufferObject



63
64
65
# File 'lib/arachni/rpc/server/output.rb', line 63

def uncap_buffer
    @@output_buffer_cap = nil
end

#unmuteObject



304
305
306
# File 'lib/arachni/ui/cli/output.rb', line 304

def unmute
    @@mute = false
end

#verbosevoid

This method returns an undefined value.

Sets the @@verbose flag to true

See Also:



237
238
239
# File 'lib/arachni/ui/cli/output.rb', line 237

def verbose
    @@verbose = true
end

#verbose?Bool

Returns the @@verbose flag

Returns:

  • (Bool)

    @@verbose

See Also:



247
248
249
# File 'lib/arachni/ui/cli/output.rb', line 247

def verbose?
    @@verbose
end