Skip to content

Commit dc7ef50

Browse files
committed
Merge branch 'develop'
2 parents a6eac8a + d715736 commit dc7ef50

File tree

22 files changed

+1441
-323
lines changed

22 files changed

+1441
-323
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Special thanks to [@0vercl0k](https://twitter.com/0vercl0k) for the inspiration.
1313

1414
## Releases
1515

16+
* v0.7 -- Frida, C++ demangling, context menu, function prefixing, tweaks, bugfixes.
1617
* v0.6 -- Intel pintool, cyclomatic complexity, batch load, bugfixes.
1718
* v0.5 -- Search, IDA 7 support, many improvements, stability.
1819
* v0.4 -- Most compute is now asynchronous, bugfixes.
@@ -29,7 +30,7 @@ Install Lighthouse into the IDA plugins folder.
2930
- On MacOS, the folder is at `/Applications/IDA\ Pro\ 6.8/idaq.app/Contents/MacOS/plugins`
3031
- On Linux, the folder may be at `/opt/IDA/plugins/`
3132

32-
The plugin is platform agnostic, but has only been tested on Windows for IDA 6.8 --> 7.0
33+
The plugin is compatible with IDA Pro 6.8 --> 7.0 on Windows, MacOS, and Linux.
3334

3435
## Usage
3536

@@ -67,6 +68,16 @@ The Coverage Overview is a dockable widget that provides a function level view o
6768

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

71+
## Context Menu
72+
73+
Right clicking the table in the Coverage Overview will produce a context menu with a few basic amenities.
74+
75+
<p align="center">
76+
<img alt="Lighthouse Context Menu" src="screenshots/context_menu.gif"/>
77+
</p>
78+
79+
These actions can be used to quickly manipulate or interact with entries in the table.
80+
7081
## Coverage Composition
7182

7283
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](#coverage-overview) provides an interactive means of constructing these relationships.
@@ -134,7 +145,7 @@ Loaded coverage data and user constructed compositions can be selected or delete
134145

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

137-
The examples below demonstrate how one can use [DynamoRIO](http://www.dynamorio.org) or [Intel Pin](https://software.intel.com/en-us/articles/pin-a-dynamic-binary-instrumentation-tool) to collect Lighthouse compatible coverage agaainst a target. The `.log` files produced by these instrumentation tools can be loaded directly into Lighthouse.
148+
The examples below demonstrate how one can use [DynamoRIO](http://www.dynamorio.org), [Intel Pin](https://software.intel.com/en-us/articles/pin-a-dynamic-binary-instrumentation-tool) or [Frida](https://www.frida.re) to collect Lighthouse compatible coverage against a target. The `.log` files produced by these instrumentation tools can be loaded directly into Lighthouse.
138149

139150
## DynamoRIO
140151

@@ -156,7 +167,17 @@ Example usage:
156167
pin.exe -t CodeCoverage64.dll -- boombox.exe
157168
```
158169

159-
For convenience, binaries for the Windows pintool can be found on the [releases](https://github.com/gaasedelen/lighthouse/releases/tag/v0.6.0) page. MacOS and Linux users need to compile the pintool themselves following the [instructions](coverage/pin#compilation) included with the pintool for their respective platforms.
170+
For convenience, binaries for the Windows pintool can be found on the [releases](https://github.com/gaasedelen/lighthouse/releases/tag/v0.7.0) page. MacOS and Linux users need to compile the pintool themselves following the [instructions](coverage/pin#compilation) included with the pintool for their respective platforms.
171+
172+
## Frida (Experimental)
173+
174+
Lighthouse offers limited support for Frida based code coverage via a custom [instrumentation script](coverage/frida) contributed by [yrp](https://twitter.com/yrp604).
175+
176+
Example usage:
177+
178+
```
179+
sudo python frida-drcov.py bb-bench
180+
```
160181

161182
# Future Work
162183

@@ -166,7 +187,7 @@ Time and motivation permitting, future work may include:
166187
* ~~Multifile/coverage support~~
167188
* Profiling based heatmaps/painting
168189
* Coverage & Profiling Treemaps
169-
* Additional coverage sources, trace formats, etc
190+
* ~~Additional coverage sources, trace formats, etc~~
170191
* Improved Pseudocode painting
171192

172193
I welcome external contributions, issues, and feature requests.

coverage/frida/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# frida-drcov.py
2+
3+
In this folder you will find the code coverage collection script `frida-drcov.py` that run ontop of the [Frida](https://www.frida.re/) DBI toolkit. This script will produce code coverage (using Frida) in a log format compatible with [Lighthouse](https://github.com/gaasedelen/lighthouse).
4+
5+
Frida is best supported on mobile platforms such as iOS or Android, claiming some support for Windows, MacOS, Linux, and QNX. Practically speaking, `frida-drcov.py` should only be used for collecting coverage data on mobile applications.
6+
7+
This script is labeled only as a prototype.
8+
9+
## Install
10+
11+
To use `frida-drcov.py`, you must have [Frida](https://www.frida.re/) installed. This can be done via python's `pip`:
12+
13+
```
14+
sudo pip install frida
15+
```
16+
17+
## Usage
18+
19+
Once frida is installed, the `frida-drcov.py` script in this repo can be used to collect coverage against a running process as demonstrated below. By default, the code coverage data will be written to the file `frida-drcov.log` at the end of execution.
20+
21+
```
22+
python frida-drcov.py <process name | pid>
23+
```
24+
25+
Here is an example of us instrumenting the running process `bb-bench`.
26+
27+
```
28+
$ sudo python frida-drcov.py bb-bench
29+
[+] Got module info
30+
Starting to stalk threads...
31+
Stalking thread 775
32+
Done stalking threads.
33+
[*] Now collecting info, control-D to terminate....
34+
[*] Detaching, this might take a second... # ^d
35+
[+] Detached. Got 320 basic blocks.
36+
[*] Formatting coverage and saving...
37+
[!] Done
38+
$ ls -lh frida-cov.log # this is the file you will load into lighthouse
39+
-rw-r--r-- 1 root staff 7.2K 21 Oct 11:58 frida-cov.log
40+
```
41+
42+
Using the `-o` flag, one can specify a custom name/location for the coverage log file:
43+
44+
```
45+
python frida-drcov.py -o more-coverage.log foo
46+
```
47+
48+
## Module Whitelisting
49+
50+
One can whitelist specific modules inside the target process. Say you have binary `foo` which imports the libraries `libfoo`, `libbar`, and `libbaz`. Using the `-w` flag (whitelist) on the command line, we can explicitly target modules of interest:
51+
52+
```
53+
$ python frida-drcov.py -w libfoo -w libbaz foo
54+
```
55+
56+
This will reduce the amount of information collected and improve performance. If no `-w` arguments are supplied, `frida-drcov.py` will trace all loaded images.
57+
58+
## Thread Targeting
59+
60+
On multi-threaded applications, tracing all threads can impose significant overhead. For these cases you can filter coverage collection based on thread id if you only care about specific threads.
61+
62+
In the following example, we target thread id `543`, and `678` running in the process named `foo`.
63+
64+
```
65+
python frida-drcov.py -t 543 -t 678 foo
66+
```
67+
68+
Without the `-t` flag, all threads that exist in the process at the time of attach will be traced.
69+
70+
# Authors
71+
72+
* yrp ([@yrp604](https://twitter.com/yrp604))

0 commit comments

Comments
 (0)