ruby-masscan 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +15 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +6 -6
- data/lib/masscan/command.rb +10 -8
- 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: bd5ccf856ca875649425af00ffe4f90092cc81e250b30a54c640acd575504387
|
4
|
+
data.tar.gz: b1f064fe48e81cee639f7a32d8e0b77334593ba757ff30d8f554c2fb3a4860bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec9bc404c40601950b44f6414af17809cf42132b2ee8e83e26268ede21ee297f33f9ae843f9aacc650861d0ffeba3bfe75268293d56b488aebbd1d2b476b8154
|
7
|
+
data.tar.gz: '06797c919c865cbe5147cdb79412883a174ca3835f72706881f1f99b58becf65836a200be6afd1b9e85f5efeac4f19e98e5aaf9ca4a08811afbdbcc200f2df86'
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
### 0.2.2 / 2023-04-20
|
2
|
+
|
3
|
+
* Corrected option definitions:
|
4
|
+
* The `--range` option expects a IP or CIDR range value.
|
5
|
+
* The `--exclude` option requires a value.
|
6
|
+
* `--range`, `--exclude`, `--excludefile`, `--includefile` options may be
|
7
|
+
repeated.
|
8
|
+
* The --pcap-payloads` option expects a file.
|
9
|
+
* The `--retries` option requires an argument.
|
10
|
+
|
11
|
+
### 0.2.1 / 2023-03-15
|
12
|
+
|
13
|
+
* Unescape `\\xXX` hex escaped characters in payload strings parsed from `.list`
|
14
|
+
masscan files.
|
15
|
+
|
1
16
|
### 0.2.0 / 2021-11-30
|
2
17
|
|
3
18
|
* Replaced the `rprogram` dependency with [command_mapper].
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -82,11 +82,11 @@ end
|
|
82
82
|
#<struct Masscan::Status status=:open, protocol=:tcp, port=443, reason=nil, ttl=nil, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:50 -0700, mac=nil>
|
83
83
|
#<struct Masscan::Status status=:open, protocol=:tcp, port=80, reason=nil, ttl=nil, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:50 -0700, mac=nil>
|
84
84
|
#<struct Masscan::Status status=:open, protocol=:icmp, port=0, reason=nil, ttl=nil, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:50 -0700, mac=nil>
|
85
|
-
#<struct Masscan::Banner protocol=:tcp, port=443, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:ssl3, payload="TLS/1.1 cipher:0xc013, www.example.org, www.example.org, example.com, example.edu, example.net, example.org, www.example.com, www.example.edu, www.example.net">
|
86
|
-
#<struct Masscan::Banner protocol=:tcp, port=443, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:x509, payload="MIIG1TCCBb2gAwIBAgIQD74IsIVNBXOKsMzhya/uyTANBgkqhkiG9w0BAQsFADBPMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMSkwJwYDVQQDEyBEaWdpQ2VydCBUTFMgUlNBIFNIQTI1NiAyMDIwIENBMTAeFw0yMDExMjQwMDAwMDBaFw0yMTEyMjUyMzU5NTlaMIGQMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEUMBIGA1UEBxMLTG9zIEFuZ2VsZXMxPD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-25 23:47:52 -0700, app_protocol=:http_server, payload="ECS (sec/974D)">
|
88
|
-
#<struct Masscan::Banner protocol=:tcp, port=80, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:html_title, payload="404 - Not Found">
|
89
|
-
#<struct Masscan::Banner protocol=:tcp, port=80, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:http, payload="HTTP/1.0 404 Not Found
|
85
|
+
#<struct Masscan::Banner protocol=:tcp, port=443, ttl=nil, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:ssl3, payload="TLS/1.1 cipher:0xc013, www.example.org, www.example.org, example.com, example.edu, example.net, example.org, www.example.com, www.example.edu, www.example.net">
|
86
|
+
#<struct Masscan::Banner protocol=:tcp, port=443, ttl=nil, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:x509, payload="MIIG1TCCBb2gAwIBAgIQD74IsIVNBXOKsMzhya/uyTANBgkqhkiG9w0BAQsFADBPMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMSkwJwYDVQQDEyBEaWdpQ2VydCBUTFMgUlNBIFNIQTI1NiAyMDIwIENBMTAeFw0yMDExMjQwMDAwMDBaFw0yMTEyMjUyMzU5NTlaMIGQMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEUMBIGA1UEBxMLTG9zIEFuZ2VsZXMxPDA6BgNVBAoTM0ludGVybmV0IENvcnBvcmF0aW9uIGZvciBBc3NpZ25lZCBOYW1lcyBhbmQgTnVtYmVyczEYMBYGA1UEAxMPd3d3LmV4YW1wbGUub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuvzuzMoKCP8Okx2zvgucA5YinrFPEK5RQP1TX7PEYUAoBO6i5hIAsIKFmFxtW2sghERilU5rdnxQcF3fEx3sY4OtY6VSBPLPhLrbKozHLrQ8ZN/rYTb+hgNUeT7NA1mP78IEkxAj4qG5tli4Jq41aCbUlCt7equGXokImhC+UY5IpQEZS0tKD4vu2ksZ04Qetp0k8jWdAvMA27W3EwgHHNeVGWbJPC0Dn7RqPw13r7hFyS5TpleywjdY1nB7ad6kcZXZbEcaFZ7ZuerA6RkPGE+PsnZRb1oFJkYoXimsuvkVFhWeHQXCGC1cuDWSrM3cpQvOzKH2vS7d15+zGls4IwIDAQABo4IDaTCCA2UwHwYDVR0jBBgwFoAUt2ui6qiqhIx56rTaD5iyxZV2ufQwHQYDVR0OBBYEFCYa+OSxsHKEztqBBtInmPvtOj0XMIGBBgNVHREEejB4gg93d3cuZXhhbXBsZS5vcmeCC2V4YW1wbGUuY29tggtleGFtcGxlLmVkdYILZXhhbXBsZS5uZXSCC2V4YW1wbGUub3Jngg93d3cuZXhhbXBsZS5jb22CD3d3dy5leGFtcGxlLmVkdYIPd3d3LmV4YW1wbGUubmV0MA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwgYsGA1UdHwSBgzCBgDA+oDygOoY4aHR0cDovL2NybDMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0VExTUlNBU0hBMjU2MjAyMENBMS5jcmwwPqA8oDqGOGh0dHA6Ly9jcmw0LmRpZ2ljZXJ0LmNv">
|
87
|
+
#<struct Masscan::Banner protocol=:tcp, port=80, ttl=nil, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:http_server, payload="ECS (sec/974D)">
|
88
|
+
#<struct Masscan::Banner protocol=:tcp, port=80, ttl=nil, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:html_title, payload="404 - Not Found">
|
89
|
+
#<struct Masscan::Banner protocol=:tcp, port=80, ttl=nil, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-25 23:47:52 -0700, app_protocol=:http, payload="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">
|
90
90
|
```
|
91
91
|
|
92
92
|
Parse `masscan` JSON output files:
|
@@ -135,7 +135,7 @@ gem 'ruby-masscan', '~> 0.2'
|
|
135
135
|
|
136
136
|
## License
|
137
137
|
|
138
|
-
Copyright (c) 2021 Hal Brodigan
|
138
|
+
Copyright (c) 2021-2023 Hal Brodigan
|
139
139
|
|
140
140
|
See {file:LICENSE.txt} for license information.
|
141
141
|
|
data/lib/masscan/command.rb
CHANGED
@@ -7,11 +7,11 @@ module Masscan
|
|
7
7
|
# ## Example
|
8
8
|
#
|
9
9
|
# require 'masscan/command'
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# Masscan::Command.sudo do |masscan|
|
12
12
|
# masscan.output_format = :list
|
13
13
|
# masscan.output_file = 'masscan.txt'
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# masscan.ips = '192.168.1.1/24'
|
16
16
|
# masscan.ports = [20,21,22,23,25,80,110,443,512,522,8080,1080]
|
17
17
|
# end
|
@@ -82,6 +82,8 @@ module Masscan
|
|
82
82
|
#
|
83
83
|
# @see https://github.com/robertdavidgraham/masscan/blob/master/doc/masscan.8.markdown
|
84
84
|
#
|
85
|
+
# @since 0.2.0
|
86
|
+
#
|
85
87
|
class Command < CommandMapper::Command
|
86
88
|
|
87
89
|
class PortList < CommandMapper::Types::Num
|
@@ -157,7 +159,7 @@ module Masscan
|
|
157
159
|
end
|
158
160
|
|
159
161
|
command "masscan" do
|
160
|
-
option '--range', name: :range, value:
|
162
|
+
option '--range', name: :range, value: true, repeats: true
|
161
163
|
option '-p', name: :ports, value: {type: PortList.new}
|
162
164
|
option '--banners', name: :banners
|
163
165
|
option '--rate', name: :rate, value: {type: Num.new}
|
@@ -171,14 +173,14 @@ module Masscan
|
|
171
173
|
option '--adapter-vlan', name: :adapter_vlan, value: true
|
172
174
|
option '--router-mac', name: :router_mac, value: true
|
173
175
|
option '--ping', name: :ping
|
174
|
-
option '--exclude', name: :exclude, value:
|
175
|
-
option '--excludefile', name: :exclude_file, value: {type: InputFile.new}
|
176
|
-
option '--includefile', name: :include_file, value: {type: InputFile.new}
|
176
|
+
option '--exclude', name: :exclude, value: true, repeats: true
|
177
|
+
option '--excludefile', name: :exclude_file, value: {type: InputFile.new}, repeats: true
|
178
|
+
option '--includefile', name: :include_file, value: {type: InputFile.new}, repeats: true
|
177
179
|
option '--append-output', name: :append_output
|
178
180
|
option '--iflist', name: :list_interfaces
|
179
|
-
option '--retries', name: :retries
|
181
|
+
option '--retries', name: :retries, value: {type: Num.new}
|
180
182
|
option '--nmap', name: :nmap_help
|
181
|
-
option '--pcap-payloads', name: :pcap_payloads
|
183
|
+
option '--pcap-payloads', name: :pcap_payloads, value: {type: InputFile.new}
|
182
184
|
option '--nmap-payloads', name: :nmap_payloads, value: {type: InputFile.new}
|
183
185
|
|
184
186
|
option '--http-method', name: :http_method, value: true
|
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.2
|
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-04-20 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.
|