Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
ghidra-llm-pipeline — Deterministic PyGhidra extraction, triage, and local LLM compiler-backend pipeline for C reimplementation. | Kitploit
Tools/GitHubGitHub/happytotoro116/ghidra-llm-pipeline
Static AnalysisCode AnalysisReverse EngineeringScripting & AutomationBinary AnalysisMachine LearningAI-Assisted ReversingAI Security
GitHub
happytotoro116/ghidra-llm-pipeline

ghidra-llm-pipeline

Deterministic PyGhidra extraction, triage, and local LLM compiler-backend pipeline for C reimplementation.

View Repository
41492 days agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

ghidra-llm-pipeline

Thank you for downloading my Ghidra + LLM pipeline.

This is my first README. ASL (American Sign Language) is my first language, so my English is not perfect. I did my best.


----- Why I made it -----

I love an old PC simulation I have played since childhood, and I want to improve it under the hood.

Looking at open-source games like OpenRA and OpenTTD taught me this: a hobbyist reimplementation is not about getting the original source code. It is about building a new open-source version of the game that can load the assets of the original. Then anyone can expand it or contribute.

To do the work I use two kinds of AI together:

  • Cloud AI for knowledge and advice (and for Python scripting help).
  • Local LLMs for the heavy work (writing the code).

----- The pipeline -----

  1. PyGhidra dumps the program as assembly and as C pseudocode.
  2. Headers are the most important part. Each function gets a header with the functions and globals it uses.
  3. Grouping: Python groups the functions that call each other into "classes".
  4. Triage: Python reads the strings used by each group to guess what it is for.
  5. Roles: a script lists the likely role of each class, and makes the work queues.

----- The labels (triage) -----

Every function gets one label. This saves a lot of time, because I do not waste effort on the big pool of OS and runtime junk.

|-----------|------------------------------------------------------------------------------------------------------------------

LabelMeaning
KEEPThe game's own logic (for example the flight model, the damage model, TrackIR)
WRAPJava-facing glue that calls OS or input APIs: keep the signature, write a new body.
(IL-2 1946 is an interesting engine: C++ and Java together.)
REPLACEOld C runtime, allocator, thunks: the compiler or OS provides them, so a new 64-bit version does not need them
UNKNOWNNot clear: look at it by hand
-----------------------------------------------------------------------------------------------------------------------------

In my test program, about 44% of the functions were REPLACE, so they never needed to be converted.


----- Assembly, not C pseudocode -----

At the start I trusted the C pseudocode to have all the answers. That was naive. It is Ghidra's interpretation of the assembly, and it guesses (variable types, lost arguments).

The assembly is the raw truth. It has no variable types, but it holds the exact behavior of each function. So the scripts read the assembly, and turn it into a blueprint in C-like form. Ghidra's C is kept only as a hint.


----- LLM as a compiler, not an assembler -----

My early tests used the local LLMs (Qwen 2.5 Coder, DeepSeek Coder V2 Lite, Mellum 2) to read the assembly directly. It never worked reliably. They hallucinated, because they are made to write code, not to read raw machine code.

After many failed experiments I split the work:

  • Python is the assembler. It reads the assembly and writes the blueprint: exact facts, a register-level C draft and a checklist.
  • The LLM is the compiler. It writes the real C freely from the blueprint.
  • Python checks the answer (text checks and a real compiler) and fixes small slips.

NOTE: How Python checks the answer

  • Text checks: the function name, every call, global and string from the blueprint, the loops, the step sizes, the compared constants, the return value, and that no register names or invented names are left.

  • gcc compile check: the code is compiled with gcc (syntax only, nothing is run). This helped a lot. In an early run the text checks passed Mellum 2's answers, but none of them compiled, because of a header comment written outside a comment. gcc catches what text checks cannot see: undeclared or redeclared variables, wrong types, and broken braces or semicolons. A function counts as PASS only when the text checks and the compile are both OK. gcc does not prove the logic is right, so I still read the code against the blueprint.

  • If a check fails, the LLM gets the list of what failed and tries once more.

  • Python fixes small slips by itself, without the LLM: it declares each variable once, wraps loose header lines in a comment, makes the last return return the right result, and adds the includes and declarations.

The checklist came after I saw the LLMs fail on very long functions. It works like the checklist a pilot uses before take-off and landing. Python writes it from the function, and checks the answer against it. In my tests the long functions started to pass, and the runs got faster.


----- What is in this repository -----

|-------------------|---------------------------------------|---------------------------------------------

FolderWhat it doesRead
ghidra_pipelineDump, grouping, triage, rolesghidra_pipeline/INSTRUCTION.txt
llm_pipelineBlueprints and the LLM runner (v3)llm_pipeline/INSTRUCTION_BLUEPRINT_LLM.txt
-------------------------------------------------------------------------------------------------------

Start with ghidra_pipeline, then go to llm_pipeline when you are ready to use your local LLMs.


----- Quick start -----

First, analyze your program in PyGhidra and run PyGhidra Scripts/decompile_full_dump.py. The two INSTRUCTION files explain the folder setup. Then:

First, analyze your program in PyGhidra and run PyGhidra Scripts/decompile_full_dump.py. The two INSTRUCTION files explain the folder setup. Then:

python .\make_full_lite_v2.py --in . --out .\OUT
python .\triage_evidence_v2.py --lite .\OUT\LITE_AC
python .\build_roles_v2.py --triage .\OUT\TRIAGE

python .\blueprint_v3.py --group ".\SOURCE\LITE_AC\<GroupName>" --out ".\G_<GroupName>\BLUEPRINT_v3"
python .\run_blueprint_llm_v3.py --bp ".\G_<GroupName>\BLUEPRINT_v3" --out ".\G_<GroupName>\RUN1_v3_<model>" --model <model name>

You need Ghidra with PyGhidra, Python 3, LM Studio (one model loaded), and gcc (recommended, used as a compile check).


----- Results so far -----

  • One group of 6 functions from one 32-bit Windows program, three local models.
  • All three models gave logically correct code (I read it against the blueprints). The automatic checker passed 6/6, 6/6 and 5/6.
  • I keep working on it. This is the first release.

----- Limits -----

  • Tested on one program only. Please try others.
  • PASS means the checks and the compile are OK. It does not prove the logic is right.
  • 32-bit programs only (addresses are read as 8 hex digits).
  • Pointers are typed as 32-bit integers. A 64-bit build needs pointer-sized types.
  • Triage labels are guesses, not proof.
  • Some settings in the scripts are examples for my test program. Set them for yours.
  • Please do not trust PASS alone. If you have a cloud AI such as Claude, give it the LLM output together with the original assembly and C pseudocode from the SOURCE folder, and ask it to compare them function by function. That tells you whether the code really passes. This is how I checked my own results. Only upload files you are allowed to share.

----- No game files -----

Download Tool