Module: Arachni::UI::Output

Overview

XML-RPC deamon 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: Tasos “Zapotek” Laskos

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

@version: 0.1

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
@@reroute_to_file =
false

Instance Method Summary collapse

Instance Method Details

#buffer(msg) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rpc/xml/server/output.rb', line 60

def buffer( msg )
    if file = @@reroute_to_file
        File.open( file, 'a+' ) {
            |f|

            type = msg.keys[0]
            str  = msg.values[0]
            next if str.empty?

            f.write( "[#{Time.now.asctime}] [#{type}]  #{str}\n" )
        }
    else
        @@buffer << msg
    end
end

#debug!void

This method returns an undefined value.

Sets the @@debug flag to true

See Also:



207
208
209
# File 'lib/ui/cli/output.rb', line 207

def debug!
    @@debug = true
end

#debug?Bool

Returns the @@debug flag

Returns:

  • (Bool)

    @@debug

See Also:



217
218
219
# File 'lib/ui/cli/output.rb', line 217

def debug?
    @@debug
end

#flush_bufferArray<Hash>

Empties the output buffer and returns all messages.

Messages are classified by their type.

Returns:

  • (Array<Hash>)


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

def flush_buffer
    buf = @@buffer.dup
    @@buffer.clear
    return buf
end

#mute!Object



241
242
243
# File 'lib/ui/cli/output.rb', line 241

def mute!
    @@mute = true
end

#muted?Boolean

Returns:

  • (Boolean)


250
251
252
# File 'lib/ui/cli/output.rb', line 250

def muted?
    @@mute
end

#only_positives!void

This method returns an undefined value.

Sets the @@only_positives flag to true

See Also:



227
228
229
# File 'lib/ui/cli/output.rb', line 227

def only_positives!
    @@only_positives = true
end

#only_positives?Bool

Returns the @@only_positives flag

Returns:

  • (Bool)

    @@only_positives

See Also:



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

def only_positives?
    @@only_positives
end

This method returns an undefined value.

Prints a debugging message

Obeys @@debug

Parameters:

  • debugging (String)

    string

See Also:



109
110
111
112
# File 'lib/ui/cli/output.rb', line 109

def print_debug( str = '' )
    if !@@debug then return end
    print_color( '[!]', 36, str, $stderr )
end

This method returns an undefined value.

Prints the backtrace of an exception

Obeys @@debug

Parameters:

  • (Exception)

See Also:



140
141
142
143
# File 'lib/ui/cli/output.rb', line 140

def print_debug_backtrace( e = nil )
    if !@@debug then return end
    e.backtrace.each{ |line| print_debug( line ) }
end

This method returns an undefined value.

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

Obeys @@debug

Parameters:

See Also:



125
126
127
128
# File 'lib/ui/cli/output.rb', line 125

def print_debug_pp( obj = nil )
    if !@@debug then return end
    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:



53
54
55
# File 'lib/ui/cli/output.rb', line 53

def print_error( str = '' )
    print_color( '[-]', 31, str, $stderr )
end


145
146
147
# File 'lib/ui/cli/output.rb', line 145

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

This method returns an undefined value.

Prints an info message

Obeys @@only_positives

Parameters:

See Also:



82
83
84
85
# File 'lib/ui/cli/output.rb', line 82

def print_info( str = '' )
    if @@only_positives then return end
    print_color( '[~]', 30, str )
end

This method returns an undefined value.

Prints a line of message

Obeys @@only_positives

Parameters:

See Also:



175
176
177
178
179
# File 'lib/ui/cli/output.rb', line 175

def print_line( str = '' )
    if @@only_positives then return end
    return if muted?
    puts str
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:



95
96
97
# File 'lib/ui/cli/output.rb', line 95

def print_ok( str = '' )
    print_color( '[+]', 32, str )
end

This method returns an undefined value.

Prints a status message

Obeys @@only_positives

Parameters:

See Also:



67
68
69
70
# File 'lib/ui/cli/output.rb', line 67

def print_status( str = '' )
    if @@only_positives then return end
    print_color( '[*]', 34, str )
end

This method returns an undefined value.

Prints a verbose message

Obeys @@verbose

Parameters:

See Also:



160
161
162
163
# File 'lib/ui/cli/output.rb', line 160

def print_verbose( str = '' )
    if !@@verbose then return end
    print_color( '[v]', 37, str )
end

#reroute_to_file(file) ⇒ Object



272
273
274
# File 'lib/rpc/xml/server/output.rb', line 272

def reroute_to_file( file )
    @@reroute_to_file = file
end

#reroute_to_file?Boolean

Returns:

  • (Boolean)


276
277
278
# File 'lib/rpc/xml/server/output.rb', line 276

def reroute_to_file?
    @@reroute_to_file
end

#unmute!Object



245
246
247
# File 'lib/ui/cli/output.rb', line 245

def unmute!
    @@mute = false
end

#verbose!void

This method returns an undefined value.

Sets the @@verbose flag to true

See Also:



187
188
189
# File 'lib/ui/cli/output.rb', line 187

def verbose!
    @@verbose = true
end

#verbose?Bool

Returns the @@verbose flag

Returns:

  • (Bool)

    @@verbose

See Also:



197
198
199
# File 'lib/ui/cli/output.rb', line 197

def verbose?
    @@verbose
end