Angry Hacking
How angr pwned CTFs and the CGC
Zardus
kereoz
rhelmot
nezorg
Fish
salls
Zardus
Fish
Motivation 6 mins
Fundamentals of angr 3 mins
Pure awesomeness
angr modules 7 mins
Symbolic execution
Static analysis
angr applications 25 mins
"Crypto" challenge
Rop gadget finder
Executing arbitrary code
Cyber Grand Challenge
Open source! 3 minutes
http://angr.io
Credits
Why angr?
BAP
BitBlaze
amoco
BARF
Bindead
Triton
CodeReason
radare2
PySysEmu
miasm
paimei
insight
rdis
SemTrax
JARVIS
Jakstab
vivisect
2005 Hex-Rays was founded
2015 ???
2007 Hex-Rays Decompiler 1.0
2009 Hex-Rays IDA 5.5
2013 Hex-Rays IDA 6.4
2011 Hex-Rays IDA 6.1
Fundamentals of angr
Static Analysis Routines
Symbolic Execution Engine
Control-Flow Graph
Data-Flow Analysis
Binary Loader
Value-Set Analysis
angr
ARE YOU READY FOR THE ANGRY POWER?
Symbolic execution
"How do I trigger path X or condition Y?"
We need something slightly different.
"How do I trigger path X or condition Y?"
Constraint solving:
Constraints | |
x >= 10 x < 100 |
x = 42 | |
Concretize
x = int(input())
if x >= 10:
if x < 100:
print "Two!"
else:
print "Lots!"
else:
print "One!"
x = int(input())
if x >= 10:
if x < 100:
print "Two!"
else:
print "Lots!"
else:
print "One!"
State A | |
Variables x = ??? | |
Constraints ------ |
x = int(input())
if x >= 10:
if x < 100:
print "Two!"
else:
print "Lots!"
else:
print "One!"
State A | |
Variables x = ??? | |
Constraints ------ |
State AA | |
Variables x = ??? | |
Constraints x < 10 |
State AB | |
Variables x = ??? | |
Constraints x >= 10 |
x = int(input())
if x >= 10:
if x < 100:
print "Two!"
else:
print "Lots!"
else:
print "One!"
State AA | |
Variables x = ??? | |
Constraints x < 10 |
State AB | |
Variables x = ??? | |
Constraints x >= 10 |
x = int(input())
if x >= 10:
if x < 100:
print "Two!"
else:
print "Lots!"
else:
print "One!"
State AA | |
Variables x = ??? | |
Constraints x < 10 |
State AB | |
Variables x = ??? | |
Constraints x >= 10 |
State ABA | |
Variables x = ??? | |
Constraints x >= 10 x < 100 |
State ABB | |
Variables x = ??? | |
Constraints x >= 10 x >= 100 |
x = int(input())
if x >= 10:
if x < 100:
print "Two!"
else:
print "Lots!"
else:
print "One!"
State ABA | |
Variables x = ??? | |
Constraints x >= 10 x < 100 |
Concretized ABA | |
Variables x = 99 | |
Static analysis
angr’s CFG | IDA’s CFG |
|
|
In [1]: import angr
In [2]: p = angr.Project("fauxware")
In [3]: cfg = p.analyses.CFG()
In [4]: print len(cfg.graph.nodes())
78
I want a faster CFG...
Check out GirlScout!
Umm... what’s BoyScout?
Memory access checks | Type inference |
Variable recovery | Range recovery |
Wrapped-interval analysis | |
Value-Set Analysis | |
Abstract interpretation |
Gogul Balakrishnan
Value-Set Analysis (VSA)
WYSINWYX: WHAT YOU SEE IS NOT WHAT YOU EXECUTE
Example
What is rbx in the yellow square?
cmp rbx, 0x1024
ja _OUT
cmp [rax+rbx], 1337
je _OUT
add rbx, 4
rbx?
mov rax, 0x400000
mov rbx, 0
Symbolic execution: state explosion
Naive static analysis: "anything"
Range analysis: "< 0x1024"
Can we do better?
Value Set Analysis - Strided Intervals
4[0x100, 0x120],32
Stride
Low
High
Size
0x100 | 0x10c | 0x118 |
0x104 | 0x110 | 0x11c |
0x108 | 0x114 | 0x120 |
Example
What is rbx in the yellow square?
cmp rbx, 0x1024
ja _OUT
cmp [rax+rbx], 1337
je _OUT
add rbx, 4
rbx?
1. | 1[0x0, 0x0],64 |
2. | 4[0x0, 0x4],64 |
3. | 4[0x0, 0x8],64 |
4. | 4[0x0, 0xc],64 |
5. | 4[0x0, ∞],64 |
6. | 4[0x0, 0x1024],64 |
mov rax, 0x400000
mov rbx, 0
Widen
Narrow
1
2
3
4
5
6
extended Value-Set Analysis (VSA)
mov rcx, rax
dec rax
cmp rax, 5
je Left
Left
...
Right
...
rax == 5
extended Value-Set Analysis (VSA)
mov rcx, rax
dec rax
cmp rax, 5
je Left
Left
...
Right
...
rax == 5
rcx == 6
Wrapped-interval analysis
extended Value-Set Analysis (VSA)
Jorge A. Navas
Peter Schachte
Harald Sondergaard
Peter J. Stuckey
Signedness-Agnostic Program Analysis: Precise Integer Bounds for Low-Level Code
angr applications
ROP gadget finder
"Crypto" Challenge!
Executing arbitrary code
rxc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, stripped
We got some suspected ROP chains from the traffic!
rxc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, stripped
Calling the tea_encipher() function
tea_encipher(info_block* info, void* data, int size);
Binary diffing
Cyber Grand Challenge
CB�vulnerable program
RB�patched program
POV�exploit
Cyber�Reasoning�System
CB
Proposed�RBs
Proposed�POVs
Autonomous vulnerability scanning
Shellphish CRS
Autonomous service resiliency
PCAP
Test cases
POV
RB
Autonomous processing
Autonomous patching
Program
Symbolic �inputs
Symbolic
execution engine
Security policies
Security
policy checker
POVs
Open Source
Major contributors:
Special thanks to:
Open angr!
Pull requests, issues, questions, etc super-welcome! Let's bring on the next generation of binary analysis!
Birthday: September 2013
Total line numbers: 59950
Total commits: ALMOST 9000!! (actually ~6000)
Draft and backups