Add Go calling convention and string recovery#8304
Open
seekbytes wants to merge 1 commit into
Open
Conversation
Author
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.


Based on the two rust plugins we have for Objective-C and Swift, here's a third one that provides some enhancements around golang support for binaries.
Features include:
a MLIL workflow that sets of the correct calling convention for golang binaries. As reported in Go internal ABI specification, we have two main calling conventions for go: one based from the stack, and one that uses only mainly registers. First, we detect if we're dealing with a golang binary; second, if the function has a symbol for it and the symbol ends with
.abi0we apply the cc based on the stack. At third, we try to base the heuristic with the first basic block of the routine. If we detect we're accessing a possible argument within LLIL into the stack, then we apply the stack cc otherwise the reg one.a HLIL workflow that adjusts the strings length passed as parameters. This is done without checking symbols (🥳 ) by simply taking advantage of the correct calling convention. A string in golang is a structure that is defined by two fields: a set of characters and the length. Given any structure with less than 3 parameters is splitted into registers/stack, we check in the HLIL call for every argument: if we're able to detect a const ptr + len within two arguments (I'm using
window(2)which can be definitely improved). If yes, we cap the length of the datavar defined for the const ptr and we set the len correctly.Some questions:
2024as rust version, should I downgrade it?arch?Todo:
Should be related to: