ronin-support 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) 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 +33 -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/core_ext/file.rb +43 -0
  11. data/lib/ronin/support/archive/core_ext.rb +1 -1
  12. data/lib/ronin/support/archive/tar/writer.rb +2 -2
  13. data/lib/ronin/support/archive/tar.rb +4 -4
  14. data/lib/ronin/support/archive/zip/reader.rb +2 -2
  15. data/lib/ronin/support/binary/array.rb +5 -8
  16. data/lib/ronin/support/binary/bit_flip.rb +7 -1
  17. data/lib/ronin/support/binary/buffer.rb +25 -25
  18. data/lib/ronin/support/binary/byte_slice.rb +17 -17
  19. data/lib/ronin/support/binary/core_ext.rb +2 -0
  20. data/lib/ronin/support/binary/cstring.rb +50 -4
  21. data/lib/ronin/support/binary/ctypes/arch/arm/big_endian.rb +4 -0
  22. data/lib/ronin/support/binary/ctypes/arch/arm.rb +3 -0
  23. data/lib/ronin/support/binary/ctypes/arch/arm64/big_endian.rb +4 -0
  24. data/lib/ronin/support/binary/ctypes/arch/arm64.rb +3 -0
  25. data/lib/ronin/support/binary/ctypes/arch/mips/little_endian.rb +4 -0
  26. data/lib/ronin/support/binary/ctypes/arch/mips.rb +3 -0
  27. data/lib/ronin/support/binary/ctypes/arch/mips64/little_endian.rb +4 -0
  28. data/lib/ronin/support/binary/ctypes/arch/mips64.rb +3 -0
  29. data/lib/ronin/support/binary/ctypes/arch/ppc.rb +3 -0
  30. data/lib/ronin/support/binary/ctypes/arch/ppc64.rb +3 -0
  31. data/lib/ronin/support/binary/ctypes/arch/x86.rb +3 -0
  32. data/lib/ronin/support/binary/ctypes/arch/x86_64.rb +3 -0
  33. data/lib/ronin/support/binary/ctypes/array_type.rb +2 -2
  34. data/lib/ronin/support/binary/ctypes/big_endian.rb +3 -0
  35. data/lib/ronin/support/binary/ctypes/enum_type.rb +2 -2
  36. data/lib/ronin/support/binary/ctypes/little_endian.rb +3 -0
  37. data/lib/ronin/support/binary/ctypes/native.rb +3 -0
  38. data/lib/ronin/support/binary/ctypes/os/bsd.rb +1 -1
  39. data/lib/ronin/support/binary/ctypes/scalar_type.rb +2 -2
  40. data/lib/ronin/support/binary/ctypes/struct_type.rb +3 -3
  41. data/lib/ronin/support/binary/ctypes/type_resolver.rb +7 -8
  42. data/lib/ronin/support/binary/ctypes/unbounded_array_type.rb +2 -2
  43. data/lib/ronin/support/binary/ctypes/union_type.rb +3 -3
  44. data/lib/ronin/support/binary/ctypes.rb +3 -3
  45. data/lib/ronin/support/binary/memory.rb +2 -2
  46. data/lib/ronin/support/binary/packet.rb +80 -0
  47. data/lib/ronin/support/binary/stack.rb +6 -7
  48. data/lib/ronin/support/binary/struct/member.rb +5 -3
  49. data/lib/ronin/support/binary/struct.rb +81 -79
  50. data/lib/ronin/support/binary/template.rb +2 -5
  51. data/lib/ronin/support/binary/unhexdump/parser.rb +11 -11
  52. data/lib/ronin/support/binary/union.rb +22 -22
  53. data/lib/ronin/support/binary.rb +1 -0
  54. data/lib/ronin/support/cli/ansi.rb +0 -1
  55. data/lib/ronin/support/cli/io_shell/core_ext/io.rb +1 -1
  56. data/lib/ronin/support/cli/io_shell.rb +4 -4
  57. data/lib/ronin/support/cli/printing.rb +3 -3
  58. data/lib/ronin/support/compression/core_ext/file.rb +16 -0
  59. data/lib/ronin/support/compression/zlib.rb +1 -1
  60. data/lib/ronin/support/core_ext/enumerable.rb +0 -2
  61. data/lib/ronin/support/core_ext/file.rb +1 -1
  62. data/lib/ronin/support/core_ext/kernel.rb +6 -9
  63. data/lib/ronin/support/core_ext/string.rb +2 -2
  64. data/lib/ronin/support/crypto/cert.rb +11 -15
  65. data/lib/ronin/support/crypto/cert_chain.rb +1 -1
  66. data/lib/ronin/support/crypto/cipher/aes.rb +3 -0
  67. data/lib/ronin/support/crypto/cipher/aes128.rb +4 -1
  68. data/lib/ronin/support/crypto/cipher/aes256.rb +4 -1
  69. data/lib/ronin/support/crypto/cipher.rb +1 -1
  70. data/lib/ronin/support/crypto/core_ext/file.rb +33 -1
  71. data/lib/ronin/support/crypto/core_ext/string.rb +34 -2
  72. data/lib/ronin/support/crypto/key/methods.rb +4 -1
  73. data/lib/ronin/support/crypto/key.rb +5 -2
  74. data/lib/ronin/support/crypto/openssl.rb +1 -1
  75. data/lib/ronin/support/crypto.rb +0 -1
  76. data/lib/ronin/support/encoding/base16.rb +2 -2
  77. data/lib/ronin/support/encoding/base32.rb +29 -18
  78. data/lib/ronin/support/encoding/c/core_ext/integer.rb +1 -1
  79. data/lib/ronin/support/encoding/c/core_ext/string.rb +1 -1
  80. data/lib/ronin/support/encoding/c.rb +6 -6
  81. data/lib/ronin/support/encoding/core_ext/string.rb +2 -2
  82. data/lib/ronin/support/encoding/hex/core_ext/string.rb +1 -1
  83. data/lib/ronin/support/encoding/hex.rb +4 -4
  84. data/lib/ronin/support/encoding/js/core_ext/integer.rb +1 -1
  85. data/lib/ronin/support/encoding/js.rb +5 -5
  86. data/lib/ronin/support/encoding/powershell/core_ext/integer.rb +2 -2
  87. data/lib/ronin/support/encoding/powershell.rb +5 -6
  88. data/lib/ronin/support/encoding/quoted_printable.rb +3 -1
  89. data/lib/ronin/support/encoding/ruby.rb +5 -5
  90. data/lib/ronin/support/encoding/shell/core_ext/integer.rb +2 -2
  91. data/lib/ronin/support/encoding/shell.rb +3 -3
  92. data/lib/ronin/support/encoding/sql.rb +1 -1
  93. data/lib/ronin/support/encoding/uuencoding.rb +3 -1
  94. data/lib/ronin/support/encoding/xml.rb +3 -3
  95. data/lib/ronin/support/encoding.rb +95 -0
  96. data/lib/ronin/support/network/asn/list.rb +6 -1
  97. data/lib/ronin/support/network/asn/record.rb +3 -0
  98. data/lib/ronin/support/network/asn/record_set.rb +3 -0
  99. data/lib/ronin/support/network/asn.rb +167 -6
  100. data/lib/ronin/support/network/dns/mixin.rb +2 -10
  101. data/lib/ronin/support/network/dns/resolver.rb +3 -0
  102. data/lib/ronin/support/network/domain.rb +21 -21
  103. data/lib/ronin/support/network/email_address.rb +1 -5
  104. data/lib/ronin/support/network/esmtp/mixin.rb +1 -0
  105. data/lib/ronin/support/network/ftp/mixin.rb +1 -1
  106. data/lib/ronin/support/network/host.rb +75 -47
  107. data/lib/ronin/support/network/http/core_ext/uri/http.rb +8 -0
  108. data/lib/ronin/support/network/http/core_ext.rb +1 -1
  109. data/lib/ronin/support/network/http.rb +317 -80
  110. data/lib/ronin/support/network/ip.rb +49 -23
  111. data/lib/ronin/support/network/ip_range/cidr.rb +1 -5
  112. data/lib/ronin/support/network/ip_range/glob.rb +1 -0
  113. data/lib/ronin/support/network/ip_range/range.rb +1 -1
  114. data/lib/ronin/support/network/ip_range.rb +5 -7
  115. data/lib/ronin/support/network/proxy.rb +4 -4
  116. data/lib/ronin/support/network/public_suffix/list.rb +10 -8
  117. data/lib/ronin/support/network/public_suffix/suffix_set.rb +3 -0
  118. data/lib/ronin/support/network/public_suffix.rb +9 -4
  119. data/lib/ronin/support/network/smtp/email.rb +0 -9
  120. data/lib/ronin/support/network/smtp/mixin.rb +2 -2
  121. data/lib/ronin/support/network/ssl/local_cert.rb +1 -3
  122. data/lib/ronin/support/network/ssl/mixin.rb +13 -13
  123. data/lib/ronin/support/network/ssl/openssl.rb +1 -1
  124. data/lib/ronin/support/network/ssl/proxy.rb +14 -16
  125. data/lib/ronin/support/network/ssl.rb +4 -2
  126. data/lib/ronin/support/network/tcp/proxy.rb +3 -3
  127. data/lib/ronin/support/network/tcp.rb +10 -12
  128. data/lib/ronin/support/network/telnet/mixin.rb +14 -14
  129. data/lib/ronin/support/network/tld/list.rb +2 -1
  130. data/lib/ronin/support/network/tld.rb +7 -4
  131. data/lib/ronin/support/network/tls/proxy.rb +1 -1
  132. data/lib/ronin/support/network/tls.rb +0 -2
  133. data/lib/ronin/support/network/udp/proxy.rb +5 -5
  134. data/lib/ronin/support/network/udp.rb +14 -16
  135. data/lib/ronin/support/path.rb +4 -4
  136. data/lib/ronin/support/text/erb/mixin.rb +3 -0
  137. data/lib/ronin/support/text/homoglyph/core_ext/string.rb +33 -0
  138. data/lib/ronin/support/text/homoglyph/table.rb +3 -3
  139. data/lib/ronin/support/text/patterns/credentials.rb +2 -2
  140. data/lib/ronin/support/text/patterns/crypto.rb +1 -1
  141. data/lib/ronin/support/text/patterns/file_system.rb +3 -4
  142. data/lib/ronin/support/text/patterns/network.rb +21 -21
  143. data/lib/ronin/support/text/patterns/numeric.rb +1 -1
  144. data/lib/ronin/support/text/patterns/source_code.rb +2 -2
  145. data/lib/ronin/support/text/random/mixin.rb +17 -17
  146. data/lib/ronin/support/text/random.rb +25 -25
  147. data/lib/ronin/support/text/typo/core_ext/string.rb +24 -0
  148. data/lib/ronin/support/text/typo/generator.rb +2 -2
  149. data/lib/ronin/support/version.rb +1 -1
  150. data/ronin-support.gemspec +6 -5
  151. metadata +3 -2
@@ -52,7 +52,7 @@ module Ronin
52
52
  def self.swapcase(string)
53
53
  candidates = []
54
54
 
55
- string.each_char.each_with_index do |char,index|
55
+ string.each_char.with_index do |char,index|
56
56
  if char =~ /\p{L}/
57
57
  candidates << index
58
58
  end
@@ -61,7 +61,7 @@ module Ronin
61
61
  new_string = string.dup
62
62
 
63
63
  # ensure that at least one character is swap-cased, but not all
64
- num_swaps = rand(candidates.length-1)+1
64
+ num_swaps = rand(1..(candidates.length - 1)) || 1
65
65
 
66
66
  candidates.sample(num_swaps).each do |index|
67
67
  new_string[index] = new_string[index].swapcase
@@ -73,7 +73,7 @@ module Ronin
73
73
  #
74
74
  # Generates a random String of numeric characters.
75
75
  #
76
- # @param [Integer] n
76
+ # @param [Integer, Range<Integer>] n
77
77
  # The desired length of the String.
78
78
  #
79
79
  # @return [String]
@@ -88,7 +88,7 @@ module Ronin
88
88
  #
89
89
  # Alias for {numeric}.
90
90
  #
91
- # @param [Integer] n
91
+ # @param [Integer, Range<Integer>] n
92
92
  # The desired length of the String.
93
93
  #
94
94
  # @return [String]
@@ -103,7 +103,7 @@ module Ronin
103
103
  #
104
104
  # A random octal-digit string.
105
105
  #
106
- # @param [Integer] n
106
+ # @param [Integer, Range<Integer>] n
107
107
  # The desired length of the String.
108
108
  #
109
109
  # @return [String]
@@ -118,7 +118,7 @@ module Ronin
118
118
  #
119
119
  # The upper-case hexadecimal character set.
120
120
  #
121
- # @param [Integer] n
121
+ # @param [Integer, Range<Integer>] n
122
122
  # The desired length of the String.
123
123
  #
124
124
  # @return [String]
@@ -133,7 +133,7 @@ module Ronin
133
133
  #
134
134
  # Alias for {uppercase_hex}.
135
135
  #
136
- # @param [Integer] n
136
+ # @param [Integer, Range<Integer>] n
137
137
  # The desired length of the String.
138
138
  #
139
139
  # @return [String]
@@ -148,7 +148,7 @@ module Ronin
148
148
  #
149
149
  # The lower-case hexadecimal character set.
150
150
  #
151
- # @param [Integer] n
151
+ # @param [Integer, Range<Integer>] n
152
152
  # The desired length of the String.
153
153
  #
154
154
  # @return [String]
@@ -163,7 +163,7 @@ module Ronin
163
163
  #
164
164
  # Alias for {lowercase_hex}.
165
165
  #
166
- # @param [Integer] n
166
+ # @param [Integer, Range<Integer>] n
167
167
  # The desired length of the String.
168
168
  #
169
169
  # @return [String]
@@ -178,7 +178,7 @@ module Ronin
178
178
  #
179
179
  # A random hexadecimal string.
180
180
  #
181
- # @param [Integer] n
181
+ # @param [Integer, Range<Integer>] n
182
182
  # The desired length of the String.
183
183
  #
184
184
  # @return [String]
@@ -193,7 +193,7 @@ module Ronin
193
193
  #
194
194
  # The upper-case alphabetic character set.
195
195
  #
196
- # @param [Integer] n
196
+ # @param [Integer, Range<Integer>] n
197
197
  # The desired length of the String.
198
198
  #
199
199
  # @return [String]
@@ -208,7 +208,7 @@ module Ronin
208
208
  #
209
209
  # Alias for {uppercase_alpha}.
210
210
  #
211
- # @param [Integer] n
211
+ # @param [Integer, Range<Integer>] n
212
212
  # The desired length of the String.
213
213
  #
214
214
  # @return [String]
@@ -223,7 +223,7 @@ module Ronin
223
223
  #
224
224
  # The lower-case alphabetic character set.
225
225
  #
226
- # @param [Integer] n
226
+ # @param [Integer, Range<Integer>] n
227
227
  # The desired length of the String.
228
228
  #
229
229
  # @return [String]
@@ -238,7 +238,7 @@ module Ronin
238
238
  #
239
239
  # Alias for {lowercase_alpha}.
240
240
  #
241
- # @param [Integer] n
241
+ # @param [Integer, Range<Integer>] n
242
242
  # The desired length of the String.
243
243
  #
244
244
  # @return [String]
@@ -253,7 +253,7 @@ module Ronin
253
253
  #
254
254
  # A random alphabetic string.
255
255
  #
256
- # @param [Integer] n
256
+ # @param [Integer, Range<Integer>] n
257
257
  # The desired length of the String.
258
258
  #
259
259
  # @return [String]
@@ -268,7 +268,7 @@ module Ronin
268
268
  #
269
269
  # A random alpha-numeric string.
270
270
  #
271
- # @param [Integer] n
271
+ # @param [Integer, Range<Integer>] n
272
272
  # The desired length of the String.
273
273
  #
274
274
  # @return [String]
@@ -283,7 +283,7 @@ module Ronin
283
283
  #
284
284
  # A random punctuation string.
285
285
  #
286
- # @param [Integer] n
286
+ # @param [Integer, Range<Integer>] n
287
287
  # The desired length of the String.
288
288
  #
289
289
  # @return [String]
@@ -298,7 +298,7 @@ module Ronin
298
298
  #
299
299
  # A random symbolic string.
300
300
  #
301
- # @param [Integer] n
301
+ # @param [Integer, Range<Integer>] n
302
302
  # The desired length of the String.
303
303
  #
304
304
  # @return [String]
@@ -313,7 +313,7 @@ module Ronin
313
313
  #
314
314
  # A random whitespace string.
315
315
  #
316
- # @param [Integer] n
316
+ # @param [Integer, Range<Integer>] n
317
317
  # The desired length of the String.
318
318
  #
319
319
  # @return [String]
@@ -328,7 +328,7 @@ module Ronin
328
328
  #
329
329
  # A random whitespace string.
330
330
  #
331
- # @param [Integer] n
331
+ # @param [Integer, Range<Integer>] n
332
332
  # The desired length of the String.
333
333
  #
334
334
  # @return [String]
@@ -342,7 +342,7 @@ module Ronin
342
342
  #
343
343
  # The set of printable characters, not including spaces.
344
344
  #
345
- # @param [Integer] n
345
+ # @param [Integer, Range<Integer>] n
346
346
  # The desired length of the String.
347
347
  #
348
348
  # @return [String]
@@ -357,7 +357,7 @@ module Ronin
357
357
  #
358
358
  # The set of printable characters, including spaces.
359
359
  #
360
- # @param [Integer] n
360
+ # @param [Integer, Range<Integer>] n
361
361
  # The desired length of the String.
362
362
  #
363
363
  # @return [String]
@@ -372,7 +372,7 @@ module Ronin
372
372
  #
373
373
  # A random control-character string.
374
374
  #
375
- # @param [Integer] n
375
+ # @param [Integer, Range<Integer>] n
376
376
  # The desired length of the String.
377
377
  #
378
378
  # @return [String]
@@ -387,7 +387,7 @@ module Ronin
387
387
  #
388
388
  # The signed ASCII character set.
389
389
  #
390
- # @param [Integer] n
390
+ # @param [Integer, Range<Integer>] n
391
391
  # The desired length of the String.
392
392
  #
393
393
  # @return [String]
@@ -402,7 +402,7 @@ module Ronin
402
402
  #
403
403
  # A random ASCII string.
404
404
  #
405
- # @param [Integer] n
405
+ # @param [Integer, Range<Integer>] n
406
406
  # The desired length of the String.
407
407
  #
408
408
  # @return [String]
@@ -41,6 +41,10 @@ class String
41
41
  # @return [String]
42
42
  # A random typo of the String.
43
43
  #
44
+ # @example
45
+ # "microsoft".typo
46
+ # # => "microssoft"
47
+ #
44
48
  # @see Ronin::Support::Text::Typo.substitute
45
49
  #
46
50
  # @api public
@@ -79,6 +83,11 @@ class String
79
83
  # @return [Enumerator]
80
84
  # If no block is given, an Enumerator will be returned.
81
85
  #
86
+ # @example
87
+ # "consciousness".each_typo do |typo|
88
+ # # ...
89
+ # end
90
+ #
82
91
  # @see Ronin::Support::Text::Typo.each_substitution
83
92
  #
84
93
  # @api public
@@ -110,6 +119,21 @@ class String
110
119
  # @return [Array<String>]
111
120
  # Every typo variation of the String.
112
121
  #
122
+ # @example
123
+ # "consciousness".typos
124
+ # # =>
125
+ # # ["consciusness",
126
+ # # "consciosness",
127
+ # # "conscuosness",
128
+ # # "consciosness",
129
+ # # "coonsciousness",
130
+ # # "conscioousness",
131
+ # # "conssciousness",
132
+ # # "conscioussness",
133
+ # # "consciousnesss",
134
+ # # "consciuosness",
135
+ # # "consciousnes"]
136
+ #
113
137
  # @see Ronin::Support::Text::Typo.each_substitution
114
138
  #
115
139
  # @api public
@@ -117,7 +117,7 @@ module Ronin
117
117
  # @yield [typo_word]
118
118
  # If a block is given, it will be passed each typo variation of the
119
119
  # original word.
120
- #
120
+ #
121
121
  # @yieldparam [String] typo_word
122
122
  # One of the typoed variations of the original word.
123
123
  #
@@ -132,8 +132,8 @@ module Ronin
132
132
 
133
133
  while (match = word.match(regexp,offset))
134
134
  start, stop = match.offset(0)
135
+ new_string = word.dup
135
136
 
136
- new_string = word.dup
137
137
  new_string[start...stop] = replace
138
138
  yield new_string
139
139
 
@@ -19,6 +19,6 @@
19
19
  module Ronin
20
20
  module Support
21
21
  # ronin-support version
22
- VERSION = '1.0.0'
22
+ VERSION = '1.0.2'
23
23
  end
24
24
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
4
 
@@ -22,16 +22,17 @@ Gem::Specification.new do |gem|
22
22
  gem.homepage = gemspec['homepage']
23
23
  gem.metadata = gemspec['metadata'] if gemspec['metadata']
24
24
 
25
- glob = lambda { |patterns| gem.files & Dir[*patterns] }
25
+ glob = ->(patterns) { gem.files & Dir[*patterns] }
26
26
 
27
- gem.files = `git ls-files`.split($/)
28
- gem.files = glob[gemspec['files']] if gemspec['files']
27
+ gem.files = `git ls-files`.split($/)
28
+ gem.files = glob[gemspec['files']] if gemspec['files']
29
29
  # exclude test files from the packages gem
30
30
  gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
31
31
 
32
32
  gem.executables = gemspec.fetch('executables') do
33
33
  glob['bin/*'].map { |path| File.basename(path) }
34
34
  end
35
+
35
36
  gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
36
37
 
37
38
  gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
@@ -46,7 +47,7 @@ Gem::Specification.new do |gem|
46
47
  gem.required_rubygems_version = gemspec['required_rubygems_version']
47
48
  gem.post_install_message = gemspec['post_install_message']
48
49
 
49
- split = lambda { |string| string.split(/,\s*/) }
50
+ split = ->(string) { string.split(/,\s*/) }
50
51
 
51
52
  if gemspec['dependencies']
52
53
  gemspec['dependencies'].each do |name,versions|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-01 00:00:00.000000000 Z
11
+ date: 2023-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chars
@@ -124,6 +124,7 @@ files:
124
124
  - ".gitignore"
125
125
  - ".mailmap"
126
126
  - ".rspec"
127
+ - ".rubocop.yml"
127
128
  - ".ruby-version"
128
129
  - ".yardopts"
129
130
  - COPYING.txt