Class: Ronin::Recon::OutputFormats::Dot
- Inherits:
-
Core::OutputFormats::OutputFile
- Object
- Core::OutputFormats::OutputFile
- Ronin::Recon::OutputFormats::Dot
- Includes:
- GraphFormat
- Defined in:
- lib/ronin/recon/output_formats/dot.rb
Overview
Represents a GraphViz DOT (.dot
) output format.
Instance Method Summary collapse
-
#<<(value) ⇒ Object
Writes a value to the GraphViz DOT output stream as a node declaration.
-
#[]=(value, parent) ⇒ self
Appends a value and it's parent value to the GraphViz DOT output stream.
-
#close ⇒ Object
Writes the complete JSON Array of values and closes the IO stream.
-
#initialize(io) ⇒ Dot
constructor
Initializes the GraphViz DOT (
.dot
) output format. -
#value_text(value) ⇒ String
Returns the body text for the value object.
-
#value_type(value) ⇒ String
Returns the descriptive type name for the value object.
Constructor Details
#initialize(io) ⇒ Dot
Initializes the GraphViz DOT (.dot
) output format.
54 55 56 57 58 |
# File 'lib/ronin/recon/output_formats/dot.rb', line 54 def initialize(io) super(io) @io.puts "digraph {" end |
Instance Method Details
#<<(value) ⇒ Object
Writes a value to the GraphViz DOT output stream as a node declaration.
118 119 120 121 122 123 124 |
# File 'lib/ronin/recon/output_formats/dot.rb', line 118 def <<(value) name = value.to_s label = "#{value_type(value)}\n#{value_text(value)}" @io.puts "\t#{name.inspect} [label=#{label.inspect}]" @io.flush end |
#[]=(value, parent) ⇒ self
Appends a value and it's parent value to the GraphViz DOT output stream.
138 139 140 141 |
# File 'lib/ronin/recon/output_formats/dot.rb', line 138 def []=(value,parent) @io.puts "\t#{parent.to_s.inspect} -> #{value.to_s.inspect}" @io.flush end |
#close ⇒ Object
Writes the complete JSON Array of values and closes the IO stream.
146 147 148 149 150 |
# File 'lib/ronin/recon/output_formats/dot.rb', line 146 def close @io.puts "}" super end |
#value_text(value) ⇒ String
Returns the body text for the value object.
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ronin/recon/output_formats/dot.rb', line 100 def value_text(value) case value when Values::URL "#{value.status} #{value}" when Values::Cert value.subject.to_h.map { |k,v| "#{k}: #{v}\n" }.join else value.to_s end end |
#value_type(value) ⇒ String
Returns the descriptive type name for the value object.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ronin/recon/output_formats/dot.rb', line 72 def value_type(value) case value when Values::Domain then "Domain" when Values::Mailserver then "Mailserver" when Values::Nameserver then "Nameserver" when Values::Host then "Host" when Values::IP then "IP address" when Values::IPRange then "IP range" when Values::OpenPort then "Open #{value.protocol.upcase} Port" when Values::EmailAddress then "Email Address" when Values::Cert then "SSL/TLS Cert" when Values::URL then "URL" when Values::Website then "Website" when Values::Wildcard then "Wildcard" else raise(NotImplementedError,"value class #{value.class} not supported") end end |