Experimental opaque predicate detection for IDA Pro
Drop (Drop Removes Opaque Predicates) is an experimental IDA Pro plugin capable of detecting several types of opaque predicates in obfuscated binaries by making use of the symbolic-execution engine angr and its components. Specifically, Drop can detect, highlight and (primitively) remove the following types of opaque predicates:
- invariant opaque predicates (i.e. "normal" opaque predicates without context)
- contextual opaque predicates (i.e. opaque predicates that depend on one or more invariants at the predicate location)
In general, the plugin is built to be as interactive as possible, allowing the analyst to specify additional context through function hooking, symbolic global variables and additional (in-)equality constraints.
- This code was written during an internship. It is not a Riscure product and Riscure does not support or maintain this code.
- This is experimental code, intended as an experiment to see what can be accomplished by combining
angrand IDA Pro for this purpose.
- Because of certain heuristics, the plugin will in various scenarios result in false positives, false negatives, or both.
- In certain (often complex) functions, SMT constraints will become very large, and solving time might become unreasonably large. Drop provides a button to kill the current analysis, but because of Z3's architecture, this can occasionally kill IDA itself as well. It is therefore recommended you save your database before performing any heavy analysis.
Because of the instable nature of the APIs provided by angr and its components, Drop requires a very specific version of each to be installed.
In order to make installation easier, some of these have been provided as Python
.egg files in the
See the Installation section below for instructions on how to install these dependencies.
This assumes a 64-bit Windows 7 installation with IDA 6.95. Other operating systems are not tested an will require a different installation procedure. Currently, IDA 7.0 and 64-bit Python are not supported. This might change in the future.
It is assumed that (32-bit) Python 2.7,
easy_install are installed, as they come with IDA 6.95.
Make sure the 32-bit Python 2.7 executable directories are in your PATH:
Run the following commands:
pip install -r requirements.txt
easy_install -Z archinfo-188.8.131.52-py2.7.egg pyvex-184.108.40.206-py2.7.egg cle-220.127.116.11-py2.7.egg simuvex-18.104.22.168-py2.7.egg capstone-3.0.4-py2.7.egg angr-22.214.171.124-py2.7.egg
plugins/in your IDA installation folder.
The following video shows Drop in action on a simple function containing the opaque predicate
7*x*x-1 != y*y: https://streamable.com/s7fjw. The source code of the program seen in that video can be found in the demo folder.
In general, the workflow with Drop is is follows:
Open a binary* in IDA Pro.
Make sure the cursor is located within a function.
Launch Drop with Alt+F6.
Follow the steps shown in the panel:
Let angr perform a rudimentary concrete trace through the function by pressing 'concrete trace...' or manually mark code-blocks to include in the analysis.
Click the 'along trace' button to start opaque predicate detection on the currently marked basic-blocks.
Optionally (and very experimentally), patch any resulting unreachable code with NOP instructions, to hopefully simplify the function's graph view and decompilation output.
Optionally, one can specify context during step 2 to improve symbolic analysis, this is especially helpful in larger functions with many variables or function calls.
* only x86 binaries have been properly tested.