rex-text 0.2.62 → 0.2.63

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff5c4fff124662318b5e72b8b7eb43bc8f4bdb9545699d089450aafa57eab599
4
- data.tar.gz: d4441d13382bdfb8104687e37ac66ac92ee0545cc581c0b645bbc5069c08bf52
3
+ metadata.gz: 38b05e7a7c130d9db696f9d524e28f9cd2625dd0bea7679af45d42bd1a80e9c5
4
+ data.tar.gz: 6c5eb25945c58e4bc70c9b27e670afda87f12a989c201c8bd17e92b0638aa44e
5
5
  SHA512:
6
- metadata.gz: 47e22f78346f6cc3cd3e102dab705df958c48a907d42ab15c155802ee63c6ff02748a1f73a87581d7c402390a4e67ac7492456db6eb2e48afe5c765eefc650e9
7
- data.tar.gz: 8664319a14b2933ac154b87d185978caa014ee2c1c07a6cddf8bf6db6896ba192423bd662bb3cb41f838475cd311e5e99beb818689a599a601d4887f76572ec9
6
+ metadata.gz: d7b7005302c8640bbee97b198c3059605521af4ea7b5f7bf7ac055aaf28f16c4be47c8289a0c77c4b45c73f65eeae769e142433396060158827419c437e03b56
7
+ data.tar.gz: 65998e0159a9fea9ac51c0e9e290cb98138254250d4fb8953f80a88926e7b83480bbe0eeb8223d3efb9f3aa064a0df5e193b50768d6267e347540cb21973648a
data/lib/rex/text/hex.rb CHANGED
@@ -166,6 +166,25 @@ module Rex
166
166
  str.gsub!(regex) { |x| x[2,2].to_i(16).chr }
167
167
  end
168
168
 
169
+ #
170
+ # Converts a string to a comma-separated hex byte sequence suitable for
171
+ # use in assembly `db` directives.
172
+ #
173
+ # @example
174
+ # Rex::Text.to_hex_cstring("hi") # => "0x68, 0x69, 0x00"
175
+ # Rex::Text.to_hex_cstring("") # => "0x00"
176
+ # Rex::Text.to_hex_cstring("hi", nullbyte: false) # => "0x68, 0x69"
177
+ # Rex::Text.to_hex_cstring("", nullbyte: false) # => ""
178
+ #
179
+ # @param str [String] The string to convert
180
+ # @param nullbyte [Boolean] Whether to append a null terminator (default: true)
181
+ # @return [String] Comma-separated hex bytes
182
+ def self.to_hex_cstring(str, nullbyte: true)
183
+ bytes = str.to_s.bytes
184
+ bytes.push(0) if nullbyte
185
+ bytes.map { |byte| '0x%02x' % byte }.join(', ')
186
+ end
187
+
169
188
  private
170
189
 
171
190
  #
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Text
3
- VERSION = "0.2.62"
3
+ VERSION = "0.2.63"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.62
4
+ version: 0.2.63
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-13 00:00:00.000000000 Z
11
+ date: 2026-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake