Module: Arachni::UI::Output
- Extended by:
- Output
- Included in:
- ComponentManager, Framework, HTTP, Module::Manager, Module::Output, Parser, Plugin::Formatter, RPC::Server::Dispatcher, RPC::Server::Dispatcher::Node, RPC::Server::Instance, Report::Base, Spider, CLI, DispatcherMonitor, Output, RPC
- Defined in:
- lib/arachni/ui/cli/output.rb,
lib/arachni/rpc/server/output.rb
Overview
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.1
Constant Summary
- @@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- @@opened =
false- @@reroute_to_file =
false- @@buffer_cap =
30
Instance Method Summary (collapse)
- - (Object) buffer(msg)
-
- (void) debug!
Sets the @@debug flag to true.
-
- (Bool) debug?
Returns the @@debug flag.
-
- (Array<Hash>) flush_buffer
Empties the output buffer and returns all messages.
- - (Object) mute!
- - (Boolean) muted?
-
- (void) only_positives!
Sets the @@only_positives flag to true.
-
- (Bool) only_positives?
Returns the @@only_positives flag.
-
- (Object) print_bad(str = '')
Same as print_error but the message won't be printed to stderr.
-
- (void) print_debug(str = '')
Prints a debugging message.
-
- (void) print_debug_backtrace(e = nil)
Prints the backtrace of an exception.
-
- (void) print_debug_pp(obj = nil)
Pretty prints an object, used for debugging, needs some improvement but it'll do for now.
-
- (void) print_error(str = '')
Prints an error message.
- - (Object) print_error_backtrace(e)
-
- (void) print_info(str = '')
Prints an info message.
-
- (void) print_line(str = '')
Prints a line of message.
-
- (void) print_ok(str = '')
Prints a good message, something that went very very right, like the discovery of a vulnerability.
-
- (void) print_status(str = '')
Prints a status message.
-
- (void) print_verbose(str = '')
Prints a verbose message.
- - (Object) reroute_to_file(file)
- - (Boolean) reroute_to_file?
- - (Object) uncap_buffer!
- - (Object) unmute!
-
- (void) verbose!
Sets the @@verbose flag to true.
-
- (Bool) verbose?
Returns the @@verbose flag.
Instance Method Details
- (Object) buffer(msg)
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/arachni/rpc/server/output.rb', line 62 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 if @@buffer_cap.is_a? Integer @@buffer.slice!( (@@buffer.size - @@buffer_cap)..@@buffer.size ) end end end |
- (void) debug!
This method returns an undefined value.
Sets the @@debug flag to true
243 244 245 |
# File 'lib/arachni/ui/cli/output.rb', line 243 def debug! @@debug = true end |
- (Bool) debug?
Returns the @@debug flag
253 254 255 |
# File 'lib/arachni/ui/cli/output.rb', line 253 def debug? @@debug end |
- (Array<Hash>) flush_buffer
Empties the output buffer and returns all messages.
Messages are classified by their type.
56 57 58 59 60 |
# File 'lib/arachni/rpc/server/output.rb', line 56 def flush_buffer buf = @@buffer.dup @@buffer.clear return buf end |
- (Object) mute!
277 278 279 |
# File 'lib/arachni/ui/cli/output.rb', line 277 def mute! @@mute = true end |
- (Boolean) muted?
286 287 288 |
# File 'lib/arachni/ui/cli/output.rb', line 286 def muted? @@mute end |
- (void) only_positives!
This method returns an undefined value.
Sets the @@only_positives flag to true
263 264 265 |
# File 'lib/arachni/ui/cli/output.rb', line 263 def only_positives! @@only_positives = true end |
- (Bool) only_positives?
Returns the @@only_positives flag
273 274 275 |
# File 'lib/arachni/ui/cli/output.rb', line 273 def only_positives? @@only_positives end |
- (Object) print_bad(str = '')
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.
88 89 90 91 |
# File 'lib/arachni/ui/cli/output.rb', line 88 def print_bad( str = '', unmute = false ) return if muted? && !unmute print_color( '[-]', 31, str, $stdout, unmute ) end |
- (void) print_debug(str = '')
145 146 147 148 |
# File 'lib/arachni/ui/cli/output.rb', line 145 def print_debug( str = '', unmute = false ) if !@@debug then return end print_color( '[!]', 36, str, $stderr, unmute ) end |
- (void) print_debug_backtrace(e = nil)
176 177 178 179 |
# File 'lib/arachni/ui/cli/output.rb', line 176 def print_debug_backtrace( e ) if !@@debug then return end e.backtrace.each{ |line| print_debug( line ) } end |
- (void) print_debug_pp(obj = nil)
This method returns an undefined value.
Pretty prints an object, used for debugging, needs some improvement but it'll do for now
Obeys @@debug
161 162 163 164 |
# File 'lib/arachni/ui/cli/output.rb', line 161 def print_debug_pp( obj = nil ) if !@@debug then return end pp obj end |
- (void) print_error(str = '')
This method returns an undefined value.
Prints an error message
It ignores all flags, error messages will be output under all circumstances.
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 |
# File 'lib/arachni/ui/cli/output.rb', line 55 def print_error( str = '' ) print_color( '[-]', 31, str, $stderr, true ) File.open( 'error.log', 'a' ){ |f| if !@@opened f.puts f.puts "#{Time.now} " + ( "-" * 80 ) 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 f.puts "-" * 80 end print_color( "[#{Time.now}]", 31, str, f, true ) } @@opened = true end |
- (Object) print_error_backtrace(e)
181 182 183 |
# File 'lib/arachni/ui/cli/output.rb', line 181 def print_error_backtrace( e ) e.backtrace.each{ |line| print_error( line ) } end |
- (void) print_info(str = '')
118 119 120 121 |
# File 'lib/arachni/ui/cli/output.rb', line 118 def print_info( str = '', unmute = false ) if @@only_positives then return end print_color( '[~]', 30, str, $stdout, unmute ) end |
- (void) print_line(str = '')
211 212 213 214 215 |
# File 'lib/arachni/ui/cli/output.rb', line 211 def print_line( str = '', unmute = false ) if @@only_positives then return end return if muted? && !unmute puts str end |
- (void) print_ok(str = '')
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.
131 132 133 |
# File 'lib/arachni/ui/cli/output.rb', line 131 def print_ok( str = '', unmute = false ) print_color( '[+]', 32, str, $stdout, unmute ) end |
- (void) print_status(str = '')
103 104 105 106 |
# File 'lib/arachni/ui/cli/output.rb', line 103 def print_status( str = '', unmute = false ) if @@only_positives then return end print_color( '[*]', 34, str, $stdout, unmute ) end |
- (void) print_verbose(str = '')
196 197 198 199 |
# File 'lib/arachni/ui/cli/output.rb', line 196 def print_verbose( str = '', unmute = false ) if !@@verbose then return end print_color( '[v]', 37, str, $stdout, unmute ) end |
- (Object) reroute_to_file(file)
296 297 298 |
# File 'lib/arachni/rpc/server/output.rb', line 296 def reroute_to_file( file ) @@reroute_to_file = file end |
- (Boolean) reroute_to_file?
300 301 302 |
# File 'lib/arachni/rpc/server/output.rb', line 300 def reroute_to_file? @@reroute_to_file end |
- (Object) uncap_buffer!
81 82 83 |
# File 'lib/arachni/rpc/server/output.rb', line 81 def uncap_buffer! @@buffer_cap = nil end |
- (Object) unmute!
281 282 283 |
# File 'lib/arachni/ui/cli/output.rb', line 281 def unmute! @@mute = false end |
- (void) verbose!
This method returns an undefined value.
Sets the @@verbose flag to true
223 224 225 |
# File 'lib/arachni/ui/cli/output.rb', line 223 def verbose! @@verbose = true end |
- (Bool) verbose?
Returns the @@verbose flag
233 234 235 |
# File 'lib/arachni/ui/cli/output.rb', line 233 def verbose? @@verbose end |