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
@@ -59,10 +59,10 @@ module Ronin
59
59
  # @since 1.0.0
60
60
  AWS_ACCESS_KEY_ID = /(?<=[^A-Z0-9]|^)[A-Z0-9]{20}(?=[^A-Z0-9]|$)/
61
61
 
62
- # Regular expression for finding all AWS secret access key
62
+ # Regular expression for finding all AWS secret access key
63
63
  #
64
64
  # @since 1.0.0
65
- AWS_SECRET_ACCESS_KEY = /(?<=[^A-Za-z0-9\/+=]|^)[A-Za-z0-9\/+=]{40}(?=[^A-Za-z0-9\/+=]|$)/
65
+ AWS_SECRET_ACCESS_KEY = %r{(?<=[^A-Za-z0-9/+=]|^)[A-Za-z0-9/+=]{40}(?=[^A-Za-z0-9/+=]|$)}
66
66
 
67
67
  # Regular expression for finding all API keys (md5, sha1, sha256,
68
68
  # sha512, AWS access key ID or AWS secret access key).
@@ -60,7 +60,7 @@ module Ronin
60
60
  # Regular expression for finding all SSH public keys in text.
61
61
  #
62
62
  # @since 1.0.0
63
- SSH_PUBLIC_KEY = /(?:ssh-(?:rsa|dss|ed25519(?:@openssh.com)?)|ecdsa-sha2-nistp(?:256|384|521)(?:@openssh.com)?) AAAA[A-Za-z0-9+\/]+[=]{0,3} [^@\s]+@[^@\s]+/
63
+ SSH_PUBLIC_KEY = %r{(?:ssh-(?:rsa|dss|ed25519(?:@openssh.com)?)|ecdsa-sha2-nistp(?:256|384|521)(?:@openssh.com)?) AAAA[A-Za-z0-9+/]+(?:=){0,3} [^@\s]+@[^@\s]+}
64
64
  end
65
65
  end
66
66
  end
@@ -35,7 +35,7 @@ module Ronin
35
35
  # Regular expression to find file names in text
36
36
  #
37
37
  # @since 0.4.0
38
- FILE_NAME = /(?:[^\/\\\. ]|\\[\/\\ ])+(?:#{FILE_EXT})?/
38
+ FILE_NAME = %r{(?:[^/\\\. ]|\\[/\\ ])+(?:#{FILE_EXT})?}
39
39
 
40
40
  # Regular expression to find Directory names in text
41
41
  #
@@ -45,12 +45,12 @@ module Ronin
45
45
  # Regular expression to find local UNIX Paths in text
46
46
  #
47
47
  # @since 0.4.0
48
- RELATIVE_UNIX_PATH = /(?:#{DIR_NAME}\/)+#{DIR_NAME}\/?/
48
+ RELATIVE_UNIX_PATH = %r{(?:#{DIR_NAME}/)+#{DIR_NAME}/?}
49
49
 
50
50
  # Regular expression to find absolute UNIX Paths in text
51
51
  #
52
52
  # @since 0.4.0
53
- ABSOLUTE_UNIX_PATH = /(?:\/#{FILE_NAME})+\/?/
53
+ ABSOLUTE_UNIX_PATH = %r{(?:/#{FILE_NAME})+/?}
54
54
 
55
55
  # Regular expression to find UNIX Paths in text
56
56
  #
@@ -86,7 +86,6 @@ module Ronin
86
86
  #
87
87
  # @since 0.4.0
88
88
  PATH = /#{UNIX_PATH}|#{WINDOWS_PATH}/
89
-
90
89
  end
91
90
  end
92
91
  end
@@ -40,7 +40,7 @@ module Ronin
40
40
  # A regular expression for matching IPv4 Addresses.
41
41
  #
42
42
  # @since 1.0.0
43
- IPV4_ADDR = /#{decimal_octet}(?:\.#{decimal_octet}){3}(?:\/\d{1,2})?/
43
+ IPV4_ADDR = %r{#{decimal_octet}(?:\.#{decimal_octet}){3}(?:/\d{1,2})?}
44
44
 
45
45
  # A regular expression for matching IPv6 Addresses.
46
46
  #
@@ -55,15 +55,15 @@ module Ronin
55
55
  /(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,1}:#{IPV4_ADDR}/,
56
56
  /:(?::[0-9a-f]{1,4}){1,5}:#{IPV4_ADDR}/,
57
57
  /(?:(?:[0-9a-f]{1,4}:){1,5}|:):#{IPV4_ADDR}/,
58
- /(?:[0-9a-f]{1,4}:){1,1}(?::[0-9a-f]{1,4}){1,6}(?:\/\d{1,3})?/,
59
- /(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}(?:\/\d{1,3})?/,
60
- /(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}(?:\/\d{1,3})?/,
61
- /(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}(?:\/\d{1,3})?/,
62
- /(?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}(?:\/\d{1,3})?/,
63
- /(?:[0-9a-f]{1,4}:){1,6}(?::[0-9a-f]{1,4}){1,1}(?:\/\d{1,3})?/,
64
- /[0-9a-f]{1,4}(?::[0-9a-f]{1,4}){7}(?:\/\d{1,3})?/,
65
- /:(?::[0-9a-f]{1,4}){1,7}(?:\/\d{1,3})?/,
66
- /(?:(?:[0-9a-f]{1,4}:){1,7}|:):(?:\/\d{1,3})?/
58
+ %r{(?:[0-9a-f]{1,4}:){1,1}(?::[0-9a-f]{1,4}){1,6}(?:/\d{1,3})?},
59
+ %r{(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}(?:/\d{1,3})?},
60
+ %r{(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}(?:/\d{1,3})?},
61
+ %r{(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}(?:/\d{1,3})?},
62
+ %r{(?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}(?:/\d{1,3})?},
63
+ %r{(?:[0-9a-f]{1,4}:){1,6}(?::[0-9a-f]{1,4}){1,1}(?:/\d{1,3})?},
64
+ %r{[0-9a-f]{1,4}(?::[0-9a-f]{1,4}){7}(?:/\d{1,3})?},
65
+ %r{:(?::[0-9a-f]{1,4}){1,7}(?:/\d{1,3})?},
66
+ %r{(?:(?:[0-9a-f]{1,4}:){1,7}|:):(?:/\d{1,3})?}
67
67
  )
68
68
 
69
69
  # A regular expression for matching IP Addresses.
@@ -26,7 +26,7 @@ module Ronin
26
26
  #
27
27
  # @group Numeric Patterns
28
28
  #
29
-
29
+
30
30
  # Regular expression for finding all numbers in text.
31
31
  #
32
32
  # @since 1.0.0
@@ -35,7 +35,7 @@ module Ronin
35
35
  # Regular expression to find identifier in text
36
36
  #
37
37
  # @since 0.4.0
38
- IDENTIFIER = /[_]*[a-zA-Z]+[a-zA-Z0-9_-]*/
38
+ IDENTIFIER = /_*[a-zA-Z]+[a-zA-Z0-9_-]*/
39
39
 
40
40
  # Regular expression to find all variable names in text.
41
41
  #
@@ -77,7 +77,7 @@ module Ronin
77
77
  # Regular expression to find all Base64 encoded strings in the text.
78
78
  #
79
79
  # @since 1.0.0
80
- BASE64 = /(?:[A-Za-z0-9+\/]{4}\n?)+(?:[A-Za-z0-9+\/]{2}==\n?|[A-Za-z0-9+\/]{3}=\n?)?|[A-Za-z0-9+\/]{2}==\n?|[A-Za-z0-9+\/]{3}=\n?/
80
+ BASE64 = %r{(?:[A-Za-z0-9+/]{4}\n?)+(?:[A-Za-z0-9+/]{2}==\n?|[A-Za-z0-9+/]{3}=\n?)?|[A-Za-z0-9+/]{2}==\n?|[A-Za-z0-9+/]{3}=\n?}
81
81
 
82
82
  # Regular expression to match any single-line or multi-line C-style
83
83
  # comments.
@@ -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
@@ -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.beta3'
22
+ VERSION = '1.0.1'
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.beta3
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-22 00:00:00.000000000 Z
11
+ date: 2023-03-02 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