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
@@ -60,7 +60,7 @@ module Ronin
|
|
60
60
|
# Custom type alignment to override the type's alignment.
|
61
61
|
#
|
62
62
|
def initialize(type,length, alignment: nil)
|
63
|
-
if type.
|
63
|
+
if type.kind_of?(UnboundedArrayType)
|
64
64
|
raise(ArgumentError,"cannot initialize an #{self.class} of #{UnboundedArrayType}")
|
65
65
|
end
|
66
66
|
|
@@ -82,7 +82,7 @@ module Ronin
|
|
82
82
|
@signed = signed
|
83
83
|
end
|
84
84
|
|
85
|
-
#
|
85
|
+
#
|
86
86
|
# Whether the scalar type is signed.
|
87
87
|
#
|
88
88
|
# @return [Boolean]
|
@@ -91,7 +91,7 @@ module Ronin
|
|
91
91
|
@signed
|
92
92
|
end
|
93
93
|
|
94
|
-
#
|
94
|
+
#
|
95
95
|
# Whether the scalar type is unsigned.
|
96
96
|
#
|
97
97
|
# @return [Boolean]
|
@@ -214,9 +214,9 @@ module Ronin
|
|
214
214
|
# The uninitialized values for the new struct's members.
|
215
215
|
#
|
216
216
|
def uninitialized_value
|
217
|
-
|
218
|
-
|
219
|
-
|
217
|
+
@members.transform_values do |member|
|
218
|
+
member.type.uninitialized_value
|
219
|
+
end
|
220
220
|
end
|
221
221
|
|
222
222
|
#
|
@@ -155,9 +155,9 @@ module Ronin
|
|
155
155
|
#
|
156
156
|
def resolve_struct(type_signature)
|
157
157
|
struct_class = type_signature
|
158
|
-
struct_members =
|
159
|
-
|
160
|
-
}
|
158
|
+
struct_members = struct_class.members.transform_values { |member|
|
159
|
+
resolve(member.type_signature)
|
160
|
+
}
|
161
161
|
|
162
162
|
struct_type = StructType.build(
|
163
163
|
struct_members, alignment: struct_class.alignment,
|
@@ -176,9 +176,9 @@ module Ronin
|
|
176
176
|
#
|
177
177
|
def resolve_union(type_signature)
|
178
178
|
union_class = type_signature
|
179
|
-
union_members =
|
180
|
-
|
181
|
-
}
|
179
|
+
union_members = union_class.members.transform_values { |member|
|
180
|
+
resolve(member.type_signature)
|
181
|
+
}
|
182
182
|
|
183
183
|
union_type = UnionType.build(
|
184
184
|
union_members, alignment: union_class.alignment
|
@@ -191,7 +191,7 @@ module Ronin
|
|
191
191
|
# Resolves a type name.
|
192
192
|
#
|
193
193
|
# @param [Symbol] name
|
194
|
-
#
|
194
|
+
#
|
195
195
|
# @return [Type]
|
196
196
|
#
|
197
197
|
def resolve_symbol(name)
|
@@ -203,4 +203,3 @@ module Ronin
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
end
|
206
|
-
|
@@ -47,7 +47,7 @@ module Ronin
|
|
47
47
|
# Cannot initialize a nested {UnboundedArrayType}.
|
48
48
|
#
|
49
49
|
def initialize(type, alignment: nil)
|
50
|
-
if type.
|
50
|
+
if type.kind_of?(UnboundedArrayType)
|
51
51
|
raise(ArgumentError,"cannot initialize a nested #{UnboundedArrayType}")
|
52
52
|
end
|
53
53
|
|
@@ -162,9 +162,9 @@ module Ronin
|
|
162
162
|
# The uninitialized values for the new union's members.
|
163
163
|
#
|
164
164
|
def uninitialized_value
|
165
|
-
|
166
|
-
|
167
|
-
|
165
|
+
@members.transform_values do |member|
|
166
|
+
member.type.uninitialized_value
|
167
|
+
end
|
168
168
|
end
|
169
169
|
|
170
170
|
#
|
@@ -61,7 +61,7 @@ module Ronin
|
|
61
61
|
# * Floating Point Types:
|
62
62
|
# * {CTypes::Float32Type float} (`-3.40282347E+38F` -
|
63
63
|
# `3.40282347E+38F`)
|
64
|
-
# * {CTypes::Float64Type double} (`-1.79769313486231570E+308` -
|
64
|
+
# * {CTypes::Float64Type double} (`-1.79769313486231570E+308` -
|
65
65
|
# `1.79769313486231570E+308`)
|
66
66
|
# * Aggregate Types:
|
67
67
|
# * {CTypes::ArrayType Array} (ex: `{1,2,3}`)
|
@@ -182,7 +182,7 @@ module Ronin
|
|
182
182
|
UINT32_NET = Network::UINT32
|
183
183
|
UINT64_NET = Network::UINT64
|
184
184
|
|
185
|
-
WORD_NET
|
185
|
+
WORD_NET = Network::WORD
|
186
186
|
DWORD_NET = Network::DWORD
|
187
187
|
QWORD_NET = Network::QWORD
|
188
188
|
|
@@ -390,7 +390,7 @@ module Ronin
|
|
390
390
|
openbsd: OS::OpenBSD,
|
391
391
|
netbsd: OS::NetBSD,
|
392
392
|
|
393
|
-
linux: OS::
|
393
|
+
linux: OS::Linux,
|
394
394
|
macos: OS::MacOS,
|
395
395
|
windows: OS::Windows
|
396
396
|
}
|
@@ -145,7 +145,7 @@ module Ronin
|
|
145
145
|
|
146
146
|
case length
|
147
147
|
when Integer then @string[index,length] = value
|
148
|
-
when nil then @string[index]
|
148
|
+
when nil then @string[index] = value
|
149
149
|
when Float::INFINITY
|
150
150
|
@string[index,@string.length - index] = value
|
151
151
|
else
|
@@ -157,7 +157,7 @@ module Ronin
|
|
157
157
|
end
|
158
158
|
|
159
159
|
#
|
160
|
-
# Returns a byte slice of the memory at the given offset and for the
|
160
|
+
# Returns a byte slice of the memory at the given offset and for the
|
161
161
|
# remainder of the memory.
|
162
162
|
#
|
163
163
|
# @param [Integer] offset
|
@@ -152,7 +152,7 @@ module Ronin
|
|
152
152
|
else index
|
153
153
|
end
|
154
154
|
|
155
|
-
if offset
|
155
|
+
if (offset + @machine_word.size) > @size
|
156
156
|
raise(IndexError,"index #{index} is out of bounds: 0...#{@size}")
|
157
157
|
end
|
158
158
|
|
@@ -184,12 +184,11 @@ module Ronin
|
|
184
184
|
else index
|
185
185
|
end
|
186
186
|
|
187
|
-
if offset
|
187
|
+
if (offset + @machine_word.size) > @size
|
188
188
|
raise(IndexError,"index #{index} is out of bounds: 0...#{@size}")
|
189
189
|
end
|
190
190
|
|
191
|
-
|
192
|
-
@string[offset,@machine_word.size] = data
|
191
|
+
@string[offset,@machine_word.size] = @machine_word.pack(value)
|
193
192
|
return value
|
194
193
|
end
|
195
194
|
|
@@ -22,6 +22,9 @@ module Ronin
|
|
22
22
|
module Support
|
23
23
|
module Binary
|
24
24
|
class Struct < Memory
|
25
|
+
#
|
26
|
+
# Represents a member defined within a {Struct}.
|
27
|
+
#
|
25
28
|
class Member
|
26
29
|
|
27
30
|
# The name of the structure member.
|
@@ -51,10 +54,9 @@ module Ronin
|
|
51
54
|
# The optional default value for the structure's field.
|
52
55
|
#
|
53
56
|
def initialize(name,type_signature, default: nil)
|
54
|
-
@name
|
57
|
+
@name = name
|
55
58
|
@type_signature = type_signature
|
56
|
-
|
57
|
-
@default = default
|
59
|
+
@default = default
|
58
60
|
end
|
59
61
|
|
60
62
|
#
|