rex-text 0.2.45 → 0.2.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -2
- data/lib/rex/text/hex.rb +36 -15
- data/lib/rex/text/lang.rb +17 -29
- data/lib/rex/text/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6669fedd30c2456c0b6203cbe8dcfcdec690726fb1de674a601a4fea68166c7
|
4
|
+
data.tar.gz: a83499bb2a5e324dd71e58f7e62662a7ad937cbde461fd90d7ae4ce60995c1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37973a9f478fd2b849cf6af27cdeb979d9f8ad819f7971bc54b640f2c066ce6da42fb869724d85fb9f5f36391f835e1ce696871c5ec033d24bc983c32ed30e15
|
7
|
+
data.tar.gz: 3455a6a84bf2a28205c4a0647d86b264a1ad228f28ad2d7b04e2f295ac902b8554b28cae45c8666efbf0e5991cf2dce001fc1ef2f0b40a9892ac4435d05af55f
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
'
|
1
|
+
Ya�����M�C�e
|
2
|
+
͠`p�@�L��=E�[�����U���J���_�5M���s���"E��蟊���SR'Ƥ���z"��5�M�y����ԓZ�)�1��[eR�P�8�d��+�l�Ty������b[�M��͞J�
|
3
|
+
~�#�k[r��|�/��yq�ݓ�ߛ�N�
|
data/lib/rex/text/hex.rb
CHANGED
@@ -127,22 +127,13 @@ module Rex
|
|
127
127
|
# Converts a string to a hex version with wrapping support
|
128
128
|
#
|
129
129
|
def self.hexify(str, col = DefaultWrap, line_start = '', line_end = '', buf_start = '', buf_end = '')
|
130
|
-
|
131
|
-
|
132
|
-
raise ArgumentError.new('insufficient column width')
|
133
|
-
end
|
130
|
+
self.hexify_general(str, "\\x", col, line_start, line_end, buf_start, buf_end)
|
131
|
+
end
|
134
132
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
if (ret.split("\n").last || '').length + 4 + line_end.length > col
|
140
|
-
ret << "#{line_end}\n#{line_start}"
|
141
|
-
end
|
142
|
-
ret << "\\x" << char.unpack('H*')[0]
|
143
|
-
end
|
144
|
-
ret << "\n" if ret.split("\n").last.length + buf_end.length > col
|
145
|
-
ret << "#{buf_end}\n"
|
133
|
+
#
|
134
|
+
# Converts a string to hex, with each character prefixed with 0x; with wrapping support
|
135
|
+
def self.numhexify(str, col = DefaultWrap, line_start = '', line_end = '', buf_start = '', buf_end = '', between = '')
|
136
|
+
self.hexify_general(str, "0x", col, line_start, line_end, buf_start, buf_end, between)
|
146
137
|
end
|
147
138
|
|
148
139
|
#
|
@@ -175,5 +166,35 @@ module Rex
|
|
175
166
|
str.gsub!(regex) { |x| x[2,2].to_i(16).chr }
|
176
167
|
end
|
177
168
|
|
169
|
+
private
|
170
|
+
|
171
|
+
#
|
172
|
+
# General-case method to handle both "\xAA\xBB\xCC" format and 0xAA,0xBB,0xCC format
|
173
|
+
#
|
174
|
+
def self.hexify_general(str, char_prefix, col = DefaultWrap, line_start = '', line_end = '', buf_start = '', buf_end = '', between='')
|
175
|
+
encoded_char_length = 2 + char_prefix.length + between.length
|
176
|
+
if col < line_start.length + encoded_char_length + line_end.length
|
177
|
+
# raise an exception
|
178
|
+
raise ArgumentError.new('insufficient column width')
|
179
|
+
end
|
180
|
+
|
181
|
+
ret = buf_start.dup
|
182
|
+
ret << line_start if ret.end_with?("\n")
|
183
|
+
last_newline = ret.rindex("\n") || -1
|
184
|
+
last_line_length = ret.length - last_newline - 1
|
185
|
+
str.each_char do |char|
|
186
|
+
# Check if we're going over the wrap boundary
|
187
|
+
if last_line_length + encoded_char_length + line_end.length > col
|
188
|
+
ret << "#{line_end}\n#{line_start}"
|
189
|
+
last_line_length = line_start.length
|
190
|
+
end
|
191
|
+
ret << char_prefix << char.unpack('H*')[0] << between
|
192
|
+
last_line_length += encoded_char_length
|
193
|
+
end
|
194
|
+
# Remove the last in-between characters, if required
|
195
|
+
ret = ret[0..ret.length - 1 - between.length] unless str.empty?
|
196
|
+
ret << "\n" if last_line_length + buf_end.length > col
|
197
|
+
ret << "#{buf_end}\n"
|
198
|
+
end
|
178
199
|
end
|
179
200
|
end
|
data/lib/rex/text/lang.rb
CHANGED
@@ -28,30 +28,14 @@ module Rex
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.to_csharp(str, wrap = DefaultWrap, name = "buf")
|
31
|
-
|
32
|
-
str.each_char do |char|
|
33
|
-
# "0x##,".length is 5, check if we're going over the wrap boundary
|
34
|
-
ret << "\n" if ret.split("\n").last.length + 5 > wrap
|
35
|
-
ret << "0x" << char.unpack('H*')[0] << ","
|
36
|
-
end
|
37
|
-
ret = ret[0..ret.length - 2] unless str.empty? # cut off last comma
|
38
|
-
ret << "\n" if ret.split("\n").last.length + 2 > wrap
|
39
|
-
ret << "};\n"
|
31
|
+
return numhexify(str, wrap, '', '', "byte[] #{name} = new byte[#{str.length}] {", "};", ',')
|
40
32
|
end
|
41
33
|
|
42
34
|
#
|
43
35
|
# Converts to a golang style array of bytes
|
44
36
|
#
|
45
37
|
def self.to_golang(str, wrap = DefaultWrap, name = "buf")
|
46
|
-
|
47
|
-
str.each_char do |char|
|
48
|
-
# "0x##,".length is 5, check if we're going over the wrap boundary
|
49
|
-
ret << "\n" if ret.split("\n").last.length + 5 > wrap
|
50
|
-
ret << "0x" << char.unpack('H*')[0] << ","
|
51
|
-
end
|
52
|
-
ret = ret[0..ret.length - 2] unless str.empty? # cut off last comma
|
53
|
-
ret << "\n" if ret.split("\n").last.length + 2 > wrap
|
54
|
-
ret << "};\n"
|
38
|
+
return numhexify(str, wrap, '', '', "#{name} := []byte{", "};", ',')
|
55
39
|
end
|
56
40
|
|
57
41
|
#
|
@@ -66,17 +50,7 @@ module Rex
|
|
66
50
|
#
|
67
51
|
def self.to_nim(str, wrap = DefaultWrap, name = "buf")
|
68
52
|
raise ArgumentError.new('str can not be empty') if str.empty?
|
69
|
-
|
70
|
-
ret = "var #{name}: array[#{str.length}, byte] = [\n"
|
71
|
-
ret << "byte "
|
72
|
-
str.each_char do |char|
|
73
|
-
# "0x##,".length is 5, check if we're going over the wrap boundary
|
74
|
-
ret << "\n" if ret.split("\n").last.length + 5 > wrap
|
75
|
-
ret << "0x" << char.unpack('H*')[0] << ","
|
76
|
-
end
|
77
|
-
ret = ret[0..ret.length - 2] unless str.empty? # cut off last comma
|
78
|
-
ret << "\n" if ret.split("\n").last.length + 1 > wrap
|
79
|
-
ret << "]\n"
|
53
|
+
return numhexify(str, wrap, '', '', "var #{name}: array[#{str.length}, byte] = [\nbyte ", "]", ',')
|
80
54
|
end
|
81
55
|
|
82
56
|
#
|
@@ -86,6 +60,20 @@ module Rex
|
|
86
60
|
return "#[\n" + wordwrap(str, 0, wrap, '', '') + "]#\n"
|
87
61
|
end
|
88
62
|
|
63
|
+
#
|
64
|
+
# Converts to a Rust style array of bytes
|
65
|
+
#
|
66
|
+
def self.to_rust(str, wrap = DefaultWrap, name = "buf")
|
67
|
+
return numhexify(str, wrap, '', '', "let #{name}: [u8; #{str.length}] = [", "];", ',')
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Creates a Rust style comment
|
72
|
+
#
|
73
|
+
def self.to_rust_comment(str, wrap = DefaultWrap)
|
74
|
+
return "/*\n" + wordwrap(str, 0, wrap, '', ' * ') + " */\n"
|
75
|
+
end
|
76
|
+
|
89
77
|
#
|
90
78
|
# Creates a c-style comment
|
91
79
|
#
|
data/lib/rex/text/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rex-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Metasploit Hackers
|
@@ -93,7 +93,7 @@ cert_chain:
|
|
93
93
|
EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
|
94
94
|
9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
|
95
95
|
-----END CERTIFICATE-----
|
96
|
-
date: 2022-
|
96
|
+
date: 2022-12-12 00:00:00.000000000 Z
|
97
97
|
dependencies:
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: rake
|
@@ -185,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
|
189
|
-
rubygems_version: 2.7.10
|
188
|
+
rubygems_version: 3.3.26
|
190
189
|
signing_key:
|
191
190
|
specification_version: 4
|
192
191
|
summary: Provides Text Manipulation Methods for Exploitation
|
metadata.gz.sig
CHANGED
Binary file
|