SlideShare a Scribd company logo
2
Most read
4
Most read
6
Most read
Return Oriented Programming (ROP) 
INTRODUCTION, EXPLOITATIONS AND COUNTER-MEASURES 
Pipat Methavanitpong 
Doctoral Student 
ppmet.th@vlsi.ce.titech.ac.jp 
Kunieda-Isshiki Laboratory 
Department of Communications and Computer Engineering 
Tokyo Institute of Technology 
11/4/2014
What is ROP? 
A program composes of functions 
◦ A lot of Calls and Returns 
Manipulating return addresses 
Go to other Address / Function / Program 
Can be done without injecting new code 
Example 
◦ [Linux] Opening sh shell 
◦ [Windows] Opening a calculator 
source: https://en.wikipedia.org/wiki/Return-oriented_programming
Anatomy of x86 Stack 
Caller • Function Arguments 
Callee 
• Function Return Address 
• Frame Pointer 
• Exception Handler Frame 
• Locally Declared Variables and Buffers 
• Callee Save Registers 
Higher Addresses 
Grow Downward 
Lower Addresses 
source: http://msdn.microsoft.com/en-us/library/aa290051.aspx#vctchcompilersecuritychecksindepthanchor3
Attack 
Approaches 
Stack 
Smashing 
Attack 
Return-to-libc 
Borrowed 
Code 
Chunks 
(Gadgets) 
1. Stack Smashing 
2. Return-to-libc 
3. Borrowed Code 
Chunks
Stack 
Smashing 
Overflow data in stack to its header 
or beyond 
Example 
• Size unchecked string input/copy 
• “HELLOBUG”x5 
• Overwrite return address of 
DrawLine() 
• When DrawLine() returns, it 
goes to address of value 
“HELLOBUG” 
H E L L O B U G 
H E L L O B U G 
H E L L O B U G 
H E L L O B U G 
H E L L O B U G 
source: https://en.wikipedia.org/wiki/Return-oriented_programming
Return-to-libc 
Common component of a program 
◦ Target once, apply all 
Provide handful functions (it’s a library) 
◦ system() can be used to execute shell commands 
Library’s code is marked as executable 
◦ Recent defenses force a restriction on execution on address spaces 
◦ Non executable (NX) bit feature is useless 
Steps 
◦ Exploit a buffer overflow vulnerability to gain flow control 
◦ Craft a targeted function’s arguments e.g. “/bin/bash” 
◦ Return to the targeted function entry e.g. “system()”
Borrowed 
Code Chunks 
(Gadgets) 
Registers tend to be reused 
Many chances to access memory 
Neutral instructions can serve evil 
No need to inject code 
Link these together 
YOU ARE HACKED! 
source: Black Hat 2008 – ROP Exploitation without Code Injection
Defenses 
Stack Canary 
Stack smashing protection 
A layer between a buffer and control data 
Verify it to confirm stack overflow or not 
StackGuard / ProPolice / GS Security Cookie 
NX bit 
Mark memory as executable or not 
Can be hardware implementation or software 
(emulated) 
GCC FORTIFY_SOURCE 
Detect and prevent buffer overflow during 
compile-time 
Sometimes, buffer size is known 
ASCII Zone 
Fill memory with NULL character to prevent 
string abuse 
Address Space Layout Randomization (ASLR) 
Random placing program and library code 
Position Independent Executable (PIE) 
Allow the executable part of a program to be 
reallocated everywhere 
Section Rearrangement 
Mitigate damage of overflow 
E.g. data and bss section to the lowest 
 Overflow does not overwrite other important parts of 
program’s sections
Further Resources 
Black Hat 2008 – ROP Exploitation without Code Injection 
SecurityTube – Buffer Overflow Primer Part 8 (Return To Libc Theory) 
Marcelo Carvalho – Buffer Overflow with a Practical Example 
RSA Conf 2010 – Practical Return-Oriented Programming 
Sebastian Krahmer – x86-64 buffer overflow exploits and the borrowed code chunks exploitation technique 
Florida State University – Offensive Computer Security Lectures 
Black Hat 2004 – A Comparison of Buffer Overflow Prevention Implementations and Weaknesses 
OpenRCE – Reversing Microsoft Visual C++ part I: Exception Handling 
Fedora – Security Features 
Red Hat Magazine – Limiting Buffer Overflow with ExecShield 
Microsoft Technet – On the Effectiveness of DEP and ASLR

More Related Content

What's hot (20)

PPTX
Return Oriented Programming (ROP) Based Exploits - Part I
n|u - The Open Security Community
 
PPT
Virtual platform
sean chen
 
PDF
One Shellcode to Rule Them All: Cross-Platform Exploitation
Quinn Wilton
 
PDF
Return-Oriented Programming: Exploits Without Code Injection
guest9f4856
 
PPTX
07 - Bypassing ASLR, or why X^W matters
Alexandre Moneger
 
PPTX
05 - Bypassing DEP, or why ASLR matters
Alexandre Moneger
 
PDF
ROP 輕鬆談
hackstuff
 
ODP
Design and implementation_of_shellcodes
Amr Ali
 
PDF
System Hacking Tutorial #2 - Buffer Overflow - Overwrite EIP
sanghwan ahn
 
PDF
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
DVClub
 
PPT
Ilfak Guilfanov - Decompiler internals: Microcode [rooted2018]
RootedCON
 
PDF
不深不淺,帶你認識 LLVM (Found LLVM in your life)
Douglas Chen
 
PDF
Triton and symbolic execution on gdb
Wei-Bo Chen
 
PPTX
Berkeley Packet Filters
Kernel TLV
 
PPTX
04 - I love my OS, he protects me (sometimes, in specific circumstances)
Alexandre Moneger
 
PPTX
Software to the slaughter
Quinn Wilton
 
PDF
Exploitation Crash Course
UTD Computer Security Group
 
PDF
[COSCUP 2021] A trip about how I contribute to LLVM
Douglas Chen
 
PPTX
Shellcode mastering
Positive Hack Days
 
PPTX
Bypassing DEP using ROP
Japneet Singh
 
Return Oriented Programming (ROP) Based Exploits - Part I
n|u - The Open Security Community
 
Virtual platform
sean chen
 
One Shellcode to Rule Them All: Cross-Platform Exploitation
Quinn Wilton
 
Return-Oriented Programming: Exploits Without Code Injection
guest9f4856
 
07 - Bypassing ASLR, or why X^W matters
Alexandre Moneger
 
05 - Bypassing DEP, or why ASLR matters
Alexandre Moneger
 
ROP 輕鬆談
hackstuff
 
Design and implementation_of_shellcodes
Amr Ali
 
System Hacking Tutorial #2 - Buffer Overflow - Overwrite EIP
sanghwan ahn
 
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
DVClub
 
Ilfak Guilfanov - Decompiler internals: Microcode [rooted2018]
RootedCON
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
Douglas Chen
 
Triton and symbolic execution on gdb
Wei-Bo Chen
 
Berkeley Packet Filters
Kernel TLV
 
04 - I love my OS, he protects me (sometimes, in specific circumstances)
Alexandre Moneger
 
Software to the slaughter
Quinn Wilton
 
Exploitation Crash Course
UTD Computer Security Group
 
[COSCUP 2021] A trip about how I contribute to LLVM
Douglas Chen
 
Shellcode mastering
Positive Hack Days
 
Bypassing DEP using ROP
Japneet Singh
 

Similar to Return oriented programming (ROP) (20)

PDF
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Miguel Arroyo
 
DOCX
Report on hacking blind
NikitaAndhale
 
PPTX
antoanthongtin_Lesson 3- Software Security (1).pptx
23162024
 
PDF
DEF CON 27 - OMER YAIR - exploiting windows exploit mitigation for rop exploits
Felipe Prado
 
PDF
Code Vulnerabilities & Attacks
Marcus Botacin
 
PDF
IEEE BE-BTECH NS2 PROJECT@ DREAMWEB TECHNO SOLUTION
ranjith kumar
 
PDF
IRJET - Buffer Overflows Attacks & Defense
IRJET Journal
 
PDF
Software Security
Roman Oliynykov
 
PDF
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
PDF
Buffer overflow null
nullowaspmumbai
 
PPSX
Buffer overflow
Ambuj Kumar
 
PDF
Advanced Arm Exploitation
Himanshu Khokhar Jaat
 
PPT
Buffer Overflows
Sumit Kumar
 
PDF
Return Oriented Programming - ROP
Mihir Shah
 
PPT
Buffer Overflow Attacks
harshal kshatriya
 
PDF
Buffer overflow tutorial
hughpearse
 
PPTX
Stack-Based Buffer Overflows
Daniel Tumser
 
PPTX
Control hijacking
Prachi Gulihar
 
PDF
rop heap attacks cfi int overflows computer security
FannyBellows
 
PPT
Software(runtime) attacks
Amir Neziri
 
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Miguel Arroyo
 
Report on hacking blind
NikitaAndhale
 
antoanthongtin_Lesson 3- Software Security (1).pptx
23162024
 
DEF CON 27 - OMER YAIR - exploiting windows exploit mitigation for rop exploits
Felipe Prado
 
Code Vulnerabilities & Attacks
Marcus Botacin
 
IEEE BE-BTECH NS2 PROJECT@ DREAMWEB TECHNO SOLUTION
ranjith kumar
 
IRJET - Buffer Overflows Attacks & Defense
IRJET Journal
 
Software Security
Roman Oliynykov
 
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
Buffer overflow null
nullowaspmumbai
 
Buffer overflow
Ambuj Kumar
 
Advanced Arm Exploitation
Himanshu Khokhar Jaat
 
Buffer Overflows
Sumit Kumar
 
Return Oriented Programming - ROP
Mihir Shah
 
Buffer Overflow Attacks
harshal kshatriya
 
Buffer overflow tutorial
hughpearse
 
Stack-Based Buffer Overflows
Daniel Tumser
 
Control hijacking
Prachi Gulihar
 
rop heap attacks cfi int overflows computer security
FannyBellows
 
Software(runtime) attacks
Amir Neziri
 
Ad

More from Pipat Methavanitpong (6)

PPTX
Influence of Native Language and Society on English Proficiency
Pipat Methavanitpong
 
PPTX
Intel processor trace - What are Recorded?
Pipat Methavanitpong
 
PPTX
Principles in software debugging
Pipat Methavanitpong
 
PDF
HPP Week 1 Summary
Pipat Methavanitpong
 
PPTX
Exploring the World Classroom: MOOC
Pipat Methavanitpong
 
PPTX
Seminar 12-11-19
Pipat Methavanitpong
 
Influence of Native Language and Society on English Proficiency
Pipat Methavanitpong
 
Intel processor trace - What are Recorded?
Pipat Methavanitpong
 
Principles in software debugging
Pipat Methavanitpong
 
HPP Week 1 Summary
Pipat Methavanitpong
 
Exploring the World Classroom: MOOC
Pipat Methavanitpong
 
Seminar 12-11-19
Pipat Methavanitpong
 
Ad

Recently uploaded (20)

PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Design Thinking basics for Engineers.pdf
CMR University
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
MRRS Strength and Durability of Concrete
CivilMythili
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 

Return oriented programming (ROP)

  • 1. Return Oriented Programming (ROP) INTRODUCTION, EXPLOITATIONS AND COUNTER-MEASURES Pipat Methavanitpong Doctoral Student [email protected] Kunieda-Isshiki Laboratory Department of Communications and Computer Engineering Tokyo Institute of Technology 11/4/2014
  • 2. What is ROP? A program composes of functions ◦ A lot of Calls and Returns Manipulating return addresses Go to other Address / Function / Program Can be done without injecting new code Example ◦ [Linux] Opening sh shell ◦ [Windows] Opening a calculator source: https://en.wikipedia.org/wiki/Return-oriented_programming
  • 3. Anatomy of x86 Stack Caller • Function Arguments Callee • Function Return Address • Frame Pointer • Exception Handler Frame • Locally Declared Variables and Buffers • Callee Save Registers Higher Addresses Grow Downward Lower Addresses source: http://msdn.microsoft.com/en-us/library/aa290051.aspx#vctchcompilersecuritychecksindepthanchor3
  • 4. Attack Approaches Stack Smashing Attack Return-to-libc Borrowed Code Chunks (Gadgets) 1. Stack Smashing 2. Return-to-libc 3. Borrowed Code Chunks
  • 5. Stack Smashing Overflow data in stack to its header or beyond Example • Size unchecked string input/copy • “HELLOBUG”x5 • Overwrite return address of DrawLine() • When DrawLine() returns, it goes to address of value “HELLOBUG” H E L L O B U G H E L L O B U G H E L L O B U G H E L L O B U G H E L L O B U G source: https://en.wikipedia.org/wiki/Return-oriented_programming
  • 6. Return-to-libc Common component of a program ◦ Target once, apply all Provide handful functions (it’s a library) ◦ system() can be used to execute shell commands Library’s code is marked as executable ◦ Recent defenses force a restriction on execution on address spaces ◦ Non executable (NX) bit feature is useless Steps ◦ Exploit a buffer overflow vulnerability to gain flow control ◦ Craft a targeted function’s arguments e.g. “/bin/bash” ◦ Return to the targeted function entry e.g. “system()”
  • 7. Borrowed Code Chunks (Gadgets) Registers tend to be reused Many chances to access memory Neutral instructions can serve evil No need to inject code Link these together YOU ARE HACKED! source: Black Hat 2008 – ROP Exploitation without Code Injection
  • 8. Defenses Stack Canary Stack smashing protection A layer between a buffer and control data Verify it to confirm stack overflow or not StackGuard / ProPolice / GS Security Cookie NX bit Mark memory as executable or not Can be hardware implementation or software (emulated) GCC FORTIFY_SOURCE Detect and prevent buffer overflow during compile-time Sometimes, buffer size is known ASCII Zone Fill memory with NULL character to prevent string abuse Address Space Layout Randomization (ASLR) Random placing program and library code Position Independent Executable (PIE) Allow the executable part of a program to be reallocated everywhere Section Rearrangement Mitigate damage of overflow E.g. data and bss section to the lowest  Overflow does not overwrite other important parts of program’s sections
  • 9. Further Resources Black Hat 2008 – ROP Exploitation without Code Injection SecurityTube – Buffer Overflow Primer Part 8 (Return To Libc Theory) Marcelo Carvalho – Buffer Overflow with a Practical Example RSA Conf 2010 – Practical Return-Oriented Programming Sebastian Krahmer – x86-64 buffer overflow exploits and the borrowed code chunks exploitation technique Florida State University – Offensive Computer Security Lectures Black Hat 2004 – A Comparison of Buffer Overflow Prevention Implementations and Weaknesses OpenRCE – Reversing Microsoft Visual C++ part I: Exception Handling Fedora – Security Features Red Hat Magazine – Limiting Buffer Overflow with ExecShield Microsoft Technet – On the Effectiveness of DEP and ASLR