capa: migrate to PyGhidra #29
Replies: 3 comments 20 replies
-
Hi @darshan-crypto , please review our contributor guidance and reach out here if you have any questions. This project will primarily focus on migrating the code found under https://github.com/mandiant/capa/tree/master/capa/features/extractors/ghidra so I'd recommend starting there while also reviewing capa's documentation, if you haven't already 😄 |
Beta Was this translation helpful? Give feedback.
-
Hi @mike-hunhoff, Thank you for your response! I've reviewed the contributor guidance, GSOC time management guide, and the code under capa/features/extractors/ghidra, and explored capa's documentation to understand its architecture and functionality. To familiarize myself with the migration process, I tried migrating the is_supported_ghidra_version function in capa/ghidra/helpers.py to PyGhidra.This was just a test to understand how the migration will work and I successfully mitigated this function. If you'd like, I can share the code snippet of the mitigated function for review to ensure I'm heading in the right direction. Let me know what you think! Thank you. |
Beta Was this translation helpful? Give feedback.
-
Hi @mike-hunhoff, To familiarize myself with the migration process, I tried to migrate the is_supported_ghidra_version function in capa/ghidra/helpers.py to use PyGhidra. Old Implementation (Ghidrathon)def is_supported_ghidra_version():
version = float(getGhidraVersion()[:4]) # type: ignore [name-defined] # noqa: F821
if version < 10.2:
warning_msg = "capa does not support this Ghidra version"
logger.warning(warning_msg)
logger.warning("Your Ghidra version is: %s. Supported versions are: Ghidra >= 10.2", version)
return False
return True Above function was used in capa/ghidra/capa_explorer.py at line 349 as: if not capa.ghidra.helpers.is_supported_ghidra_version(): In Ghidrathon, both the REPL and all Python modules had direct access to all Instance variables and methods of GhidraScript class. Here helpers.py can access getGhidraVersion function directly.New Implementation (PyGhidra)def is_supported_ghidra_version(ghidraScript: GhidraScript):
version = float(ghidraScript.getGhidraVersion()[:4]) # type: ignore [name-defined] # noqa: F821
if version < 10.2:
warning_msg = "capa does not support this Ghidra version"
logger.warning(warning_msg)
logger.warning("Your Ghidra version is: %s. Supported versions are: Ghidra >= 10.2", version)
return False
return True Now, this function is used in capa/ghidra/capa_explorer.py at line 349 as: if not capa.ghidra.helpers.is_supported_ghidra_version(this): Here this variable points to the GhidraScript Object. In PyGhidra, the REPL has direct access to all instance methods and variables of the GhidraScript class. However, Python modules do not have this direct access.In this case:
This migration was mainly to adapt to PyGhidra's behavior, where GhidraScript needs to be explicitly passed as an function argument. Could you review this and let me know if I’m on the right track? Any feedback would be greatly appreciated! Thank you for your support. |
Beta Was this translation helpful? Give feedback.
-
Hi @mike-hunhoff and @mandiant/flare-gsoc ,
I am Darshan sojitra. I'm interested in contributing to the "capa: migrate to PyGhidra" project for GSoC 2025. I've reviewed the project description and understand the goal is to migrate the capa Ghidra backend from Ghidrathon to PyGhidra for better long-term support and compatibility.
I have the necessary skills including Python programming, Capa tool, experience with Git/GitHub, and familiarity with Ghidra and its scripting capabilities.
I'd like to hear any initial guidance or suggestions from you and the team. Also, are there any specific areas of the migration that you'd recommend focusing on first?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions