Skip to content

hypnguyen1209/offensive-claude / skills/reverse-engineering

reverse-engineering

Verified

Use when reverse-engineering a binary or firmware — static triage + decompilation (Ghidra/IDA/Binary Ninja), dynamic instrumentation (GDB/Frida 17/angr), anti-reversing & packer bypass, OLLVM/VM deobfuscation, UEFI/BIOS RE & Secure Boot research, patch-diffing for n-days

scripts/ghidra/DecompileToC.java

View on GitHub
// DecompileToC.java - Ghidra headless postScript: decompile every function to <program>.c
//
// Usage (driven by triage.py --decompile, or standalone):
//   $GHIDRA_HOME/support/analyzeHeadless /tmp/proj triage -import ./sample -overwrite \
//       -postScript DecompileToC.java -scriptPath /path/to/scripts/ghidra
//
// Tested against Ghidra 11.3 / 11.4.x. Writes one C file next to the project working dir.
// No external dependencies beyond the Ghidra runtime.

import ghidra.app.script.GhidraScript;
import ghidra.app.decompiler.DecompInterface;
import ghidra.app.decompiler.DecompileResults;
import ghidra.program.model.listing.Function;
import java.io.FileWriter;
import java.io.PrintWriter;

public class DecompileToC extends GhidraScript {
    @Override
    public void run() throws Exception {
        DecompInterface dec = new DecompInterface();
        if (!dec.openProgram(currentProgram)) {
            printerr("Failed to open program in decompiler");
            return;
        }
        String outName = currentProgram.getName() + ".c";
        PrintWriter w = new PrintWriter(new FileWriter(outName));
        int ok = 0, fail = 0;
        for (Function f : currentProgram.getFunctionManager().getFunctions(true)) {
            if (monitor.isCancelled()) break;
            DecompileResults r = dec.decompileFunction(f, 60, monitor);
            if (r != null && r.decompileCompleted()) {
                w.println("// === " + f.getName() + " @ " + f.getEntryPoint() + " ===");
                w.println(r.getDecompiledFunction().getC());
                ok++;
            } else {
                fail++;
            }
        }
        w.close();
        dec.dispose();
        println("[DecompileToC] wrote " + outName + "  (ok=" + ok + " fail=" + fail + ")");
    }
}
add-product-e2e-evalpaperclipai/paperclipAdd or extend a Paperclip full-stack runner E2E workflow, fixture, matcher, or report evidence path for local or Daytona execution.Stars: 115kUpdated Claude CodeCodexVerifiedInstall
add-runner-evalpaperclipai/paperclipAdd or extend a Paperclip Runner protocol evaluation definition, roster, assertion, or report fixture with provenance and narrow validation.Stars: 115kUpdated Claude CodeCodexVerifiedInstall
diagnose-why-work-stoppedpaperclipai/paperclipCompatibility entry point for failed, stalled, looping, or over-recovered Paperclip work. Use fix-failed-paperclip-run for the full diagnosis, regression, repair, real verification, and green-PR workflow; honor an explicitly requested diagnosis-only scope.Stars: 115kUpdated Claude CodeCodexVerifiedInstall
fix-failed-paperclip-runpaperclipai/paperclipDiagnose and fix failed, stuck, slow, or incorrectly blocked Paperclip tasks and runs. Use with a task/run URL or failure report to trace the root cause, prove a regression red then green, check second-order effects, verify the real workflow, and deliver a PR with passing checks.Stars: 115kUpdated Claude CodeCodexVerifiedInstall