Cobord / pcode2c

Convert low ghidra pcode to verifiable C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pcode2c

WIP: Do not expect this to work for you yet.

pcode2c is a Ghidra translator script from low pcode to a specialized C interpreter for the purposes of running the resulting code through off the shelf verifiers (for example CBMC). The resulting C has a direct mapping to the underlying assembly.

C is a useful intermediate because it enables using powerful off the shelf verifiers and can be directly compared (with a little muscle grease) against decompilaton or source.

This enables soundly answering questions about the relationship between high level source and binary in a relatively easy manner that no other method I know of can do.

Blog posts:

Installation

python3 -m pip install -e .

Usage

python3 -m pcode2c ./examples/min/mymin.o > tmp.c
gcc -I _templates -c tmp.c 

Ghidra Plugin Installation

  • Open up Ghidra on a binary
  • Click on Window > Script Manager in the toolbar
  • Manage Script Directories button in top right of Script Manager window (looks like a checklist)
  • Find the ./scripts directory and add it
  • Click Refresh Script List in script manager
  • There is now a PCode2C folder in the script manager. Go to it and click

Example

About

Convert low ghidra pcode to verifiable C


Languages

Language:Jupyter Notebook 47.4%Language:Python 35.0%Language:C 16.1%Language:Makefile 1.0%Language:C++ 0.4%Language:Shell 0.1%