Git Product home page Git Product logo

lighthouse-2's Introduction

Lighthouse - A Code Coverage Explorer for Reverse Engineers

Lighthouse Plugin

Overview

Lighthouse is a code coverage plugin for IDA Pro, and Binary Ninja. The plugin makes use of interactive disassemblers to map, explore, and visualize externally collected code coverage data when symbols or source may not be available for a given binary.

This plugin is labeled only as a prototype & code resource for the community.

Special thanks to @0vercl0k for the inspiration.

Releases

  • v0.8 -- Binary Ninja support, HTML coverage reports, consistent styling, many tweaks, bugfixes.
  • v0.7 -- Frida, C++ demangling, context menu, function prefixing, tweaks, bugfixes.
  • v0.6 -- Intel pintool, cyclomatic complexity, batch load, bugfixes.
  • v0.5 -- Search, IDA 7 support, many improvements, stability.
  • v0.4 -- Most compute is now asynchronous, bugfixes.
  • v0.3 -- Coverage composition, interactive composing shell.
  • v0.2 -- Multifile support, performance improvements, bugfixes.
  • v0.1 -- Initial release

IDA Pro Installation

Lighthouse is a cross-platform (Windows, macOS, Linux) python plugin, supporting IDA Pro 6.8 and newer.

  • Copy the contents of the plugin folder to the IDA plugins folder
    • On Windows, the folder is at C:\Program Files (x86)\IDA 6.8\plugins
    • On macOS, the folder is at /Applications/IDA\ Pro\ 6.8/idaq.app/Contents/MacOS/plugins
    • On Linux, the folder may be at /opt/IDA/plugins/

It has been primarily developed and tested on Windows, so that is where we expect the best experience.

Binary Ninja Installation (Experimental)

At this time, support for Binary Ninja is considered experimental. Please feel free to report any bugs that you encounter.

You can install Lighthouse & PyQt5 for Binary Ninja by following the instructions below.

Windows Installation

  1. Install PyQt5 from a Windows command prompt with the following command:
pip install --target="%appdata%\Binary Ninja\plugins\Lib\site-packages" python-qt5
  1. Copy the contents of the /plugin/ folder in this repo to your Binary Ninja plugins folder.

Linux Installation

  1. Install PyQt5 from a Linux shell with the following command:
sudo apt install python-pyqt5
  1. Copy the contents of the /plugin/ folder in this repo to your Binary Ninja plugins folder.

macOS Installation

¯\_(ツ)_/¯

Usage

Lighthouse loads automatically when a database is opened, installing a handful of menu entries into the disassembler.

Lighthouse Menu Entries

These are the entry points for a user to load and view coverage data.

Coverage Painting

Lighthouse 'paints' the active coverage data across the three major IDA views as applicable. Specifically, the Disassembly, Graph, and Pseudocode views.

Lighthouse Coverage Painting

In Binary Ninja, only the Disassembly and Graph views are supported.

Coverage Overview

The Coverage Overview is a dockable widget that provides a function level view of the active coverage data for the database.

Lighthouse Coverage Overview

This table can be sorted by column, and entries can be double clicked to jump to their corresponding disassembly.

Context Menu

Right clicking the table in the Coverage Overview will produce a context menu with a few basic amenities.

Lighthouse Context Menu

These actions can be used to quickly manipulate or interact with entries in the table.

Coverage Composition

Building relationships between multiple sets of coverage data often distills deeper meaning than their individual parts. The shell at the bottom of the Coverage Overview provides an interactive means of constructing these relationships.

Lighthouse Coverage Composition

Pressing enter on the shell will evaluate and save a user constructed composition.

Composition Syntax

Coverage composition, or Composing as demonstrated above is achieved through a simple expression grammar and 'shorthand' coverage symbols (A to Z) on the composing shell.

Grammar Tokens

  • Logical Operators: |, &, ^, -
  • Coverage Symbol: A, B, C, ..., Z
  • Coverage Range: A,C, Q,Z, ...
  • Parenthesis: (...)

Example Compositions

  • A & B
  • (A & B) | C
  • (C & (A - B)) | (F,H & Q)

The evaluation of the composition may occur right to left, parenthesis are suggested for potentially ambiguous expressions.

Hot Shell

Additionally, there is a 'Hot Shell' mode that asynchronously evaluates and caches user compositions in real-time.

Lighthouse Hot Shell

The hot shell serves as a natural gateway into the unguided exploration of composed relationships.

Search

Using the shell, one can search and filter the functions listed in the coverage table by prefixing their query with /.

Lighthouse Search

The head of the shell will show an updated coverage % computed only from the remaining functions. This is useful when analyzing coverage for specific function families.

Jump

Entering an address or function name into the shell can be used to jump to corresponding function entries in the table.

Lighthouse Jump

Coverage ComboBox

Loaded coverage data and user constructed compositions can be selected or deleted through the coverage combobox.

Lighthouse Coverage ComboBox

HTML Coverage Report

Lighthouse can generate a rudimentary HTML coverage report of the active coverage. A sample report can be seen here.

Lighthouse HTML Report

Collecting Coverage

Before using Lighthouse, one will need to collect code coverage data for their target binary / application.

The examples below demonstrate how one can use DynamoRIO, Intel Pin or Frida to collect Lighthouse compatible coverage against a target. The .log files produced by these instrumentation tools can be loaded directly into Lighthouse.

DynamoRIO

Code coverage data can be collected via DynamoRIO's drcov code coverage module.

Example usage:

..\DynamoRIO-Windows-7.0.0-RC1\bin64\drrun.exe -t drcov -- boombox.exe

Intel Pin

Using a custom pintool contributed by Agustin Gianni, the Intel Pin DBI can also be used to collect coverage data.

Example usage:

pin.exe -t CodeCoverage64.dll -- boombox.exe

For convenience, binaries for the Windows pintool can be found on the releases page. macOS and Linux users need to compile the pintool themselves following the instructions included with the pintool for their respective platforms.

Frida (Experimental)

Lighthouse offers limited support for Frida based code coverage via a custom instrumentation script contributed by yrp.

Example usage:

sudo python frida-drcov.py bb-bench

Future Work

Time and motivation permitting, future work may include:

  • Asynchronous composition, painting, metadata collection
  • Multifile/coverage support
  • Profiling based heatmaps/painting
  • Coverage & profiling treemaps
  • Additional coverage sources, trace formats, etc
  • Improved pseudocode painting
  • Lighthouse console access, headless usage
  • Custom themes
  • Python 3 support

I welcome external contributions, issues, and feature requests.

Authors

lighthouse-2's People

Contributors

agustingianni avatar ayrx avatar fmagin avatar gaasedelen avatar mrsapps avatar x9090 avatar yrp604 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.