Module: Masscan::Parsers::List
- Extended by:
- PlainText
- Defined in:
- lib/masscan/parsers/list.rb
Overview
Parses the masscan -oL
output format.
Constant Summary
Constants included from PlainText
PlainText::APP_PROTOCOLS, PlainText::IP_PROTOCOLS, PlainText::REASONS, PlainText::STATUSES
Class Method Summary collapse
-
.open(path) {|file| ... } ⇒ File
Opens a list file for parsing.
-
.parse(io) {|record| ... } ⇒ Enumerator
Parses the masscan simple list data.
-
.parse_payload(payload) ⇒ String
private
Parses a payload string and removes any
\\xXX
hex escaped characters.
Methods included from PlainText
parse_app_protocol, parse_ip, parse_ip_protocol, parse_reason, parse_status, parse_timestamp
Class Method Details
.open(path) {|file| ... } ⇒ File
Opens a list file for parsing.
33 34 35 |
# File 'lib/masscan/parsers/list.rb', line 33 def self.open(path,&block) File.open(path,&block) end |
.parse(io) {|record| ... } ⇒ Enumerator
Parses the masscan simple list data.
52 53 54 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 80 81 |
# File 'lib/masscan/parsers/list.rb', line 52 def self.parse(io) return enum_for(__method__,io) unless block_given? io.each_line do |line| line.chomp! if line.start_with?('open ') || line.start_with?('closed ') type, ip_proto, port, ip, = line.split(' ',5) yield Status.new( status: parse_status(type), protocol: parse_ip_protocol(ip_proto), port: port.to_i, ip: parse_ip(ip), timestamp: () ) elsif line.start_with?('banner ') type, ip_proto, port, ip, , app_proto, payload = line.split(' ',7) yield Banner.new( protocol: parse_ip_protocol(ip_proto), port: port.to_i, ip: parse_ip(ip), timestamp: (), app_protocol: parse_app_protocol(app_proto), payload: parse_payload(payload) ) end end end |
.parse_payload(payload) ⇒ String
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.
Parses a payload string and removes any \\xXX
hex escaped characters.
94 95 96 97 98 |
# File 'lib/masscan/parsers/list.rb', line 94 def self.parse_payload(payload) payload.gsub(/\\x[0-9a-f]{2}/) do |hex_escape| hex_escape[2..].to_i(16).chr end end |