-
-
Notifications
You must be signed in to change notification settings - Fork 374
How can I automate the diffing process?
Diaphora can be used from within an interactive IDA or it can be used in batch mode with either IDA or Radare2. In order to export a binary file to a SQLite database in batch mode, one needs to set some specific environment variables and then run the script corresponding to the specific backend used. See below for how to do so for each specific tool.
First, set the following environment variables:
$ export DIAPHORA_EXPORT_FILE=/path/to/store/the/export/database.db
$ export DIAPHORA_AUTO=1
Then, run IDA in batch mode passing the path to diaphora. For IDA 7.0:
$ ida -A -B -S/path/to/diaphora.py your_binary
or
$ ida64 -A -B -S/path/to/diaphora.py your_binary
...and for <= IDA 6.95:
$ idaq -A -B -S/path/to/diaphora.py your_binary
or
$ idaq64 -A -B -S/path/to/diaphora.py your_binary
Please remember that only IDA >= 6.8 is supported.
The process is similar as to exporting: set environment variables, then run a tool. The process is pure Python and doesn't require IDA:
$ export DIAPHORA_AUTO=1
$ export DIAPHORA_AUTO_DIFF=1
$ export DIAPHORA_DIFF_OUT=/path/to/store/the/diffing/results/database.db
$ export DIAPHORA_DB1=/first/database/to/diff.db
$ export DIAPHORA_DB2=/second/database/to/diff.db
$ python /path/to/diaphora/diaphora.py
Or, if you prefer, you can just do the following:
$ python /path/to/diaphora/diaphora.py first.db second.db -o output.db
$ ida64 -A -S"/path/to/diaphora_load_and_import.py output.db first.db second.db" your_binary.i64
- DIAPHORA_MAX_PROCESSED_ROWS: Maximum number of rows to process from a heuristic query.
- DIAPHORA_TIMEOUT_LIMIT: Timeout (in seconds) to stop processing a heuristic.