Home

Awesome

bncov - Scriptable Binary Ninja plugin for coverage analysis and visualization

bncov provides a scriptable interface for bringing together coverage information with Binary Ninja's static analysis and visualization. Beyond visualization, the abstractions in bncov allow for programmatic reasoning about coverage. It was designed for interactive GUI use as well as for factoring into larger analysis tasks and standalone scripts.

Demo Overview

This plugin is provided as a way to give back to the community, and is not part of the Mayhem product. If you're interested in Mayhem, the combined symbolic execution and fuzzing system, check us out at forallsecure.com.

CHANGELOG

Feb 2023: drcov format version 3 now supported. Oct 2021: Some changes in the API:

Installation

The easiest way is to install via the Binary Ninja plugin manager! The only difference when installing via plugin manager is that wherever you see import bncov, you'll do import ForAllSecure_bncov as bncov.

Alternatively:

Usage

Check out the tutorial for a complete walkthrough or how to get started right away using data that's already included in this repo!

First collect coverage information in DynamoRIO's drcov format (example script).

To use in Binary Ninja GUI:

  1. Open the target binary, then import coverage files using one of the commands in bncov/Coverage Data/Import * either from the Tools menu or from the context (right-click) menu.
  2. Explore the coverage visualization and explore additional analyses from the right-click menu or with the built-in interpreter and import bncov followed by covdb = bncov.get_covdb(bv).

Scripting:

  1. Ensure bncov's parent directory is in your module search path OR add it to sys.path at the top of your script like this: sys.path.append(os.path.split(os.path.normpath('/path/to/bncov'))[0])
  2. import bncov and write scripts with the CoverageDB class in coverage.py, check out the scripts folder for examples.

Screenshots

Import a coverage directory containing trace files to see blocks colored in heat map fashion: blocks covered by most traces (blue) or by few traces (red). Additional context commands (right-click menu) include frontier highlighting and a per-function block coverage report.

Watch Coverage Directory

See Relative Rarity

Highlight Rare Blocks

Highlight Frontier Blocks

Block Coverage Report

Notes

Currently the plugin only deals with block coverage and ingests files in the drcov format or "module+offset" format. Included in the repo is dr_block_coverage.py which can be used for generating coverage files, just specify your DynamoRIO install location with an environment variable (or modify the script) and it can process a directory of inputs. DynamoRIO binary packages can be found here or you can use the included download_dynamorio.py script. See the tutorial for a complete walkthrough.

Please file any feature requests/bugs as issues on GitHub, we welcome any input or feedback.

Scripting

bncov was designed so users can interact directly with the data structures the plugin uses. See the scripts/ directory for more ideas.