rex-text 0.2.46 → 0.2.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/verify.yml +6 -5
- data/lib/rex/text/hex.rb +36 -15
- data/lib/rex/text/lang.rb +4 -38
- 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: 4e3ab248f34fa3b7917bad07015868aebb7e91af8af1a210fa90cb89da7b8edc
|
4
|
+
data.tar.gz: 853d7652f999e24504754ad1416faed2a68377c0c29e4d74ff1189b2c7194f01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d49ba31b089bc450704c14d0d93f5b2a5c40519c4d324474fa6f8c27faacb8808f71c9f36f9c8baa519084b9f20e39b9569868504d061c422fa65fc3ed1e94e
|
7
|
+
data.tar.gz: a11d6dbc2323b7e9e0aa92aa7bbdf8b67a2cbc1329ff637e4a4cfd047191ea347c58ae40bb6a5f0a4cfc614cf6e7c3561e9de629c1172e18c930534cdf5a7f25
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -33,15 +33,16 @@ jobs:
|
|
33
33
|
fail-fast: true
|
34
34
|
matrix:
|
35
35
|
ruby:
|
36
|
-
- 2.7
|
37
|
-
- 3.0
|
38
|
-
- 3.1
|
36
|
+
- '2.7'
|
37
|
+
- '3.0'
|
38
|
+
- '3.1'
|
39
|
+
- '3.2'
|
39
40
|
os:
|
40
41
|
- ubuntu-20.04
|
41
42
|
- ubuntu-latest
|
42
43
|
exclude:
|
43
|
-
- { os: ubuntu-latest, ruby: 2.7 }
|
44
|
-
- { os: ubuntu-latest, ruby: 3.0 }
|
44
|
+
- { os: ubuntu-latest, ruby: '2.7' }
|
45
|
+
- { os: ubuntu-latest, ruby: '3.0' }
|
45
46
|
test_cmd:
|
46
47
|
- bundle exec rspec
|
47
48
|
|
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
|
#
|
@@ -90,15 +64,7 @@ module Rex
|
|
90
64
|
# Converts to a Rust style array of bytes
|
91
65
|
#
|
92
66
|
def self.to_rust(str, wrap = DefaultWrap, name = "buf")
|
93
|
-
|
94
|
-
str.each_char do |char|
|
95
|
-
# "0x##,".length is 5, check if we're going over the wrap boundary
|
96
|
-
ret << "\n" if ret.split("\n").last.length + 5 > wrap
|
97
|
-
ret << "0x" << char.unpack('H*')[0] << ","
|
98
|
-
end
|
99
|
-
ret = ret[0..ret.length - 2] unless str.empty? # cut off last comma
|
100
|
-
ret << "\n" if ret.split("\n").last.length + 2 > wrap
|
101
|
-
ret << "];\n"
|
67
|
+
return numhexify(str, wrap, '', '', "let #{name}: [u8; #{str.length}] = [", "];", ',')
|
102
68
|
end
|
103
69
|
|
104
70
|
#
|
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.48
|
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:
|
96
|
+
date: 2023-01-31 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
|