2016.6.21 related work: reuse code attacks

29
Related Work: Code Reuse Attacks 2016.6.21 <[email protected]> AJMachine @ 若若

Upload: aj0612

Post on 14-Apr-2017

1.053 views

Category:

Presentations & Public Speaking


0 download

TRANSCRIPT

Page 1: 2016.6.21 Related Work: Reuse Code Attacks

Related Work:Code Reuse Attacks

2016.6.21<[email protected]>

AJMachine

@ 若渴

Page 2: 2016.6.21 Related Work: Reuse Code Attacks

How to Explore Code Reuse to Construct a Turing Machine

Page 3: 2016.6.21 Related Work: Reuse Code Attacks

https://www.quora.com/What-exactly-is-Turings-Automatic-Computing-Engine

The Turing Machine

• Finite state machine• Read head

• Program

Page 4: 2016.6.21 Related Work: Reuse Code Attacks

For Example: Return-Oriented Programmingvirtual memory

heap

high

low

code

ADD gadget retLOAD gadget ret

stack

ADD gadget AddrLOAD gadget AddrSP

• Finite state machine • SP (read head) + ret

• Program • LOAD gadget ret

Page 5: 2016.6.21 Related Work: Reuse Code Attacks

For Simplicity, Code Reuse Attack Using ROP

Page 6: 2016.6.21 Related Work: Reuse Code Attacks

László Szekeres, etc., “Eternal War in Memory”

Stack overflow Use-After-Free 不只

ROP

沒畫到SMEP

Page 7: 2016.6.21 Related Work: Reuse Code Attacks

Modify a Code Pointer …

• Code pointer– Stack overflow modifies EIP. Once ret instruction is

used, the execution flow is redirected.– Heap overflow modifies function pointer with an

address that points to stack pivot gadget. Once the overwritten function pointer is used by the application, the execution flow is redirected.

– Enrique Nissim, etc.,Windows SMEP Bypass U=S (!)– …

Page 8: 2016.6.21 Related Work: Reuse Code Attacks

Just-In-Time ROP

Kevin Z. Snow, etc., “Just-In-Time Code Reuse: On the Effectiveness of Fine-Grained Address Space Layout Randomization”

ROP

ASLRASLR

Page 9: 2016.6.21 Related Work: Reuse Code Attacks

ROP semantics (Load/Store/…) RO Programming自動化找 gadgetsROP gadgets ROP compiler

Just-in-time ROP compiler Bypassing ASLR

Initial code pointer

Page 10: 2016.6.21 Related Work: Reuse Code Attacks

還需 stack overflow, 等來執行 ROP payload

Page 11: 2016.6.21 Related Work: Reuse Code Attacks

Network

AttackerVictimInitial code pointer

kuku 補充

Page 12: 2016.6.21 Related Work: Reuse Code Attacks

Researches on Code Reuse Attacks to Break Defenses

• The different FSMs• The different gadgets

Page 13: 2016.6.21 Related Work: Reuse Code Attacks

Code Reuse Attacks

• Jump-oriented programming• Loop-oriented programming• Interrupt-oriented programming• Data-oriented programming• …

Page 14: 2016.6.21 Related Work: Reuse Code Attacks

Jump-oriented Programming

Tyler Bletsch, etc.,”Jump-Oriented Programming: A New Class of Code-Reuse Attack”

• Bypassing ret integrity• Stackless

Page 15: 2016.6.21 Related Work: Reuse Code Attacks

Loop-oriented(call-ret-pairing) Programming

• Bypassing CFI and shadow stack

Page 16: 2016.6.21 Related Work: Reuse Code Attacks

Interrupt-oriented Programming

Samuel Junjie Tan, etc., “Interrupt-oriented Bugdoor Programming: A minimalist approach to bugdooring embedded systems firmware“

Page 17: 2016.6.21 Related Work: Reuse Code Attacks

IOP Setup

Timings are precise enough

Page 18: 2016.6.21 Related Work: Reuse Code Attacks

The table is from László Szekeres, etc., “Eternal War in Memory”

Data-oriented programming

假設 data address 已知

Page 19: 2016.6.21 Related Work: Reuse Code Attacks

Data-oriented Exploit

Hong Hu, etc., “Automatic Generation of Data-Oriented Exploits”

Page 20: 2016.6.21 Related Work: Reuse Code Attacks

Data-oriented Exploit

Hong Hu, etc., “Automatic Generation of Data-Oriented Exploits”

Page 21: 2016.6.21 Related Work: Reuse Code Attacks

Data-oriented Exploit

Hong Hu, etc., “Automatic Generation of Data-Oriented Exploits”

Page 22: 2016.6.21 Related Work: Reuse Code Attacks

Data-oriented Exploit isTuring-complete

Hong Hu, etc., “Data-Oriented Programming: On the Expressiveness of Non-Control Data Attacks”

Page 23: 2016.6.21 Related Work: Reuse Code Attacks

• The data consumed by the interpreter is inherently under the remote attacker’s control

• For example, all local variables are under the control of attackers using stack overflow

The Concept of Data-oriented Programming

Vulnerable FTP server with data-oriented gadgets

Page 24: 2016.6.21 Related Work: Reuse Code Attacks

Data-oriented Programming

a data-oriented gadget simulates three logical micro-operations• the load micro-operation• the intended virtual operation’s

semantics• store micro-operation.

The Evil interpreter

data-oriented gadget of assignment operation

Page 25: 2016.6.21 Related Work: Reuse Code Attacks

利用 DOP 執行 74+612

Page 26: 2016.6.21 Related Work: Reuse Code Attacks

round1

*type 被 corrupted 成 !NONE 也不是 !STREAM ,假設 *type =74 。假設 srv 被 corrupted 讓 srv + 0x8 (srv->type) 等於 size 。那執行 assignment gadget 時, *size = 74而執行 addition gadget 是無意思的。

The Evil interpreter

Page 27: 2016.6.21 Related Work: Reuse Code Attacks

round2

*type 被 corrupted 成 !NONE 也不是 !STREAM ,假設 *type =612 。假設 srv 被 corrupted 成 srv – 0x4 ,讓 srv – 0x4 + 0x8 (srv->type) 會等於 srv + 0x4 (srv->total) 。那執行 assignment gadget 時, srv->total = 612而執行 addition gadget 是無意思的

The Evil interpreter

Page 28: 2016.6.21 Related Work: Reuse Code Attacks

round3

*type 被 corrupted 成 !NONE 也不是 !STREAM ,假設 *type =612 。假設 srv 被 corrupted 成 (srv – 0x4) + 0x4那執行 assignment gadget 時, 是無意思。而執行 addition gadget 就會是 612 + 74 存至 srv->total

The Evil interpreter

Page 29: 2016.6.21 Related Work: Reuse Code Attacks

Reference• https://

www.trust.cased.de/fileadmin/user_upload/Group_TRUST/PubsPDF/blackhat-2013-jitrop.pdf

• http://www.ieee-security.org/TC/SP2013/papers/4977a574.pdf• https://nebelwelt.net/publications/files/14SP.pdf• https://www.csc.ncsu.edu/faculty/jiang/pubs/ASIACCS11.pdf• http://tcipg.org/sites/default/files/papers/2014_q3_tfs1.pdf• https://

www.usenix.org/sites/default/files/conference/protected-files/sec15_slides_hu_0.pdf

• http://huhong-nus.github.io/advanced-DOP/• https://www.ics.uci.edu/~perl/keynote_sadeghi_runtime_exploits.pdf• https://www.trust.cased.de/fileadmin/user_upload/Group_TRUST/Pub

sPDF/blackhat-2013-jitrop.pdf• http://www.ieee-security.org/TC/SP2013/papers/4977a574.pdf