• Stars
    star
    128
  • Rank 279,427 (Top 6 %)
  • Language
    Python
  • License
    Other
  • Created almost 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GEARSHIFT

GEARSHIFT is a tool that performs structure recovery for a specified function within a stripped binary. It also generates a fuzz harness that can be used to call functions in a shared object (.so) or dynamically linked library (.dll) file.

The name comes from it leveraging a mix of reverse and forward engineering.

Installation

To install the Ghidra script, copy the python files to one of your Ghidra script directories:

  1. In Ghidra, open the Script Manager (Window > Script Manager)
  2. Click the "Script Directories" button to view the list of directories
  3. Note the name of a directory. If there isn't one you can edit, add a new directory.
  4. Copy all the python files in plugin/ to the chosen directory.
  5. Click the "Refresh Script List" button. The scripts should appear in the GEARSHIFT folder in the Script Manager.

Usage

  1. Select a function whose arguments you want to analyze.
  2. From the Script Manager, under GEARSHIFT, select go.py and click Run.
  3. Any structs that are identified from the arguments of the function will be defined in Data Type Manager under $binary_name > struct.
  4. The script will generate harness code and print out the names of the files it generated
  5. Compile the harness (must be compiled with -ldl flag for shared objects)
  6. Run the harness, passing it the file name of your input file as the only argument

Example Programs

The example/ directory contains example programs that can be used to try out the tool. Compile the example programs as follows:

$ cd example
$ make

Limitations

The harnesses generated by GEARSHIFT currently depend on the LoadLibrary and dlopen functions, which are unable to load executable files. If your target is an executable rather than a shared library, you may need to write your own harness, but you can use the generated code to create the input datastructure.

If your target is an ELF executable, you may be able to fool dlopen into loading your binary by removing the PIE flag. The LIEF Project (versions >= 0.11.0) can be used to do so as described here. However, this may completely break your binary, depending on what relocations and other loader features it uses.

Leveraged technologies

The current tool is implemented as a Ghidra script. It leverages Ghidra's intermediate language and data dependency analysis to discover struct fields, and outputs its results to the Ghidra Data Type Manager. See the associated blog post for more information.

References of interest:

More Repositories

1

NotQuite0DayFriday

This is a repo which documents real bugs in real software to illustrate trends, learn how to prevent or find them more quickly.
Python
794
star
2

killerbeez

A distributed fuzzer which aims to pull in the best technologies, make them play nicely together, and run on multiple O/Ses.
C
193
star
3

delta-debugging

Debugging library to quickly get the minimal crashing test case
Python
34
star
4

IoTCameraLab

Internet-of-Things (IoT) hacking lab exercise as showcased at RSA 2018, Hack NYC, and Hack the Capital
Python
31
star
5

GOCSP-responder

OCSP responder written in Go meant to be used with easy-rsa
Go
28
star
6

linuxklee

Pulled out Linux kernel code to run in userland so they could be targeted by AFL and KLEE
C
18
star
7

killerbeez-mutators

This repo is deprecated as of 2019.08.20, all code moved to https://github.com/grimm-co/killerbeez
C
16
star
8

mme

Man-in-the-middle made easy!
Python
15
star
9

stm32-j1708

Captures J1708 messages by connecting the STM32 board to the J1708 bus, connecting USB to your computer and running j1708dump
Python
4
star
10

dji-go-4

Code used in analysis of the DJI GO 4 Android application
Java
4
star
11

hax-2018

HAX Challenges for 2018
Shell
3
star
12

afl-benchmark

Get AFL up and running in a couple minutes and see how fast your computer really is!
Python
3
star
13

killerbeez-utils

This repo is deprecated as of 2019.08.20, all code moved to https://github.com/grimm-co/killerbeez
C
2
star
14

SetRegTime

Registry timestamp manipulation. A C-rewrite of https://github.com/jschicht/SetRegTime
C++
2
star
15

httpd_msi

Apache HTTP Server v2.2.31 Windows Setup MSI
1
star