Module: Ronin::Nmap::Converters::CSV Private
- Defined in:
- lib/ronin/nmap/converters/csv.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 nmap XML into CSV.
Constant Summary collapse
- HEADER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
CSV rows header.
%w[host.start_time host.end_time host.status host.ip port.protocol port.number port.status port.reason port.reason_ttl service.name service.ssl service.protocol service.produce service.version service.extra_info service.hostnmae service.os_type service.device_type service.fingerprint_method service.fingerprint service.confidence]
Class Method Summary collapse
-
.convert(xml, output) ⇒ Object
private
Converts parsed nmap XML into CSV.
-
.each_host_rows(host) {|row| ... } ⇒ Object
private
Converts a nmap XML host into a series of rows.
-
.port_to_row(port) ⇒ Array
private
Converts a nmap XML port into a row.
-
.service_to_row(service) ⇒ Array
private
Converts a nmap XML service into a series of rows.
-
.xml_to_csv(xml, output) ⇒ Object
private
Converts parsed XML to CSV.
-
.xml_to_rows(xml) {|row| ... } ⇒ Object
private
Converts parsed nmap XML to a series of rows.
Class Method Details
.convert(xml, 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 parsed nmap XML into CSV.
40 41 42 |
# File 'lib/ronin/nmap/converters/csv.rb', line 40 def self.convert(xml,output) xml_to_csv(xml,output) end |
.each_host_rows(host) {|row| ... } ⇒ 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 nmap XML host into a series of rows.
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ronin/nmap/converters/csv.rb', line 96 def self.each_host_rows(host) host_row = [ host.start_time, host.end_time, host.status, host.ip ] host.each_port do |port| yield(host_row + port_to_row(port)) end end |
.port_to_row(port) ⇒ Array
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 nmap XML port into a row.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/ronin/nmap/converters/csv.rb', line 118 def self.port_to_row(port) row = [ port.protocol, port.number, port.state, port.reason, port.reason_ttl ] if (service = port.service) row.concat(service_to_row(service)) end return row end |
.service_to_row(service) ⇒ Array
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 nmap XML service into a series of rows.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/ronin/nmap/converters/csv.rb', line 143 def self.service_to_row(service) [ service.name, service.ssl?, service.protocol, service.product, service.version, service.extra_info, service.hostname, service.os_type, service.device_type, service.fingerprint_method, service.fingerprint, service.confidence ] end |
.xml_to_csv(xml, 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 parsed XML to CSV.
53 54 55 56 57 |
# File 'lib/ronin/nmap/converters/csv.rb', line 53 def self.xml_to_csv(xml,output) xml_to_rows(xml) do |row| output << ::CSV.generate_line(row) end end |
.xml_to_rows(xml) {|row| ... } ⇒ 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 parsed nmap XML to a series of rows.
74 75 76 77 78 79 80 81 82 |
# File 'lib/ronin/nmap/converters/csv.rb', line 74 def self.xml_to_rows(xml) yield HEADER xml.each_host do |host| each_host_rows(host) do |row| yield row end end end |