Add to_hex_cstring method#76
Merged
Merged
Conversation
1 task
smcintyre-r7
reviewed
May 8, 2026
| # | ||
| # @param str [String] The string to convert | ||
| # @return [String] Comma-separated hex bytes with null terminator | ||
| def self.to_hex_cstring(str) |
Contributor
There was a problem hiding this comment.
This is very similiar to #numhex above it and #hexify_general notes it handles the 0xaa,0xbb,0xcc format. This differs however by not supporting the same arguments as the other hexifying methods and doesn't append a \n for better or worse. Those factors combine to make this an odd fit here.
I'm guessing the intention is to facilitate the escaped ASM strings we need. If that's the case it might be better to add a escape_cstring method Metasm directly.
e934219 to
4e54cc0
Compare
Contributor
|
Looks like we can ship this for now to unblock the release and then circle back to any additional improvements that are needed 📈 |
sjanusz-r7
pushed a commit
that referenced
this pull request
May 18, 2026
The functionality has moved to Metasm::Shellcode.define_data and Metasm::Shellcode.define_cstring, which emit full `db` directives and are a better home for assembly-source generation than rex-text. Reverts the addition from #76.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Needed for rapid7/metasploit-framework#21424
Add method to abstract handling of null-escaped hex strings in assembly.
Previously in Framework, an empty string was causing issues with Metasm.
Usage examples:
Before:
Broken with an empty string.