ruby-masscan 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +5 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/masscan/command.rb +2 -0
- data/lib/masscan/parsers/list.rb +19 -2
- data/lib/masscan/version.rb +1 -1
- data/lib/masscan.rb +1 -0
- data/spec/parsers/list_spec.rb +25 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 064d7200b60b80a1ed4f0459239235d21f96587a3199833988dd5953728cd168
|
4
|
+
data.tar.gz: 619757cb909fcec538c63ef5d37d2cb1f1029509d71e957be9aa6f74726ad4ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d9fa47ab80653e00c4d3f16b02e1cbe824575d0979b43596f7a52c703b9eda0616882e8bd7effdb77a3f9bfafe40b50043ace08a06f4725b59335dab724fee2
|
7
|
+
data.tar.gz: ad559b68f9af88c2c2e1b66711a93b3bceda9962cd0b3f1f478400a0f1dd7d79a7a87eab81eef4ff9c1cca426c135732d05437affb757fdc3d1ebcfc64b681b2
|
data/ChangeLog.md
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
data/lib/masscan/command.rb
CHANGED
data/lib/masscan/parsers/list.rb
CHANGED
@@ -64,7 +64,7 @@ module Masscan
|
|
64
64
|
timestamp: parse_timestamp(timestamp)
|
65
65
|
)
|
66
66
|
elsif line.start_with?('banner ')
|
67
|
-
type, ip_proto, port, ip, timestamp, app_proto,
|
67
|
+
type, ip_proto, port, ip, timestamp, app_proto, payload = line.split(' ',7)
|
68
68
|
|
69
69
|
yield Banner.new(
|
70
70
|
protocol: parse_ip_protocol(ip_proto),
|
@@ -72,11 +72,28 @@ module Masscan
|
|
72
72
|
ip: parse_ip(ip),
|
73
73
|
timestamp: parse_timestamp(timestamp),
|
74
74
|
app_protocol: parse_app_protocol(app_proto),
|
75
|
-
payload:
|
75
|
+
payload: parse_payload(payload)
|
76
76
|
)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Parses a payload string and removes any `\\xXX` hex escaped characters.
|
83
|
+
#
|
84
|
+
# @param [String] payload
|
85
|
+
# The payload string to unescape.
|
86
|
+
#
|
87
|
+
# @return [String]
|
88
|
+
# The raw payload string.
|
89
|
+
#
|
90
|
+
# @api private
|
91
|
+
#
|
92
|
+
def self.parse_payload(payload)
|
93
|
+
payload.gsub(/\\x[0-9a-f]{2}/) do |hex_escape|
|
94
|
+
hex_escape[2..].to_i(16).chr
|
95
|
+
end
|
96
|
+
end
|
80
97
|
end
|
81
98
|
end
|
82
99
|
end
|
data/lib/masscan/version.rb
CHANGED
data/lib/masscan.rb
CHANGED
data/spec/parsers/list_spec.rb
CHANGED
@@ -104,6 +104,31 @@ describe Masscan::Parsers::List do
|
|
104
104
|
expect(yielded_banner.service).to eq(service_keyword)
|
105
105
|
expect(yielded_banner.payload).to eq(payload)
|
106
106
|
end
|
107
|
+
|
108
|
+
context "when the payload field contains '\\xXX' hex escaped characters" do
|
109
|
+
let(:escaped_payload) do
|
110
|
+
"HTTP/1.0 404 Not Found\\x0d\\x0aContent-Type: text/html\\x0d\\x0aDate: Thu, 26 Aug 2021 06:47:52 GMT\\x0d\\x0aServer: ECS (sec/974D)\\x0d\\x0aContent-Length: 345\\x0d\\x0aConnection: close\\x0d\\x0a\\x0d"
|
111
|
+
end
|
112
|
+
let(:unescaped_payload) do
|
113
|
+
"HTTP/1.0 404 Not Found\r\nContent-Type: text/html\r\nDate: Thu, 26 Aug 2021 06:47:52 GMT\r\nServer: ECS (sec/974D)\r\nContent-Length: 345\r\nConnection: close\r\n\r"
|
114
|
+
end
|
115
|
+
|
116
|
+
let(:line) do
|
117
|
+
"banner #{protocol} #{port} #{ip} #{timestamp.to_i} #{service_name} #{escaped_payload}"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "must unescape the '\\xXX' hex escaped characters" do
|
121
|
+
yielded_records = []
|
122
|
+
|
123
|
+
subject.parse(io) do |record|
|
124
|
+
yielded_records << record
|
125
|
+
end
|
126
|
+
|
127
|
+
yielded_banner = yielded_records.first
|
128
|
+
|
129
|
+
expect(yielded_banner.payload).to eq(unescaped_payload)
|
130
|
+
end
|
131
|
+
end
|
107
132
|
end
|
108
133
|
end
|
109
134
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-masscan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: command_mapper
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements:
|
113
113
|
- masscan >= 1.0.0
|
114
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.3.26
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: A Ruby interface to masscan.
|