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.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +14 -0
  3. data/.rubocop.yml +109 -0
  4. data/ChangeLog.md +12 -1
  5. data/Gemfile +8 -4
  6. data/README.md +1 -1
  7. data/Rakefile +2 -2
  8. data/examples/ssl_proxy.rb +2 -1
  9. data/examples/tcp_proxy.rb +6 -4
  10. data/lib/ronin/support/archive/tar/writer.rb +2 -2
  11. data/lib/ronin/support/archive/tar.rb +4 -4
  12. data/lib/ronin/support/archive/zip/reader.rb +2 -2
  13. data/lib/ronin/support/binary/array.rb +4 -7
  14. data/lib/ronin/support/binary/bit_flip.rb +7 -1
  15. data/lib/ronin/support/binary/buffer.rb +22 -22
  16. data/lib/ronin/support/binary/byte_slice.rb +17 -17
  17. data/lib/ronin/support/binary/cstring.rb +7 -4
  18. data/lib/ronin/support/binary/ctypes/arch/arm/big_endian.rb +4 -0
  19. data/lib/ronin/support/binary/ctypes/arch/arm.rb +3 -0
  20. data/lib/ronin/support/binary/ctypes/arch/arm64/big_endian.rb +4 -0
  21. data/lib/ronin/support/binary/ctypes/arch/arm64.rb +3 -0
  22. data/lib/ronin/support/binary/ctypes/arch/mips/little_endian.rb +4 -0
  23. data/lib/ronin/support/binary/ctypes/arch/mips.rb +3 -0
  24. data/lib/ronin/support/binary/ctypes/arch/mips64/little_endian.rb +4 -0
  25. data/lib/ronin/support/binary/ctypes/arch/mips64.rb +3 -0
  26. data/lib/ronin/support/binary/ctypes/arch/ppc.rb +3 -0
  27. data/lib/ronin/support/binary/ctypes/arch/ppc64.rb +3 -0
  28. data/lib/ronin/support/binary/ctypes/arch/x86.rb +3 -0
  29. data/lib/ronin/support/binary/ctypes/arch/x86_64.rb +3 -0
  30. data/lib/ronin/support/binary/ctypes/array_type.rb +1 -1
  31. data/lib/ronin/support/binary/ctypes/big_endian.rb +3 -0
  32. data/lib/ronin/support/binary/ctypes/enum_type.rb +2 -2
  33. data/lib/ronin/support/binary/ctypes/little_endian.rb +3 -0
  34. data/lib/ronin/support/binary/ctypes/native.rb +3 -0
  35. data/lib/ronin/support/binary/ctypes/scalar_type.rb +2 -2
  36. data/lib/ronin/support/binary/ctypes/struct_type.rb +3 -3
  37. data/lib/ronin/support/binary/ctypes/type_resolver.rb +7 -8
  38. data/lib/ronin/support/binary/ctypes/unbounded_array_type.rb +1 -1
  39. data/lib/ronin/support/binary/ctypes/union_type.rb +3 -3
  40. data/lib/ronin/support/binary/ctypes.rb +3 -3
  41. data/lib/ronin/support/binary/memory.rb +2 -2
  42. data/lib/ronin/support/binary/packet.rb +3 -0
  43. data/lib/ronin/support/binary/stack.rb +3 -4
  44. data/lib/ronin/support/binary/struct/member.rb +5 -3
  45. data/lib/ronin/support/binary/struct.rb +81 -79
  46. data/lib/ronin/support/binary/template.rb +1 -0
  47. data/lib/ronin/support/binary/unhexdump/parser.rb +11 -11
  48. data/lib/ronin/support/binary/union.rb +22 -22
  49. data/lib/ronin/support/cli/ansi.rb +0 -1
  50. data/lib/ronin/support/cli/io_shell/core_ext/io.rb +1 -1
  51. data/lib/ronin/support/cli/io_shell.rb +4 -4
  52. data/lib/ronin/support/cli/printing.rb +3 -3
  53. data/lib/ronin/support/compression/zlib.rb +1 -1
  54. data/lib/ronin/support/core_ext/enumerable.rb +0 -2
  55. data/lib/ronin/support/core_ext/file.rb +1 -1
  56. data/lib/ronin/support/core_ext/kernel.rb +6 -5
  57. data/lib/ronin/support/core_ext/string.rb +2 -2
  58. data/lib/ronin/support/crypto/cert.rb +11 -15
  59. data/lib/ronin/support/crypto/cert_chain.rb +1 -1
  60. data/lib/ronin/support/crypto/cipher/aes.rb +3 -0
  61. data/lib/ronin/support/crypto/cipher/aes128.rb +4 -1
  62. data/lib/ronin/support/crypto/cipher/aes256.rb +4 -1
  63. data/lib/ronin/support/crypto/cipher.rb +1 -1
  64. data/lib/ronin/support/crypto/core_ext/file.rb +1 -1
  65. data/lib/ronin/support/crypto/key/methods.rb +4 -1
  66. data/lib/ronin/support/crypto/key.rb +5 -2
  67. data/lib/ronin/support/crypto/openssl.rb +1 -1
  68. data/lib/ronin/support/crypto.rb +0 -1
  69. data/lib/ronin/support/encoding/base16.rb +1 -1
  70. data/lib/ronin/support/encoding/base32.rb +28 -17
  71. data/lib/ronin/support/encoding/c/core_ext/integer.rb +1 -1
  72. data/lib/ronin/support/encoding/c.rb +4 -4
  73. data/lib/ronin/support/encoding/hex.rb +2 -2
  74. data/lib/ronin/support/encoding/js/core_ext/integer.rb +1 -1
  75. data/lib/ronin/support/encoding/js.rb +4 -4
  76. data/lib/ronin/support/encoding/powershell/core_ext/integer.rb +2 -2
  77. data/lib/ronin/support/encoding/powershell.rb +4 -5
  78. data/lib/ronin/support/encoding/ruby.rb +4 -4
  79. data/lib/ronin/support/encoding/shell/core_ext/integer.rb +2 -2
  80. data/lib/ronin/support/encoding/shell.rb +3 -3
  81. data/lib/ronin/support/encoding/sql.rb +1 -1
  82. data/lib/ronin/support/encoding/xml.rb +2 -2
  83. data/lib/ronin/support/encoding.rb +95 -0
  84. data/lib/ronin/support/network/asn/list.rb +6 -1
  85. data/lib/ronin/support/network/asn/record.rb +3 -0
  86. data/lib/ronin/support/network/asn/record_set.rb +3 -0
  87. data/lib/ronin/support/network/asn.rb +167 -6
  88. data/lib/ronin/support/network/dns/resolver.rb +3 -0
  89. data/lib/ronin/support/network/domain.rb +21 -21
  90. data/lib/ronin/support/network/email_address.rb +1 -5
  91. data/lib/ronin/support/network/esmtp/mixin.rb +1 -0
  92. data/lib/ronin/support/network/ftp/mixin.rb +1 -1
  93. data/lib/ronin/support/network/host.rb +75 -47
  94. data/lib/ronin/support/network/http/core_ext.rb +1 -1
  95. data/lib/ronin/support/network/http.rb +317 -80
  96. data/lib/ronin/support/network/ip.rb +8 -10
  97. data/lib/ronin/support/network/ip_range/cidr.rb +1 -5
  98. data/lib/ronin/support/network/ip_range/glob.rb +1 -0
  99. data/lib/ronin/support/network/ip_range/range.rb +1 -1
  100. data/lib/ronin/support/network/ip_range.rb +1 -3
  101. data/lib/ronin/support/network/proxy.rb +4 -4
  102. data/lib/ronin/support/network/public_suffix/list.rb +10 -8
  103. data/lib/ronin/support/network/public_suffix/suffix_set.rb +3 -0
  104. data/lib/ronin/support/network/public_suffix.rb +9 -4
  105. data/lib/ronin/support/network/smtp/email.rb +0 -9
  106. data/lib/ronin/support/network/smtp/mixin.rb +2 -2
  107. data/lib/ronin/support/network/ssl/local_cert.rb +1 -3
  108. data/lib/ronin/support/network/ssl/mixin.rb +13 -13
  109. data/lib/ronin/support/network/ssl/openssl.rb +1 -1
  110. data/lib/ronin/support/network/ssl/proxy.rb +14 -16
  111. data/lib/ronin/support/network/ssl.rb +4 -2
  112. data/lib/ronin/support/network/tcp/proxy.rb +3 -3
  113. data/lib/ronin/support/network/tcp.rb +10 -12
  114. data/lib/ronin/support/network/telnet/mixin.rb +14 -14
  115. data/lib/ronin/support/network/tld/list.rb +2 -1
  116. data/lib/ronin/support/network/tld.rb +7 -4
  117. data/lib/ronin/support/network/tls/proxy.rb +1 -1
  118. data/lib/ronin/support/network/tls.rb +0 -2
  119. data/lib/ronin/support/network/udp/proxy.rb +5 -5
  120. data/lib/ronin/support/network/udp.rb +14 -16
  121. data/lib/ronin/support/path.rb +3 -3
  122. data/lib/ronin/support/text/erb/mixin.rb +3 -0
  123. data/lib/ronin/support/text/homoglyph/table.rb +3 -3
  124. data/lib/ronin/support/text/patterns/credentials.rb +2 -2
  125. data/lib/ronin/support/text/patterns/crypto.rb +1 -1
  126. data/lib/ronin/support/text/patterns/file_system.rb +3 -4
  127. data/lib/ronin/support/text/patterns/network.rb +10 -10
  128. data/lib/ronin/support/text/patterns/numeric.rb +1 -1
  129. data/lib/ronin/support/text/patterns/source_code.rb +2 -2
  130. data/lib/ronin/support/text/random.rb +2 -2
  131. data/lib/ronin/support/text/typo/generator.rb +2 -2
  132. data/lib/ronin/support/version.rb +1 -1
  133. data/ronin-support.gemspec +6 -5
  134. 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 != 0
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)
@@ -265,6 +265,7 @@ module Ronin
265
265
  #
266
266
  def parse_range(range)
267
267
  start, stop = range.split('-',2)
268
+
268
269
  start = start.to_i(@base)
269
270
  stop = stop.to_i(@base)
270
271
 
@@ -76,7 +76,7 @@ module Ronin
76
76
  #
77
77
  # @param [String] last
78
78
  # The last IP address in the ASN IP range.
79
- #
79
+ #
80
80
  # @raise [ArgumentError]
81
81
  # Both IP addresses must be either IPv4 addresses or IPv6 addresses.
82
82
  #
@@ -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 ||= @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
- tld_regexp(subtree.keys[0],subtree.values[0])
317
- else
318
- Regexp.union(
319
- subtree.map { |sub_tld,sub_subtree|
320
- tld_regexp(sub_tld,sub_subtree)
321
- }
322
- )
323
- end
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
@@ -20,6 +20,9 @@ module Ronin
20
20
  module Support
21
21
  module Network
22
22
  module PublicSuffix
23
+ #
24
+ # A sub-set of public suffixes.
25
+ #
23
26
  class SuffixSet
24
27
 
25
28
  include Enumerable
@@ -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
- List.update
35
- List.load_file
36
- )
38
+ @list ||= begin
39
+ List.update
40
+ List.load_file
41
+ end
37
42
  end
38
43
  end
39
44
  end
@@ -137,15 +137,6 @@ module Ronin
137
137
  # @api public
138
138
  #
139
139
  def to_s
140
- address = lambda { |info|
141
- case info
142
- when Array
143
- "#{info[0]} <#{info[1]}>"
144
- else
145
- info
146
- end
147
- }
148
-
149
140
  message = []
150
141
 
151
142
  if @from
@@ -146,8 +146,8 @@ module Ronin
146
146
  ssl: nil,
147
147
  helo: 'localhost',
148
148
  auth: :login)
149
- host = DNS::IDN.to_ascii(host)
150
- user = user.to_s
149
+ host = DNS::IDN.to_ascii(host)
150
+ user = user.to_s
151
151
  password = password.to_s
152
152
 
153
153
  case ssl
@@ -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
- begin
186
- Timeout.timeout(timeout) do
187
- ssl_connect(host,port, bind_host: bind_host,
188
- bind_port: bind_port,
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 = Crypto::Cert(socket.peer_cert)
394
+ cert = Crypto::Cert(socket.peer_cert)
395
+
396
396
  socket.close
397
397
  return cert
398
398
  end
@@ -18,6 +18,6 @@
18
18
 
19
19
  begin
20
20
  require 'openssl'
21
- rescue ::LoadError
21
+ rescue LoadError
22
22
  warn "WARNING: Ruby was not compiled with OpenSSL support"
23
23
  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
- begin
242
- connection.readpartial(@buffer_size)
243
- rescue Errno::ECONNRESET, EOFError
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 = super
256
- context = SSL.context(version: @version,
257
- key: @key,
258
- key_file: @key_file,
259
- cert: @cert,
260
- cert_file: @cert_file,
261
- verify: @verify)
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, writtable, errors = IO.select(sockets,nil,sockets)
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
- begin
71
- Timeout.timeout(timeout) do
72
- socket = connect(host,port,**kwargs)
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
- 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)
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
- List.update
35
- List.load_file
36
- )
36
+ @list ||= begin
37
+ List.update
38
+ List.load_file
39
+ end
37
40
  end
38
41
  end
39
42
  end
@@ -27,7 +27,7 @@ module Ronin
27
27
  # protocols.
28
28
  #
29
29
  # ## Example
30
- #
30
+ #
31
31
  # require 'ronin/support/network/tls/proxy'
32
32
  # require 'hexdump'
33
33
  #
@@ -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, writtable, errors = IO.select(sockets,nil,sockets)
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 = client_connection_for(server_socket)
83
- data, addrinfo = recv(server_socket)
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, (host, port) = connection
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
- begin
71
- Timeout.timeout(timeout) do
72
- connect(host,port,**kwargs) do |socket|
73
- # send an empty UDP packet, just like nmap
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
- # send an empty UDP packet again, to elicit an
77
- # Errno::ECONNREFUSED
78
- socket.syswrite('')
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
 
@@ -54,8 +54,8 @@ module Ronin
54
54
  # @return [Path]
55
55
  # The root path.
56
56
  #
57
- def Path.root
58
- Path.new('/')
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
@@ -22,6 +22,9 @@ module Ronin
22
22
  module Support
23
23
  module Text
24
24
  module ERB
25
+ #
26
+ # Mixin which adds `erb` helper methods.
27
+ #
25
28
  module Mixin
26
29
  #
27
30
  # Renders the ERB template file.
@@ -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 = string.dup
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