Class: VOODOO::Output
- Inherits:
-
Object
- Object
- VOODOO::Output
- Defined in:
- lib/voodoo/output.rb
Instance Attribute Summary collapse
-
#writable ⇒ Object
readonly
Returns the value of attribute writable.
Instance Method Summary collapse
- #handle(event) ⇒ Object
-
#initialize(file: nil, in_format: nil, for_command: nil) ⇒ Output
constructor
A new instance of Output.
- #write(any, with_print: false) ⇒ Object
Constructor Details
#initialize(file: nil, in_format: nil, for_command: nil) ⇒ Output
Returns a new instance of Output.
8 9 10 11 12 13 14 |
# File 'lib/voodoo/output.rb', line 8 def initialize(file: nil, in_format: nil, for_command: nil) @file = nil @format = in_format @command = for_command @writable = in_format != 'none' @file = open(file, 'a') if file end |
Instance Attribute Details
#writable ⇒ Object (readonly)
Returns the value of attribute writable.
6 7 8 |
# File 'lib/voodoo/output.rb', line 6 def writable @writable end |
Instance Method Details
#handle(event) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/voodoo/output.rb', line 28 def handle(event) if !@writable return end case @format when 'pretty' case @command when 'keylogger' write event[:payload], with_print: true else write JSON.generate(event[:payload]) end when 'json' write JSON.generate(event) when 'payload' write JSON.generate(event[:payload]) when 'payload:base64decode' write Base64.decode64(event[:payload]) else write JSON.generate(event) end true end |
#write(any, with_print: false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/voodoo/output.rb', line 16 def write(any, with_print: false) if @file @file.puts any else if with_print print any else puts any end end end |