Module: Ronin::Masscan::Converters::JSON Private
- Defined in:
- lib/ronin/masscan/converters/json.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Handles converting masscan scan files into JSON.
Class Method Summary collapse
-
.banner_as_json(banner) ⇒ Hash{Symbol => Object}
private
Converts a masscan record into a JSON representation.
-
.convert(masscan_file, output) ⇒ Object
private
Converts the masscan scan file to JSON.
-
.masscan_file_as_json(output_file) ⇒ Array<Hash{Symbol => Object}>
private
Converts a masscan scan file into JSON representation.
-
.masscan_file_to_json(masscan_file, output) ⇒ Object
private
Converts the masscan scan file to JSON.
-
.record_as_json(record) ⇒ Hash{Symbol => Object}
private
Converts a masscan record into a JSON representation.
-
.status_as_json(status) ⇒ Hash{Symbol => Object}
private
Converts a masscan status record into a JSON representation.
Class Method Details
.banner_as_json(banner) ⇒ Hash{Symbol => Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a masscan record into a JSON representation.
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/ronin/masscan/converters/json.rb', line 129 def self.() { protocol: .protocol, port: .port, ip: .ip, timestamp: ., app_protocol: .app_protocol, payload: .payload } end |
.convert(masscan_file, output) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts the masscan scan file to JSON.
42 43 44 |
# File 'lib/ronin/masscan/converters/json.rb', line 42 def self.convert(masscan_file,output) masscan_file_to_json(masscan_file,output) end |
.masscan_file_as_json(output_file) ⇒ Array<Hash{Symbol => Object}>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a masscan scan file into JSON representation.
68 69 70 71 72 |
# File 'lib/ronin/masscan/converters/json.rb', line 68 def self.masscan_file_as_json(output_file) output_file.each.map do |record| record_as_json(record) end end |
.masscan_file_to_json(masscan_file, output) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts the masscan scan file to JSON.
55 56 57 |
# File 'lib/ronin/masscan/converters/json.rb', line 55 def self.masscan_file_to_json(masscan_file,output) ::JSON.dump(masscan_file_as_json(masscan_file),output) end |
.record_as_json(record) ⇒ Hash{Symbol => Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a masscan record into a JSON representation.
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ronin/masscan/converters/json.rb', line 83 def self.record_as_json(record) case record when ::Masscan::Status status_as_json(record) when ::Masscan::Banner (record) else raise(NotImplementedError,"unable to convert masscan record: #{record.inspect}") end end |
.status_as_json(status) ⇒ Hash{Symbol => Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a masscan status record into a JSON representation.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ronin/masscan/converters/json.rb', line 103 def self.status_as_json(status) hash = { status: status.status, protocol: status.protocol, port: status.port, reason: status.reason, ttl: status.ttl, ip: status.ip, timestamp: status. } # omit the `mac` field if it's nil hash[:mac] = status.mac if status.mac return hash end |