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
<[email protected]>
<[email protected]>
@version: 0.1.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
- @@opened =
false
- @@reroute_to_file =
false
- @@buffer_cap =
30
Instance Method Summary collapse
- #buffer(msg) ⇒ Object
-
#debug! ⇒ void
Sets the @@debug flag to true.
-
#debug? ⇒ Bool
Returns the @@debug flag.
-
#flush_buffer ⇒ Array<Hash>
Empties the output buffer and returns all messages.
- #mute! ⇒ Object
- #muted? ⇒ Boolean
-
#only_positives! ⇒ void
Sets the @@only_positives flag to true.
-
#only_positives? ⇒ Bool
Returns the @@only_positives flag.
-
#print_bad(str = '') ⇒ Object
Same as print_error but the message won’t be printed to stderr.
-
#print_debug(str = '') ⇒ void
Prints a debugging message.
-
#print_debug_backtrace(e = nil) ⇒ void
Prints the backtrace of an exception.
-
#print_debug_pp(obj = nil) ⇒ void
Pretty prints an object, used for debugging, needs some improvement but it’ll do for now.
-
#print_error(str = '') ⇒ void
Prints an error message.
- #print_error_backtrace(e) ⇒ Object
-
#print_info(str = '') ⇒ void
Prints an info message.
-
#print_line(str = '') ⇒ void
Prints a line of message.
-
#print_ok(str = '') ⇒ void
Prints a good message, something that went very very right, like the discovery of a vulnerability.
-
#print_status(str = '') ⇒ void
Prints a status message.
-
#print_verbose(str = '') ⇒ void
Prints a verbose message.
- #reroute_to_file(file) ⇒ Object
- #reroute_to_file? ⇒ Boolean
- #uncap_buffer! ⇒ Object
- #unmute! ⇒ Object
-
#verbose! ⇒ void
Sets the @@verbose flag to true.
-
#verbose? ⇒ Bool
Returns the @@verbose flag.
Instance Method Details
#buffer(msg) ⇒ Object
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 |
#debug! ⇒ void
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 |
#debug? ⇒ Bool
Returns the @@debug flag
253 254 255 |
# File 'lib/arachni/ui/cli/output.rb', line 253 def debug? @@debug end |
#flush_buffer ⇒ Array<Hash>
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 |
#mute! ⇒ Object
277 278 279 |
# File 'lib/arachni/ui/cli/output.rb', line 277 def mute! @@mute = true end |
#muted? ⇒ Boolean
286 287 288 |
# File 'lib/arachni/ui/cli/output.rb', line 286 def muted? @@mute end |
#only_positives! ⇒ void
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 |
#only_positives? ⇒ Bool
Returns the @@only_positives flag
273 274 275 |
# File 'lib/arachni/ui/cli/output.rb', line 273 def only_positives? @@only_positives end |
#print_bad(str = '') ⇒ Object
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 |
#print_debug(str = '') ⇒ void
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 |
#print_debug_backtrace(e = nil) ⇒ void
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 |
#print_debug_pp(obj = nil) ⇒ void
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 |
#print_error(str = '') ⇒ void
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 |
#print_error_backtrace(e) ⇒ Object
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 |
#print_info(str = '') ⇒ void
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 |
#print_line(str = '') ⇒ void
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 |
#print_ok(str = '') ⇒ void
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 |
#print_status(str = '') ⇒ void
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 |
#print_verbose(str = '') ⇒ void
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 |
#reroute_to_file(file) ⇒ Object
296 297 298 |
# File 'lib/arachni/rpc/server/output.rb', line 296 def reroute_to_file( file ) @@reroute_to_file = file end |
#reroute_to_file? ⇒ Boolean
300 301 302 |
# File 'lib/arachni/rpc/server/output.rb', line 300 def reroute_to_file? @@reroute_to_file end |
#uncap_buffer! ⇒ Object
81 82 83 |
# File 'lib/arachni/rpc/server/output.rb', line 81 def uncap_buffer! @@buffer_cap = nil end |
#unmute! ⇒ Object
281 282 283 |
# File 'lib/arachni/ui/cli/output.rb', line 281 def unmute! @@mute = false end |
#verbose! ⇒ void
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 |
#verbose? ⇒ Bool
Returns the @@verbose flag
233 234 235 |
# File 'lib/arachni/ui/cli/output.rb', line 233 def verbose? @@verbose end |