ronin-support 1.0.0.beta3 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +14 -0
- data/.rubocop.yml +109 -0
- data/ChangeLog.md +12 -1
- data/Gemfile +8 -4
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/examples/ssl_proxy.rb +2 -1
- data/examples/tcp_proxy.rb +6 -4
- data/lib/ronin/support/archive/tar/writer.rb +2 -2
- data/lib/ronin/support/archive/tar.rb +4 -4
- data/lib/ronin/support/archive/zip/reader.rb +2 -2
- data/lib/ronin/support/binary/array.rb +4 -7
- data/lib/ronin/support/binary/bit_flip.rb +7 -1
- data/lib/ronin/support/binary/buffer.rb +22 -22
- data/lib/ronin/support/binary/byte_slice.rb +17 -17
- data/lib/ronin/support/binary/cstring.rb +7 -4
- data/lib/ronin/support/binary/ctypes/arch/arm/big_endian.rb +4 -0
- data/lib/ronin/support/binary/ctypes/arch/arm.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/arm64/big_endian.rb +4 -0
- data/lib/ronin/support/binary/ctypes/arch/arm64.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/mips/little_endian.rb +4 -0
- data/lib/ronin/support/binary/ctypes/arch/mips.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/mips64/little_endian.rb +4 -0
- data/lib/ronin/support/binary/ctypes/arch/mips64.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/ppc.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/ppc64.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/x86.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/x86_64.rb +3 -0
- data/lib/ronin/support/binary/ctypes/array_type.rb +1 -1
- data/lib/ronin/support/binary/ctypes/big_endian.rb +3 -0
- data/lib/ronin/support/binary/ctypes/enum_type.rb +2 -2
- data/lib/ronin/support/binary/ctypes/little_endian.rb +3 -0
- data/lib/ronin/support/binary/ctypes/native.rb +3 -0
- data/lib/ronin/support/binary/ctypes/scalar_type.rb +2 -2
- data/lib/ronin/support/binary/ctypes/struct_type.rb +3 -3
- data/lib/ronin/support/binary/ctypes/type_resolver.rb +7 -8
- data/lib/ronin/support/binary/ctypes/unbounded_array_type.rb +1 -1
- data/lib/ronin/support/binary/ctypes/union_type.rb +3 -3
- data/lib/ronin/support/binary/ctypes.rb +3 -3
- data/lib/ronin/support/binary/memory.rb +2 -2
- data/lib/ronin/support/binary/packet.rb +3 -0
- data/lib/ronin/support/binary/stack.rb +3 -4
- data/lib/ronin/support/binary/struct/member.rb +5 -3
- data/lib/ronin/support/binary/struct.rb +81 -79
- data/lib/ronin/support/binary/template.rb +1 -0
- data/lib/ronin/support/binary/unhexdump/parser.rb +11 -11
- data/lib/ronin/support/binary/union.rb +22 -22
- data/lib/ronin/support/cli/ansi.rb +0 -1
- data/lib/ronin/support/cli/io_shell/core_ext/io.rb +1 -1
- data/lib/ronin/support/cli/io_shell.rb +4 -4
- data/lib/ronin/support/cli/printing.rb +3 -3
- data/lib/ronin/support/compression/zlib.rb +1 -1
- data/lib/ronin/support/core_ext/enumerable.rb +0 -2
- data/lib/ronin/support/core_ext/file.rb +1 -1
- data/lib/ronin/support/core_ext/kernel.rb +6 -5
- data/lib/ronin/support/core_ext/string.rb +2 -2
- data/lib/ronin/support/crypto/cert.rb +11 -15
- data/lib/ronin/support/crypto/cert_chain.rb +1 -1
- data/lib/ronin/support/crypto/cipher/aes.rb +3 -0
- data/lib/ronin/support/crypto/cipher/aes128.rb +4 -1
- data/lib/ronin/support/crypto/cipher/aes256.rb +4 -1
- data/lib/ronin/support/crypto/cipher.rb +1 -1
- data/lib/ronin/support/crypto/core_ext/file.rb +1 -1
- data/lib/ronin/support/crypto/key/methods.rb +4 -1
- data/lib/ronin/support/crypto/key.rb +5 -2
- data/lib/ronin/support/crypto/openssl.rb +1 -1
- data/lib/ronin/support/crypto.rb +0 -1
- data/lib/ronin/support/encoding/base16.rb +1 -1
- data/lib/ronin/support/encoding/base32.rb +28 -17
- data/lib/ronin/support/encoding/c/core_ext/integer.rb +1 -1
- data/lib/ronin/support/encoding/c.rb +4 -4
- data/lib/ronin/support/encoding/hex.rb +2 -2
- data/lib/ronin/support/encoding/js/core_ext/integer.rb +1 -1
- data/lib/ronin/support/encoding/js.rb +4 -4
- data/lib/ronin/support/encoding/powershell/core_ext/integer.rb +2 -2
- data/lib/ronin/support/encoding/powershell.rb +4 -5
- data/lib/ronin/support/encoding/ruby.rb +4 -4
- data/lib/ronin/support/encoding/shell/core_ext/integer.rb +2 -2
- data/lib/ronin/support/encoding/shell.rb +3 -3
- data/lib/ronin/support/encoding/sql.rb +1 -1
- data/lib/ronin/support/encoding/xml.rb +2 -2
- data/lib/ronin/support/encoding.rb +95 -0
- data/lib/ronin/support/network/asn/list.rb +6 -1
- data/lib/ronin/support/network/asn/record.rb +3 -0
- data/lib/ronin/support/network/asn/record_set.rb +3 -0
- data/lib/ronin/support/network/asn.rb +167 -6
- data/lib/ronin/support/network/dns/resolver.rb +3 -0
- data/lib/ronin/support/network/domain.rb +21 -21
- data/lib/ronin/support/network/email_address.rb +1 -5
- data/lib/ronin/support/network/esmtp/mixin.rb +1 -0
- data/lib/ronin/support/network/ftp/mixin.rb +1 -1
- data/lib/ronin/support/network/host.rb +75 -47
- data/lib/ronin/support/network/http/core_ext.rb +1 -1
- data/lib/ronin/support/network/http.rb +317 -80
- data/lib/ronin/support/network/ip.rb +8 -10
- data/lib/ronin/support/network/ip_range/cidr.rb +1 -5
- data/lib/ronin/support/network/ip_range/glob.rb +1 -0
- data/lib/ronin/support/network/ip_range/range.rb +1 -1
- data/lib/ronin/support/network/ip_range.rb +1 -3
- data/lib/ronin/support/network/proxy.rb +4 -4
- data/lib/ronin/support/network/public_suffix/list.rb +10 -8
- data/lib/ronin/support/network/public_suffix/suffix_set.rb +3 -0
- data/lib/ronin/support/network/public_suffix.rb +9 -4
- data/lib/ronin/support/network/smtp/email.rb +0 -9
- data/lib/ronin/support/network/smtp/mixin.rb +2 -2
- data/lib/ronin/support/network/ssl/local_cert.rb +1 -3
- data/lib/ronin/support/network/ssl/mixin.rb +13 -13
- data/lib/ronin/support/network/ssl/openssl.rb +1 -1
- data/lib/ronin/support/network/ssl/proxy.rb +14 -16
- data/lib/ronin/support/network/ssl.rb +4 -2
- data/lib/ronin/support/network/tcp/proxy.rb +3 -3
- data/lib/ronin/support/network/tcp.rb +10 -12
- data/lib/ronin/support/network/telnet/mixin.rb +14 -14
- data/lib/ronin/support/network/tld/list.rb +2 -1
- data/lib/ronin/support/network/tld.rb +7 -4
- data/lib/ronin/support/network/tls/proxy.rb +1 -1
- data/lib/ronin/support/network/tls.rb +0 -2
- data/lib/ronin/support/network/udp/proxy.rb +5 -5
- data/lib/ronin/support/network/udp.rb +14 -16
- data/lib/ronin/support/path.rb +3 -3
- data/lib/ronin/support/text/erb/mixin.rb +3 -0
- data/lib/ronin/support/text/homoglyph/table.rb +3 -3
- data/lib/ronin/support/text/patterns/credentials.rb +2 -2
- data/lib/ronin/support/text/patterns/crypto.rb +1 -1
- data/lib/ronin/support/text/patterns/file_system.rb +3 -4
- data/lib/ronin/support/text/patterns/network.rb +10 -10
- data/lib/ronin/support/text/patterns/numeric.rb +1 -1
- data/lib/ronin/support/text/patterns/source_code.rb +2 -2
- data/lib/ronin/support/text/random.rb +2 -2
- data/lib/ronin/support/text/typo/generator.rb +2 -2
- data/lib/ronin/support/version.rb +1 -1
- data/ronin-support.gemspec +6 -5
- metadata +3 -2
@@ -124,10 +124,9 @@ module Ronin
|
|
124
124
|
end
|
125
125
|
|
126
126
|
num_bits = SIZES.fetch(first_ip.family)
|
127
|
-
mask = MASKS.fetch(first_ip.family)
|
128
127
|
diff_bits = first_ip.to_i ^ last_ip.to_i
|
129
128
|
|
130
|
-
if diff_bits
|
129
|
+
if diff_bits > 0
|
131
130
|
prefix_length = num_bits - Math.log2(diff_bits).ceil
|
132
131
|
|
133
132
|
return new("#{first_ip}/#{prefix_length}")
|
@@ -191,9 +190,6 @@ module Ronin
|
|
191
190
|
return enum_for(__method__) unless block_given?
|
192
191
|
|
193
192
|
family_mask = MASKS[@family]
|
194
|
-
octet_mask = if ipv6? then 0xffff
|
195
|
-
else 0xff
|
196
|
-
end
|
197
193
|
|
198
194
|
(0..((~@mask_addr) & family_mask)).each do |i|
|
199
195
|
ip_uint = (@addr | i)
|
@@ -173,9 +173,7 @@ module Ronin
|
|
173
173
|
# Indicates that the IP range is a IP-glob range.
|
174
174
|
#
|
175
175
|
def self.glob?(string)
|
176
|
-
string.include?('*') ||
|
177
|
-
string.include?(',') ||
|
178
|
-
string.include?('-')
|
176
|
+
string.include?('*') || string.include?(',') || string.include?('-')
|
179
177
|
end
|
180
178
|
|
181
179
|
#
|
@@ -75,12 +75,12 @@ module Ronin
|
|
75
75
|
attr_reader :port
|
76
76
|
|
77
77
|
# The remote port the proxy will relay data to
|
78
|
-
#
|
78
|
+
#
|
79
79
|
# @return [String]
|
80
80
|
attr_reader :server_host
|
81
81
|
|
82
82
|
# The remote host the proxy will relay data to
|
83
|
-
#
|
83
|
+
#
|
84
84
|
# @return [Integer]
|
85
85
|
attr_reader :server_port
|
86
86
|
|
@@ -130,7 +130,7 @@ module Ronin
|
|
130
130
|
@port = port
|
131
131
|
|
132
132
|
@server_host, @server_port = server
|
133
|
-
@server_port
|
133
|
+
@server_port ||= @port
|
134
134
|
|
135
135
|
@callbacks = {client_data: [], server_data: []}
|
136
136
|
|
@@ -240,7 +240,7 @@ module Ronin
|
|
240
240
|
# Closes the proxy.
|
241
241
|
#
|
242
242
|
# @api public
|
243
|
-
#
|
243
|
+
#
|
244
244
|
def close
|
245
245
|
close_connections
|
246
246
|
close_proxy
|
@@ -149,6 +149,7 @@ module Ronin
|
|
149
149
|
begin
|
150
150
|
download(url: url, path: path)
|
151
151
|
rescue
|
152
|
+
# ignore any network failures
|
152
153
|
end
|
153
154
|
end
|
154
155
|
end
|
@@ -224,6 +225,7 @@ module Ronin
|
|
224
225
|
|
225
226
|
suffix.name.split('.').reverse_each.each_cons(2) do |parent,child|
|
226
227
|
subtree = tree[parent] ||= {}
|
228
|
+
|
227
229
|
subtree[child] ||= nil
|
228
230
|
|
229
231
|
tree = subtree
|
@@ -313,14 +315,14 @@ module Ronin
|
|
313
315
|
def tld_regexp(tld,subtree)
|
314
316
|
if subtree
|
315
317
|
subtree_regexp = if subtree.length == 1
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
318
|
+
tld_regexp(subtree.keys[0],subtree.values[0])
|
319
|
+
else
|
320
|
+
Regexp.union(
|
321
|
+
subtree.map { |sub_tld,sub_subtree|
|
322
|
+
tld_regexp(sub_tld,sub_subtree)
|
323
|
+
}
|
324
|
+
)
|
325
|
+
end
|
324
326
|
|
325
327
|
/(?:#{subtree_regexp}\.)?#{tld}/
|
326
328
|
else
|
@@ -21,6 +21,11 @@ require 'ronin/support/network/public_suffix/list'
|
|
21
21
|
module Ronin
|
22
22
|
module Support
|
23
23
|
module Network
|
24
|
+
#
|
25
|
+
# Manages the [public suffixes list].
|
26
|
+
#
|
27
|
+
# [public suffix list]: https://publicsuffix.org/
|
28
|
+
#
|
24
29
|
module PublicSuffix
|
25
30
|
#
|
26
31
|
# Downloads/updates then loads the cached file
|
@@ -30,10 +35,10 @@ module Ronin
|
|
30
35
|
# The loaded list file.
|
31
36
|
#
|
32
37
|
def self.list
|
33
|
-
@list ||=
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
@list ||= begin
|
39
|
+
List.update
|
40
|
+
List.load_file
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
@@ -53,7 +53,7 @@ module Ronin
|
|
53
53
|
subject: {
|
54
54
|
common_name: 'localhost',
|
55
55
|
organization: 'ronin-rb',
|
56
|
-
organizational_unit: 'ronin-support'
|
56
|
+
organizational_unit: 'ronin-support'
|
57
57
|
},
|
58
58
|
extensions: {
|
59
59
|
'subjectAltName' => subject_alt_name
|
@@ -90,8 +90,6 @@ module Ronin
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
private
|
94
|
-
|
95
93
|
#
|
96
94
|
# The value for the `subjectAltName` extension.
|
97
95
|
#
|
@@ -116,6 +116,7 @@ module Ronin
|
|
116
116
|
#
|
117
117
|
def ssl_socket(socket,**kwargs)
|
118
118
|
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket,ssl_context(**kwargs))
|
119
|
+
|
119
120
|
ssl_socket.sync_close = true
|
120
121
|
return ssl_socket
|
121
122
|
end
|
@@ -182,19 +183,17 @@ module Ronin
|
|
182
183
|
#
|
183
184
|
def ssl_open?(host,port, bind_host: nil, bind_port: nil, timeout: 5,
|
184
185
|
**kwargs)
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
**kwargs)
|
190
|
-
end
|
191
|
-
|
192
|
-
return true
|
193
|
-
rescue Timeout::Error
|
194
|
-
return nil
|
195
|
-
rescue SocketError, SystemCallError
|
196
|
-
return false
|
186
|
+
Timeout.timeout(timeout) do
|
187
|
+
ssl_connect(host,port, bind_host: bind_host,
|
188
|
+
bind_port: bind_port,
|
189
|
+
**kwargs)
|
197
190
|
end
|
191
|
+
|
192
|
+
return true
|
193
|
+
rescue Timeout::Error
|
194
|
+
return nil
|
195
|
+
rescue SocketError, SystemCallError
|
196
|
+
return false
|
198
197
|
end
|
199
198
|
|
200
199
|
#
|
@@ -392,7 +391,8 @@ module Ronin
|
|
392
391
|
#
|
393
392
|
def ssl_cert(host,port,**kwargs)
|
394
393
|
socket = ssl_connect(host,port,**kwargs)
|
395
|
-
cert
|
394
|
+
cert = Crypto::Cert(socket.peer_cert)
|
395
|
+
|
396
396
|
socket.close
|
397
397
|
return cert
|
398
398
|
end
|
@@ -28,7 +28,7 @@ module Ronin
|
|
28
28
|
# protocols.
|
29
29
|
#
|
30
30
|
# ## Example
|
31
|
-
#
|
31
|
+
#
|
32
32
|
# require 'ronin/support/network/ssl/proxy'
|
33
33
|
# require 'hexdump'
|
34
34
|
#
|
@@ -216,7 +216,7 @@ module Ronin
|
|
216
216
|
#
|
217
217
|
# @param [OpenSSL::SSL::SSLSocket] connection
|
218
218
|
# A SSL connection to write data to.
|
219
|
-
#
|
219
|
+
#
|
220
220
|
# @param [String] data
|
221
221
|
# The data to write.
|
222
222
|
#
|
@@ -238,11 +238,9 @@ module Ronin
|
|
238
238
|
# @api public
|
239
239
|
#
|
240
240
|
def recv(connection)
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
''
|
245
|
-
end
|
241
|
+
connection.readpartial(@buffer_size)
|
242
|
+
rescue Errno::ECONNRESET, EOFError
|
243
|
+
''
|
246
244
|
end
|
247
245
|
|
248
246
|
#
|
@@ -252,15 +250,15 @@ module Ronin
|
|
252
250
|
# The new SSL connection.
|
253
251
|
#
|
254
252
|
def accept_client_connection
|
255
|
-
client
|
256
|
-
context
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
253
|
+
client = super
|
254
|
+
context = SSL.context(version: @version,
|
255
|
+
key: @key,
|
256
|
+
key_file: @key_file,
|
257
|
+
cert: @cert,
|
258
|
+
cert_file: @cert_file,
|
259
|
+
verify: @verify)
|
263
260
|
ssl_socket = OpenSSL::SSL::SSLSocket.new(client,context)
|
261
|
+
|
264
262
|
ssl_socket.sync_close = true
|
265
263
|
|
266
264
|
begin
|
@@ -281,8 +279,8 @@ module Ronin
|
|
281
279
|
def open_server_connection
|
282
280
|
server_socket = super
|
283
281
|
context = SSL.context(verify: @verify, ca_bundle: @ca_bundle)
|
282
|
+
ssl_socket = OpenSSL::SSL::SSLSocket.new(server_socket,context)
|
284
283
|
|
285
|
-
ssl_socket = OpenSSL::SSL::SSLSocket.new(server_socket,context)
|
286
284
|
ssl_socket.sync_close = true
|
287
285
|
ssl_socket.connect
|
288
286
|
|
@@ -24,6 +24,9 @@ require 'ronin/support/network/ssl/proxy'
|
|
24
24
|
module Ronin
|
25
25
|
module Support
|
26
26
|
module Network
|
27
|
+
#
|
28
|
+
# Top-level SSL methods.
|
29
|
+
#
|
27
30
|
module SSL
|
28
31
|
# SSL/TLS versions
|
29
32
|
VERSIONS = {
|
@@ -136,7 +139,7 @@ module Ronin
|
|
136
139
|
cert: nil,
|
137
140
|
cert_file: nil,
|
138
141
|
ca_bundle: nil)
|
139
|
-
context = OpenSSL::SSL::SSLContext.new
|
142
|
+
context = OpenSSL::SSL::SSLContext.new
|
140
143
|
|
141
144
|
if version
|
142
145
|
context.ssl_version = VERSIONS.fetch(version,version)
|
@@ -166,7 +169,6 @@ module Ronin
|
|
166
169
|
|
167
170
|
return context
|
168
171
|
end
|
169
|
-
|
170
172
|
end
|
171
173
|
end
|
172
174
|
end
|
@@ -28,7 +28,7 @@ module Ronin
|
|
28
28
|
# The TCP Proxy allows for inspecting and manipulating TCP protocols.
|
29
29
|
#
|
30
30
|
# ## Example
|
31
|
-
#
|
31
|
+
#
|
32
32
|
# require 'ronin/support/network/tcp/proxy'
|
33
33
|
# require 'hexdump'
|
34
34
|
#
|
@@ -152,7 +152,7 @@ module Ronin
|
|
152
152
|
def poll
|
153
153
|
sockets = [@socket] + client_connections + server_connections
|
154
154
|
|
155
|
-
readable,
|
155
|
+
readable, _writtable, errors = IO.select(sockets,nil,sockets)
|
156
156
|
|
157
157
|
(errors & client_connections).each do |client_socket|
|
158
158
|
server_socket = server_connection_for(client_socket)
|
@@ -200,7 +200,7 @@ module Ronin
|
|
200
200
|
#
|
201
201
|
# @param [TCPSocket] connection
|
202
202
|
# A TCP connection to write data to.
|
203
|
-
#
|
203
|
+
#
|
204
204
|
# @param [String] data
|
205
205
|
# The data to write.
|
206
206
|
#
|
@@ -67,18 +67,16 @@ module Ronin
|
|
67
67
|
# @since 0.5.0
|
68
68
|
#
|
69
69
|
def self.open?(host,port, timeout: 5, **kwargs)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
socket.close
|
74
|
-
end
|
75
|
-
|
76
|
-
return true
|
77
|
-
rescue Timeout::Error
|
78
|
-
return nil
|
79
|
-
rescue SocketError, SystemCallError
|
80
|
-
return false
|
70
|
+
Timeout.timeout(timeout) do
|
71
|
+
socket = connect(host,port,**kwargs)
|
72
|
+
socket.close
|
81
73
|
end
|
74
|
+
|
75
|
+
return true
|
76
|
+
rescue Timeout::Error
|
77
|
+
return nil
|
78
|
+
rescue SocketError, SystemCallError
|
79
|
+
return false
|
82
80
|
end
|
83
81
|
|
84
82
|
#
|
@@ -345,7 +343,7 @@ module Ronin
|
|
345
343
|
#
|
346
344
|
def self.server_session(**kwargs,&block)
|
347
345
|
server = server(**kwargs,&block)
|
348
|
-
server.close
|
346
|
+
server.close
|
349
347
|
return nil
|
350
348
|
end
|
351
349
|
|
@@ -103,20 +103,20 @@ module Ronin
|
|
103
103
|
# @api public
|
104
104
|
#
|
105
105
|
def telnet_connect(host, # connection options
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
106
|
+
proxy: Telnet.proxy,
|
107
|
+
port: Telnet::DEFAULT_PORT,
|
108
|
+
binmode: false,
|
109
|
+
wait_time: 0,
|
110
|
+
prompt: Telnet::DEFAULT_PROMPT,
|
111
|
+
timeout: Telnet.default_timeout,
|
112
|
+
telnet: nil,
|
113
|
+
plain: nil,
|
114
|
+
# authentication options
|
115
|
+
user: nil,
|
116
|
+
password: nil,
|
117
|
+
# log options
|
118
|
+
output_log: nil,
|
119
|
+
dump_log: nil)
|
120
120
|
host = DNS::IDN.to_ascii(host)
|
121
121
|
|
122
122
|
telnet_options = {
|
@@ -152,6 +152,7 @@ module Ronin
|
|
152
152
|
begin
|
153
153
|
download(url: url, path: path)
|
154
154
|
rescue
|
155
|
+
# ignore any network failures
|
155
156
|
end
|
156
157
|
end
|
157
158
|
end
|
@@ -228,7 +229,7 @@ module Ronin
|
|
228
229
|
end
|
229
230
|
|
230
231
|
name = host_name[0...index]
|
231
|
-
tld = host_name[(index+1)..]
|
232
|
+
tld = host_name[(index + 1)..]
|
232
233
|
|
233
234
|
unless @list.include?(tld)
|
234
235
|
raise(InvalidHostname,"hostname does not have a valid TLD: #{host_name.inspect}")
|
@@ -21,6 +21,9 @@ require 'ronin/support/network/tld/list'
|
|
21
21
|
module Ronin
|
22
22
|
module Support
|
23
23
|
module Network
|
24
|
+
#
|
25
|
+
# Manages the list of Top-Level-Domains (TLDs).
|
26
|
+
#
|
24
27
|
module TLD
|
25
28
|
#
|
26
29
|
# Downloads/updates then loads the cached file
|
@@ -30,10 +33,10 @@ module Ronin
|
|
30
33
|
# The loaded list file.
|
31
34
|
#
|
32
35
|
def self.list
|
33
|
-
@list ||=
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
@list ||= begin
|
37
|
+
List.update
|
38
|
+
List.load_file
|
39
|
+
end
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -16,7 +16,6 @@
|
|
16
16
|
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
19
|
require 'ronin/support/network/tls/proxy'
|
21
20
|
require 'ronin/support/network/ssl'
|
22
21
|
|
@@ -46,7 +45,6 @@ module Ronin
|
|
46
45
|
def self.context(version: 1.2, **kwargs)
|
47
46
|
SSL.context(version: version, **kwargs)
|
48
47
|
end
|
49
|
-
|
50
48
|
end
|
51
49
|
end
|
52
50
|
end
|
@@ -44,7 +44,7 @@ module Ronin
|
|
44
44
|
# puts "#{host}:#{port} <- #{proxy}"
|
45
45
|
# hex.dump(data)
|
46
46
|
# end
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# end
|
49
49
|
#
|
50
50
|
# @since 0.5.0
|
@@ -70,7 +70,7 @@ module Ronin
|
|
70
70
|
def poll
|
71
71
|
sockets = [@socket] + server_connections
|
72
72
|
|
73
|
-
readable,
|
73
|
+
readable, _writtable, errors = IO.select(sockets,nil,sockets)
|
74
74
|
|
75
75
|
(errors & server_connections).each do |server_socket|
|
76
76
|
client_socket = client_connection_for(server_socket)
|
@@ -79,8 +79,8 @@ module Ronin
|
|
79
79
|
end
|
80
80
|
|
81
81
|
(readable & server_connections).each do |server_socket|
|
82
|
-
client_socket
|
83
|
-
data,
|
82
|
+
client_socket = client_connection_for(server_socket)
|
83
|
+
data, _addrinfo = recv(server_socket)
|
84
84
|
|
85
85
|
server_data(client_socket,server_socket,data)
|
86
86
|
end
|
@@ -133,7 +133,7 @@ module Ronin
|
|
133
133
|
def recv(connection)
|
134
134
|
case connection
|
135
135
|
when Array
|
136
|
-
socket,
|
136
|
+
socket, _host_and_port = connection
|
137
137
|
|
138
138
|
socket.recvfrom(@buffer_size)
|
139
139
|
when UDPSocket
|
@@ -67,24 +67,22 @@ module Ronin
|
|
67
67
|
# @since 0.5.0
|
68
68
|
#
|
69
69
|
def self.open?(host,port, timeout: 5, **kwargs)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
socket.syswrite('')
|
70
|
+
Timeout.timeout(timeout) do
|
71
|
+
connect(host,port,**kwargs) do |socket|
|
72
|
+
# send an empty UDP packet, just like nmap
|
73
|
+
socket.syswrite('')
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
75
|
+
# send an empty UDP packet again, to elicit an
|
76
|
+
# Errno::ECONNREFUSED
|
77
|
+
socket.syswrite('')
|
80
78
|
end
|
81
|
-
|
82
|
-
return true
|
83
|
-
rescue Timeout::Error
|
84
|
-
return nil
|
85
|
-
rescue SocketError, SystemCallError
|
86
|
-
return false
|
87
79
|
end
|
80
|
+
|
81
|
+
return true
|
82
|
+
rescue Timeout::Error
|
83
|
+
return nil
|
84
|
+
rescue SocketError, SystemCallError
|
85
|
+
return false
|
88
86
|
end
|
89
87
|
|
90
88
|
#
|
@@ -328,7 +326,7 @@ module Ronin
|
|
328
326
|
#
|
329
327
|
def self.server_session(**kwargs,&block)
|
330
328
|
server = server(**kwargs,&block)
|
331
|
-
server.close
|
329
|
+
server.close
|
332
330
|
return nil
|
333
331
|
end
|
334
332
|
|
data/lib/ronin/support/path.rb
CHANGED
@@ -54,8 +54,8 @@ module Ronin
|
|
54
54
|
# @return [Path]
|
55
55
|
# The root path.
|
56
56
|
#
|
57
|
-
def
|
58
|
-
|
57
|
+
def self.root
|
58
|
+
new('/')
|
59
59
|
end
|
60
60
|
|
61
61
|
#
|
@@ -89,7 +89,7 @@ module Ronin
|
|
89
89
|
separator
|
90
90
|
elsif n > 0
|
91
91
|
path = new('..',separator)
|
92
|
-
path.join(*(['..'] * (n-1)))
|
92
|
+
path.join(*(['..'] * (n - 1)))
|
93
93
|
else
|
94
94
|
raise(ArgumentError,"negative argument")
|
95
95
|
end
|
@@ -61,7 +61,7 @@ module Ronin
|
|
61
61
|
# @api private
|
62
62
|
#
|
63
63
|
def self.load_file(path)
|
64
|
-
table = new
|
64
|
+
table = new
|
65
65
|
|
66
66
|
File.open(path) do |file|
|
67
67
|
file.each_line(chomp: true) do |line|
|
@@ -211,11 +211,11 @@ module Ronin
|
|
211
211
|
offset = 0
|
212
212
|
|
213
213
|
while (index = string.index(replaceable_char,offset))
|
214
|
-
homoglyph
|
214
|
+
homoglyph = string.dup
|
215
215
|
homoglyph[index] = substitute_char
|
216
216
|
|
217
217
|
yield homoglyph
|
218
|
-
offset = index+1
|
218
|
+
offset = index + 1
|
219
219
|
end
|
220
220
|
end
|
221
221
|
end
|