Top Related Projects
The Z3 Theorem Prover
UNIX-like reverse engineering framework and command-line toolset
Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
RetDec is a retargetable machine-code decompiler based on LLVM.
Quick Overview
Angr is a powerful and flexible binary analysis framework for Python. It combines static and dynamic symbolic analysis techniques to provide a comprehensive suite of tools for analyzing binaries, reverse engineering, and vulnerability discovery.
Pros
- Versatile: Supports multiple architectures and operating systems
- Powerful: Combines static and dynamic analysis techniques
- Extensible: Offers a plugin system for custom analyses
- Active community: Regularly updated and well-maintained
Cons
- Steep learning curve: Requires significant knowledge of binary analysis
- Resource-intensive: Can be slow and memory-hungry for large binaries
- Limited documentation: Some advanced features lack detailed explanations
- Complexity: May be overkill for simple binary analysis tasks
Code Examples
- Loading a binary and performing symbolic execution:
import angr
# Load the binary
proj = angr.Project('path/to/binary')
# Create a simulation manager
simgr = proj.factory.simulation_manager()
# Run symbolic execution until a certain address is reached
simgr.explore(find=0x400000)
# Print the found state
if len(simgr.found) > 0:
print(simgr.found[0].posix.dumps(0))
- Finding a specific path in a binary:
import angr
def is_successful(state):
return b"Success" in state.posix.dumps(1)
def should_avoid(state):
return b"Failure" in state.posix.dumps(1)
proj = angr.Project('path/to/binary')
simgr = proj.factory.simulation_manager()
simgr.explore(find=is_successful, avoid=should_avoid)
if len(simgr.found) > 0:
print("Found a successful path!")
print(simgr.found[0].posix.dumps(0))
- Analyzing a function with symbolic arguments:
import angr
proj = angr.Project('path/to/binary')
# Create a symbolic bitvector for the argument
arg = claripy.BVS('arg', 32)
# Create an initial state with the symbolic argument
state = proj.factory.call_state(0x400000, arg)
# Perform symbolic execution
simgr = proj.factory.simulation_manager(state)
simgr.run()
# Analyze the results
for state in simgr.deadended:
print(state.solver.eval(arg))
Getting Started
To get started with Angr:
-
Install Angr using pip:
pip install angr
-
Import Angr in your Python script:
import angr
-
Load a binary and create a project:
proj = angr.Project('path/to/binary')
-
Create a simulation manager and start exploring:
simgr = proj.factory.simulation_manager() simgr.explore(find=0x400000)
For more detailed information and advanced usage, refer to the official Angr documentation.
Competitor Comparisons
The Z3 Theorem Prover
Pros of z3
- More specialized and efficient for SMT solving
- Broader language support (C, C++, Python, .NET, OCaml, etc.)
- Extensive documentation and academic research backing
Cons of z3
- Narrower focus on constraint solving
- Steeper learning curve for non-experts in formal methods
- Less integrated with binary analysis workflows
Code Comparison
z3:
from z3 import *
x = Int('x')
y = Int('y')
s = Solver()
s.add(x + y > 5)
s.add(x > 1, y > 1)
print(s.check())
print(s.model())
angr:
import angr
proj = angr.Project('binary')
state = proj.factory.entry_state()
simgr = proj.factory.simulation_manager(state)
simgr.explore(find=lambda s: b"Win" in s.posix.dumps(1))
print(simgr.found[0].posix.dumps(1))
Summary
z3 is a powerful SMT solver with broad language support and extensive documentation, making it ideal for constraint solving tasks. However, it has a steeper learning curve and is less integrated with binary analysis workflows compared to angr. angr, on the other hand, provides a more comprehensive binary analysis framework but may be less efficient for pure constraint solving tasks.
UNIX-like reverse engineering framework and command-line toolset
Pros of radare2
- More lightweight and faster execution for basic reverse engineering tasks
- Extensive command-line interface with powerful scripting capabilities
- Broader platform support, including embedded systems and mobile devices
Cons of radare2
- Steeper learning curve due to complex command syntax
- Less advanced symbolic execution and program analysis features
- Limited high-level decompilation capabilities compared to angr
Code Comparison
radare2 (command-line interface):
r2 -A binary
pdf @ main
angr (Python API):
import angr
proj = angr.Project('binary')
cfg = proj.analyses.CFGFast()
Key Differences
radare2 is primarily a reverse engineering framework with a focus on binary analysis and manipulation. It excels in low-level operations and provides a powerful command-line interface.
angr, on the other hand, is a binary analysis platform that emphasizes symbolic execution and program analysis. It offers more advanced features for vulnerability discovery and exploit development.
While radare2 is better suited for quick analysis and scripting tasks, angr provides more sophisticated analysis capabilities at the cost of increased complexity and resource usage.
Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
Pros of Capstone
- Lightweight and focused solely on disassembly
- Supports a wide range of architectures
- Faster execution for simple disassembly tasks
Cons of Capstone
- Limited to disassembly; lacks advanced analysis features
- Requires additional tools for complex reverse engineering tasks
- Less suitable for symbolic execution and program analysis
Code Comparison
Capstone (disassembling x86 code):
from capstone import *
CODE = b"\x55\x48\x8b\x05\xb8\x13\x00\x00"
md = Cs(CS_ARCH_X86, CS_MODE_64)
for i in md.disasm(CODE, 0x1000):
print("%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
Angr (symbolic execution):
import angr
proj = angr.Project('binary')
state = proj.factory.entry_state()
simgr = proj.factory.simulation_manager(state)
simgr.explore(find=0x400000)
While Capstone excels at efficient disassembly across multiple architectures, Angr provides a comprehensive framework for binary analysis, including symbolic execution and program slicing. Capstone is ideal for projects requiring quick and lightweight disassembly, whereas Angr is better suited for complex reverse engineering tasks and vulnerability research.
Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
Pros of Unicorn
- Lightweight and fast emulation framework
- Supports a wide range of architectures
- Easy to integrate into existing projects
Cons of Unicorn
- Limited symbolic execution capabilities
- Less comprehensive analysis features
- Requires more manual setup for complex scenarios
Code Comparison
Unicorn
from unicorn import *
from unicorn.x86_const import *
# Initialize emulator in X86-32bit mode
mu = Uc(UC_ARCH_X86, UC_MODE_32)
# Map 2MB memory for this emulation
mu.mem_map(ADDRESS, 2 * 1024 * 1024)
# Write machine code to be emulated to memory
mu.mem_write(ADDRESS, X86_CODE32)
Angr
import angr
# Create a project
proj = angr.Project('/bin/true', load_options={'auto_load_libs': False})
# Create a simulation manager
state = proj.factory.entry_state()
simgr = proj.factory.simulation_manager(state)
# Run symbolic execution
simgr.run()
Key Differences
- Unicorn focuses on CPU emulation, while Angr provides a full-fledged binary analysis framework
- Angr offers advanced features like symbolic execution and program slicing, which are not available in Unicorn
- Unicorn is better suited for low-level emulation tasks, while Angr excels in complex program analysis scenarios
RetDec is a retargetable machine-code decompiler based on LLVM.
Pros of RetDec
- Focuses on machine code decompilation to high-level language
- Supports a wide range of architectures (x86, ARM, MIPS, PIC32, PowerPC)
- Provides a graphical user interface for easier use
Cons of RetDec
- More specialized tool compared to Angr's broader analysis capabilities
- Less active community and fewer updates in recent years
- Limited support for dynamic analysis
Code Comparison
RetDec (C++ decompilation output):
int32_t function_401000(int32_t a1) {
int32_t v1 = a1 * 2;
return v1 + 5;
}
Angr (Python-based symbolic execution):
import angr
proj = angr.Project('binary')
state = proj.factory.entry_state()
simgr = proj.factory.simulation_manager(state)
simgr.explore(find=0x401000)
RetDec focuses on producing readable high-level code from binaries, while Angr provides a framework for various binary analysis tasks, including symbolic execution. RetDec's output is typically C or C++ code, whereas Angr uses Python for analysis and exploration of program states.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
angr
angr is a platform-agnostic binary analysis framework. It is brought to you by the Computer Security Lab at UC Santa Barbara, SEFCOM at Arizona State University, their associated CTF team, Shellphish, the open source community, and @rhelmot.
Project Links
Homepage: https://angr.io
Project repository: https://github.com/angr/angr
Documentation: https://docs.angr.io
API Documentation: https://api.angr.io/en/latest/
What is angr?
angr is a suite of Python 3 libraries that let you load a binary and do a lot of cool things to it:
- Disassembly and intermediate-representation lifting
- Program instrumentation
- Symbolic execution
- Control-flow analysis
- Data-dependency analysis
- Value-set analysis (VSA)
- Decompilation
The most common angr operation is loading a binary: p = angr.Project('/bin/bash')
If you do this in an enhanced REPL like IPython, you can use tab-autocomplete to browse the top-level-accessible methods and their docstrings.
The short version of "how to install angr" is mkvirtualenv --python=$(which python3) angr && python -m pip install angr
.
Example
angr does a lot of binary analysis stuff. To get you started, here's a simple example of using symbolic execution to get a flag in a CTF challenge.
import angr
project = angr.Project("angr-doc/examples/defcamp_r100/r100", auto_load_libs=False)
@project.hook(0x400844)
def print_flag(state):
print("FLAG SHOULD BE:", state.posix.dumps(0))
project.terminate_execution()
project.execute()
Quick Start
- Install Instructions
- Documentation as HTML and sources in the angr Github repository
- Dive right in: top-level-accessible methods
- Examples using angr to solve CTF challenges.
- API Reference
- awesome-angr repo
Top Related Projects
The Z3 Theorem Prover
UNIX-like reverse engineering framework and command-line toolset
Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
RetDec is a retargetable machine-code decompiler based on LLVM.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot