ronin 2.0.0.beta1 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +72 -4
- data/data/new/project/Rakefile +3 -3
- data/data/new/project/project.rb.erb +1 -1
- data/gemspec.yml +12 -6
- data/lib/ronin/cli/char_set_options.rb +81 -68
- data/lib/ronin/cli/commands/dns.rb +3 -95
- data/lib/ronin/cli/commands/extract.rb +17 -7
- data/lib/ronin/cli/commands/grep.rb +17 -7
- data/lib/ronin/cli/commands/hexdump.rb +8 -2
- data/lib/ronin/cli/commands/host.rb +6 -88
- data/lib/ronin/cli/commands/http.rb +11 -11
- data/lib/ronin/cli/commands/public_suffix_list.rb +16 -2
- data/lib/ronin/cli/commands/tld_list.rb +16 -2
- data/lib/ronin/cli/dns.rb +136 -0
- data/lib/ronin/cli/pattern_options.rb +200 -85
- data/lib/ronin/cli.rb +5 -0
- data/lib/ronin/version.rb +1 -1
- data/man/ronin-extract.1 +52 -12
- data/man/ronin-extract.1.md +42 -12
- data/man/ronin-grep.1 +52 -12
- data/man/ronin-grep.1.md +42 -12
- data/man/ronin-http.1 +2 -2
- data/man/ronin-http.1.md +1 -1
- data/ronin.gemspec +2 -1
- metadata +15 -25
- data/spec/cli/command_spec.rb +0 -10
- data/spec/cli/commands/decode_spec.rb +0 -152
- data/spec/cli/commands/encode_spec.rb +0 -152
- data/spec/cli/commands/escape_spec.rb +0 -128
- data/spec/cli/commands/quote_spec.rb +0 -76
- data/spec/cli/commands/unescape_spec.rb +0 -128
- data/spec/cli/commands/unquote_spec.rb +0 -80
- data/spec/cli/fixtures/file.txt +0 -3
- data/spec/cli/fixtures/file2.txt +0 -3
- data/spec/cli/key_options_spec.rb +0 -56
- data/spec/cli/method_options_spec.rb +0 -71
- data/spec/cli/string_methods_command_spec.rb +0 -25
- data/spec/cli/string_processor_command_spec.rb +0 -258
- data/spec/cli/value_processor_command_spec.rb +0 -127
- data/spec/spec_helper.rb +0 -5
- data/spec/version_spec.rb +0 -11
@@ -275,8 +275,14 @@ module Ronin
|
|
275
275
|
@highlight_chars = {}
|
276
276
|
end
|
277
277
|
|
278
|
+
#
|
279
|
+
# Runs the `ronin hexdump` command.
|
280
|
+
#
|
281
|
+
# @param [Array<String>] files
|
282
|
+
# Additional files to hexdump.
|
283
|
+
#
|
278
284
|
def run(*files)
|
279
|
-
@hexdump = ::Hexdump::Hexdump.new(**
|
285
|
+
@hexdump = ::Hexdump::Hexdump.new(**hexdump_kwargs)
|
280
286
|
|
281
287
|
super(*files)
|
282
288
|
end
|
@@ -432,7 +438,7 @@ module Ronin
|
|
432
438
|
#
|
433
439
|
# @return [Hash{Symbol => Object}]
|
434
440
|
#
|
435
|
-
def
|
441
|
+
def hexdump_kwargs
|
436
442
|
kwargs = {}
|
437
443
|
|
438
444
|
HEXDUMP_OPTIONS.each do |key|
|
@@ -17,6 +17,7 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'ronin/cli/value_processor_command'
|
20
|
+
require 'ronin/cli/dns'
|
20
21
|
require 'ronin/support/network/host'
|
21
22
|
|
22
23
|
require 'wordlist/file'
|
@@ -60,6 +61,8 @@ module Ronin
|
|
60
61
|
#
|
61
62
|
class Host < ValueProcessorCommand
|
62
63
|
|
64
|
+
include DNS
|
65
|
+
|
63
66
|
usage '[options] [HOST ...]'
|
64
67
|
|
65
68
|
option :subdomain, value: {
|
@@ -99,15 +102,6 @@ module Ronin
|
|
99
102
|
},
|
100
103
|
desc: 'Enumerates over every subdomain in the wordlist'
|
101
104
|
|
102
|
-
option :nameserver, short: '-N',
|
103
|
-
value: {
|
104
|
-
type: String,
|
105
|
-
usage: 'HOST|IP'
|
106
|
-
},
|
107
|
-
desc: 'Send DNS queries to the nameserver' do |ip|
|
108
|
-
@nameservers << ip
|
109
|
-
end
|
110
|
-
|
111
105
|
option :ips, short: '-I',
|
112
106
|
desc: "Converts the hostname to it's IP addresses"
|
113
107
|
|
@@ -155,21 +149,6 @@ module Ronin
|
|
155
149
|
|
156
150
|
man_page 'ronin-host.1'
|
157
151
|
|
158
|
-
#
|
159
|
-
# Initializes the `ronin dns` command.
|
160
|
-
#
|
161
|
-
def initialize(**kwargs)
|
162
|
-
super(**kwargs)
|
163
|
-
|
164
|
-
@nameservers = []
|
165
|
-
end
|
166
|
-
|
167
|
-
def dns_options
|
168
|
-
kwargs = {}
|
169
|
-
kwargs[:nameservers] = @nameservers unless @nameservers.empty?
|
170
|
-
kwargs
|
171
|
-
end
|
172
|
-
|
173
152
|
#
|
174
153
|
# Queries the given host.
|
175
154
|
#
|
@@ -228,7 +207,9 @@ module Ronin
|
|
228
207
|
elsif options[:has_addresses]
|
229
208
|
puts host if host.has_addresses?
|
230
209
|
elsif options[:has_records]
|
231
|
-
|
210
|
+
records = host.get_records(options[:has_records])
|
211
|
+
|
212
|
+
puts host unless records.empty?
|
232
213
|
elsif options[:query]
|
233
214
|
print_records(query_records(host))
|
234
215
|
else
|
@@ -236,69 +217,6 @@ module Ronin
|
|
236
217
|
end
|
237
218
|
end
|
238
219
|
|
239
|
-
#
|
240
|
-
# Queries the records for the given host name.
|
241
|
-
#
|
242
|
-
# @param [String] host
|
243
|
-
# The host name to query.
|
244
|
-
#
|
245
|
-
# @return [Array<Resolv::DNS::Resource>]
|
246
|
-
# The returned DNS resource records.
|
247
|
-
#
|
248
|
-
def query_records(host)
|
249
|
-
if options[:type]
|
250
|
-
resolver.get_records(host,options[:type].downcase)
|
251
|
-
else
|
252
|
-
resolver.get_a_records(host) + resolver.get_aaaa_records(host)
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
#
|
257
|
-
# Prints multiple DNS records.
|
258
|
-
#
|
259
|
-
# @param [Array<Resolv::DNS::Resource>] records
|
260
|
-
# The DNS resource records to print.
|
261
|
-
#
|
262
|
-
def print_records(records)
|
263
|
-
records.each do |record|
|
264
|
-
print_record(record)
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
#
|
269
|
-
# Prints a DNS record.
|
270
|
-
#
|
271
|
-
# @param [Resolv::DNS::Resource] record
|
272
|
-
# The DNS resource record to print.
|
273
|
-
#
|
274
|
-
def print_record(record)
|
275
|
-
case record
|
276
|
-
when Resolv::DNS::Resource::IN::A,
|
277
|
-
Resolv::DNS::Resource::IN::AAAA
|
278
|
-
puts record.address
|
279
|
-
when Resolv::DNS::Resource::IN::NS,
|
280
|
-
Resolv::DNS::Resource::IN::CNAME,
|
281
|
-
Resolv::DNS::Resource::IN::PTR
|
282
|
-
puts record.name
|
283
|
-
when Resolv::DNS::Resource::IN::MX
|
284
|
-
puts record.exchange
|
285
|
-
when Resolv::DNS::Resource::IN::TXT
|
286
|
-
puts record.strings.join
|
287
|
-
when Resolv::DNS::Resource::IN::HINFO
|
288
|
-
puts "#{record.cpu} #{record.os}"
|
289
|
-
when Resolv::DNS::Resource::IN::LOC
|
290
|
-
puts "#{record.latitude} #{record.longitude}"
|
291
|
-
when Resolv::DNS::Resource::IN::MINFO
|
292
|
-
puts "#{record.emailbx}@#{record.rmailbx}"
|
293
|
-
when Resolv::DNS::Resource::IN::SOA
|
294
|
-
puts "#{record.mname} #{record.rname} #{record.serial} #{record.refresh} #{record.retry} #{record.expire} #{record.ttl}"
|
295
|
-
when Resolv::DNS::Resource::IN::SRV
|
296
|
-
puts "#{record.port} #{record.priority} #{record.weight} #{record.target}"
|
297
|
-
when Resolv::DNS::Resource::IN::WKS
|
298
|
-
puts "#{record.address} #{record.protocol}"
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
220
|
end
|
303
221
|
end
|
304
222
|
end
|
@@ -319,17 +319,17 @@ module Ronin
|
|
319
319
|
def process_value(url)
|
320
320
|
url = URI(url)
|
321
321
|
|
322
|
-
Support::Network::HTTP.
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
322
|
+
Support::Network::HTTP.request(
|
323
|
+
@http_method, url, proxy: @proxy,
|
324
|
+
user_agent: @user_agent,
|
325
|
+
user: url.user,
|
326
|
+
password: url.password,
|
327
|
+
query_params: @query_params,
|
328
|
+
headers: @headers,
|
329
|
+
body: @body,
|
330
|
+
form_data: @form_data,
|
331
|
+
&method(:print_response)
|
332
|
+
)
|
333
333
|
end
|
334
334
|
|
335
335
|
#
|
@@ -69,8 +69,11 @@ module Ronin
|
|
69
69
|
|
70
70
|
man_page 'ronin-public-suffix-list.1'
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
#
|
73
|
+
# Runs the `ronin public-suffix-list` command.
|
74
|
+
#
|
75
|
+
def run
|
76
|
+
if !downloaded?
|
74
77
|
download
|
75
78
|
elsif options[:update] || stale?
|
76
79
|
update
|
@@ -83,9 +86,20 @@ module Ronin
|
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
89
|
+
#
|
90
|
+
# Determines if the public suffix list file has been downloaded yet.
|
91
|
+
#
|
92
|
+
# @return [Boolean]
|
93
|
+
#
|
94
|
+
def downloaded?
|
95
|
+
List.downloaded?(options[:path])
|
96
|
+
end
|
97
|
+
|
86
98
|
#
|
87
99
|
# Determines if the public suffix list file is stale.
|
88
100
|
#
|
101
|
+
# @return [Boolean]
|
102
|
+
#
|
89
103
|
def stale?
|
90
104
|
List.stale?(options[:path])
|
91
105
|
end
|
@@ -69,8 +69,11 @@ module Ronin
|
|
69
69
|
|
70
70
|
man_page 'ronin-tld-list.1'
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
#
|
73
|
+
# Runs the `ronin tld-list` command.
|
74
|
+
#
|
75
|
+
def run
|
76
|
+
if !downloaded?
|
74
77
|
download
|
75
78
|
elsif options[:update] || stale?
|
76
79
|
update
|
@@ -83,9 +86,20 @@ module Ronin
|
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
89
|
+
#
|
90
|
+
# Determines if the TLD list file has been downloaded already.
|
91
|
+
#
|
92
|
+
# @return [Boolean]
|
93
|
+
#
|
94
|
+
def downloaded?
|
95
|
+
List.downloaded?(options[:path])
|
96
|
+
end
|
97
|
+
|
86
98
|
#
|
87
99
|
# Determines if the TLD list file is stale.
|
88
100
|
#
|
101
|
+
# @return [Boolean]
|
102
|
+
#
|
89
103
|
def stale?
|
90
104
|
List.stale?(options[:path])
|
91
105
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
|
+
#
|
5
|
+
# Ronin is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# Ronin is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with Ronin. If not, see <https://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'ronin/support/network/dns'
|
20
|
+
|
21
|
+
module Ronin
|
22
|
+
class CLI
|
23
|
+
module DNS
|
24
|
+
#
|
25
|
+
# Adds the `-N,--nameserver HOST|IP` option to the command which is
|
26
|
+
# including {DNS}.
|
27
|
+
#
|
28
|
+
# @param [Class<Command>] command
|
29
|
+
# The command which is including {DNS}.
|
30
|
+
#
|
31
|
+
def self.included(command)
|
32
|
+
command.option :nameserver, short: '-N',
|
33
|
+
value: {
|
34
|
+
type: String,
|
35
|
+
usage: 'HOST|IP'
|
36
|
+
},
|
37
|
+
desc: 'Send DNS queries to the nameserver' do |ip|
|
38
|
+
@nameservers << ip
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# The configured nameservers to query.
|
43
|
+
#
|
44
|
+
# @return [Array<String>]
|
45
|
+
attr_reader :nameservers
|
46
|
+
|
47
|
+
#
|
48
|
+
# Initializes the command.
|
49
|
+
#
|
50
|
+
def initialize(**kwargs)
|
51
|
+
super(**kwargs)
|
52
|
+
|
53
|
+
@nameservers = []
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# The resolver to use.
|
58
|
+
#
|
59
|
+
# @return [Ronin::Network::DNS::Resolver]
|
60
|
+
# The DNS resolver.
|
61
|
+
#
|
62
|
+
def resolver
|
63
|
+
@resolver ||= unless @nameservers.empty?
|
64
|
+
Support::Network::DNS.resolver(
|
65
|
+
nameservers: @nameservers
|
66
|
+
)
|
67
|
+
else
|
68
|
+
Support::Network::DNS.resolver
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# Queries the records for the given host name.
|
74
|
+
#
|
75
|
+
# @param [String] host
|
76
|
+
# The host name to query.
|
77
|
+
#
|
78
|
+
# @return [Array<Resolv::DNS::Resource>]
|
79
|
+
# The returned DNS resource records.
|
80
|
+
#
|
81
|
+
def query_records(host)
|
82
|
+
if options[:type]
|
83
|
+
resolver.get_records(host,options[:type].downcase)
|
84
|
+
else
|
85
|
+
resolver.get_a_records(host) + resolver.get_aaaa_records(host)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# Prints multiple DNS records.
|
91
|
+
#
|
92
|
+
# @param [Array<Resolv::DNS::Resource>] records
|
93
|
+
# The DNS resource records to print.
|
94
|
+
#
|
95
|
+
def print_records(records)
|
96
|
+
records.each do |record|
|
97
|
+
print_record(record)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# Prints a DNS record.
|
103
|
+
#
|
104
|
+
# @param [Resolv::DNS::Resource] record
|
105
|
+
# The DNS resource record to print.
|
106
|
+
#
|
107
|
+
def print_record(record)
|
108
|
+
case record
|
109
|
+
when Resolv::DNS::Resource::IN::A,
|
110
|
+
Resolv::DNS::Resource::IN::AAAA
|
111
|
+
puts record.address
|
112
|
+
when Resolv::DNS::Resource::IN::NS,
|
113
|
+
Resolv::DNS::Resource::IN::CNAME,
|
114
|
+
Resolv::DNS::Resource::IN::PTR
|
115
|
+
puts record.name
|
116
|
+
when Resolv::DNS::Resource::IN::MX
|
117
|
+
puts record.exchange
|
118
|
+
when Resolv::DNS::Resource::IN::TXT
|
119
|
+
puts record.strings.join
|
120
|
+
when Resolv::DNS::Resource::IN::HINFO
|
121
|
+
puts "#{record.cpu} #{record.os}"
|
122
|
+
when Resolv::DNS::Resource::IN::LOC
|
123
|
+
puts "#{record.latitude} #{record.longitude}"
|
124
|
+
when Resolv::DNS::Resource::IN::MINFO
|
125
|
+
puts "#{record.emailbx}@#{record.rmailbx}"
|
126
|
+
when Resolv::DNS::Resource::IN::SOA
|
127
|
+
puts "#{record.mname} #{record.rname} #{record.serial} #{record.refresh} #{record.retry} #{record.expire} #{record.ttl}"
|
128
|
+
when Resolv::DNS::Resource::IN::SRV
|
129
|
+
puts "#{record.port} #{record.priority} #{record.weight} #{record.target}"
|
130
|
+
when Resolv::DNS::Resource::IN::WKS
|
131
|
+
puts "#{record.address} #{record.protocol}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|