GhidraPython: add type application, interface struct annotation, Go primitive types, and source comments#94
Open
Krish-Anand-dev wants to merge 2 commits intomandiant:masterfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Description
This PR improves
GhidraPython/goresym_rename.pyby closing the feature gapbetween the Ghidra script and the IDA plugin. It also adds a new section to
the README documenting how to interpret GoReSym output during malware analysis.
All existing behaviour is fully preserved — new code runs after the original
labeling block, so a failure in any new function cannot prevent core renaming
from completing.
Changes
GhidraPython/goresym_rename.pyFour additive improvements, no existing logic removed or modified:
1.
register_go_primitives(dtm)Registers
GoString,GoSlice, andGoIfaceas proper GhidraStructureDataTypeobjects under a/Gocategory in the data type manager.IDA's script did this via
idc_parse_types(). Ghidra had no equivalent —without these base types, any recovered struct referencing a string or slice
field has nothing to resolve against.
2.
apply_types(types, dtm)Parses the
CReconstructedC-like struct definitions from GoReSym's JSON output,builds a
StructureDataTypeper type, and applies it at the type's virtual addressvia
listing.createData().This is the single largest gap compared to IDA's script, which called
idc_parse_types()+apply_tinfo()per type. Analysts now see named fieldsin the decompiler view instead of raw bytes.
3.
apply_interfaces(interfaces, dtm)The original script passed interfaces to
annotate(), which only created a label.IDA's script additionally cleared the item and applied
abi_Typetinfo.This change mirrors that behaviour by applying the
GoIfacestruct layout at eachinterface VA, making
tab/datapointer fields visible in the listing.4.
annotate_func_source(user_funcs, offset)Writes
// Source: file.go:42as aPRE_COMMENTon each user function's entrypoint, using the
FileNameandLineNumberfields GoReSym already recovers when-pis used.Neither the original Ghidra script nor IDA's script did this. Analysts can now
see the original source file location directly in the disassembly listing without
cross-referencing the JSON separately.
README.mdAdded a new section "Interpreting GoReSym Output (for Reverse Engineering)"
that documents the key output fields (
UserFunctions,Strings,Types,Files & Line Information) and a practical 5-step triage workflow for analystsworking on Go-based malware. This addresses a gap in the existing docs — the
README explained how to run the tool but not how to use the output.
Testing
register_go_primitivescorrectly populates the/Gocategoryin the Data Type Manager
apply_typescreates named struct fields at type VAsapply_interfacesappliesGoIfacelayout at interface addresses(
Types,Interfaces,FileName) are absent from the JSON