SlideShare a Scribd company logo
Exploit Research
DEP Bypass with ROP
Chains
OPEN SECURITY
WWW.OPENSECURITY.IN

AJIN ABRAHAM
@AJINABRAHAM
Data Execution Prevention [DEP]


Hardware Data Execution Prevention utilizes the NX ("No eXecute page
protection“ of AMD) or XD (“eXecute Disable“ of Intel) bit on DEP compatible
CPU‟s, and will mark certain parts of the memory as non executable.



Normally the part in memory containing data (heap, stack and memory pool)
are marked as non executable.



So arbitrary code injection on these areas won‟t get executed.



Different DEP options in Windows OS
OptIn : Only a limited set of Windows system modules/binaries are protected
by DEP.
OptOut : All programs, processes, services on the Windows system are
protected, except for processes in the exception list
AlwaysOn : All programs, processes, services, etc on the Windows system are
protected. No exceptions
AlwaysOff : DEP is turned off.
@ajinabraham
How Will We Execute the Shellcode
When DEP Is Enabled?


We will craft a Windows API call that will disable DEP
for a specific memory region that we can control.



We have to use the instructions in the executable
region of the process and chain them in a particular
order to call the Windows API to disable DEP.



So once DEP is disabled, we can execute the
shellcode in the memory region that we control.



For that purpose we use ROP Chains.
@ajinabraham
Bypassing DEP with ROP Chains


A ROP Chain is a chain of instruction that contains a sequence of
gadgets.



A *Gadget is a group of instructions in the ROP Chain that ends with
a RET instruction.



A ROP NOP is a pointer to a RET.



With ROP Chains, we will jump from one part of the chain to another
part without executing a single instructions in the DEP protected
region.



In Effect what we are doing is, we use ROP Chains to setup the stack
with parameter for the Windows API call and finally call the API to
disable DEP.
* Gadget actually refers to higher-level macros/code snippets as per Hovav Shacham.

@ajinabraham
Exploitation when DEP is Enabled
Exploitation in 2 Stages
1st Stage
Disable DEP.

2nd Stage
Jump to Shellcode and Execute it.
@ajinabraham
Windows APIs for disabling DEP
API / OS

XP SP2 XP SP3 Vista SP0 Vista SP1 Windows 7 Windows 8 Windows 2003 SP1 Windows 2008

VirtualAlloc

yes

yes

yes

yes

yes

yes

yes

yes

HeapCreate

yes

yes

yes

yes

yes

yes

yes

yes

no (1)

yes

no (1)

yes

no (2)

no(2)

no (1)

yes

NtSetInformationProcess

yes

yes

yes

no (2)

no (2)

no(2)

yes

no (2)

VirtualProtect

yes

yes

yes

yes

yes

yes

yes

yes

WriteProcessMemory

yes

yes

yes

yes

yes

yes

yes

yes

SetProcessDEPPolicy

(1) Doesn‟t exist.
(2) Will fail because of default DEP Policy settings.
Source: https://www.corelan.be/index.php/2010/06/16/exploit-writing-tutorial-part-10-chaining-dep-with-rop-the-rubikstm-cube/

@ajinabraham
Universal APIs for disabling DEP
 Available

across all Windows Builds till date.

VirtualAlloc()
VirtualProtect()

@ajinabraham
Invoking a Function
Stack Layout
void add(int a, int b)
{
int x=25;
char y=„a‟;

printf(“Sum is %dn”,a+b);
}

ESP
EBP - x

add(2,3);
}

a

Local Variables
25

EBP
EBP

int main()
{

Low Memory

EBP + x

RETN
2
3
High Memory

Parameters
VirtualAlloc()
VirtualAlloc() is a Windows API present in kernel32.dll used to disable DEP.
 it will allocate new memory. One of the parameters to this function specifies the execution/access
level of the newly allocated memory, so the goal is to set that value to EXECUTE_READWRITE.
 VirtualAlloc() Win API Call Structure


LPVOID WINAPI VirtualAlloc
(
_In_opt_ LPVOID lpAddress,
_In_
SIZE_T dwSize,
_In_
DWORD flAllocationType,
_In_
DWORD flProtect

=>

A pointer to VirtualAlloc()

=>
=>
=>
=>

Return Address (Redirect Execution to ESP)
dwSize (0x1)
flAllocationType (0x1000) )
flProtect (0x40)

);
@ajinabraham
Stack Should Contain
Return Address

Return Address pointing to another ROP chain that will copy
the shellcode to the newly allocated memory and jump to it.

lpAddress

Starting address of the region where we want to allocate the
memory. You can provide a hardcoded value.

dwSize

Size of the region in bytes. We use rop chains to create and
write this value to the stack.

flAllocationType Set to 0×1000 (MEM_COMMIT). We use rop chains to create
and write this value to the stack.

flProtect

Set to 0×40 (EXECUTE_READWRITE). We use rop chains to
create and write this value to the stack.

@ajinabraham
VirtualProtect()


VirtualProtect() is another Windows API present in kernel32.dll used to disable DEP.



The VirtualProtect function changes the access protection of memory in the calling process.



VirtualProtect() Win API Call Structure

BOOL WINAPI VirtualProtect

=>

A pointer to VirtualProtect()

_In_ LPVOID lpAddress,

=>

Return Address (Redirect Execution to ESP)

_In_ SIZE_T dwSize,

=>

dwSize (0x201)

_In_ DWORD flNewProtect,

=>

flNewProtect (0x40)

_Out_ PDWORD lpflOldProtect

=>

A writable pointer

(

);
@ajinabraham
Stack Should Contain
Return Address

Return Address pointing to the shellcode on the stack. This value
is dynamically created using ROP chains.

lpAddress

Pointer to the base address of the region of pages whose access
protection attributes need to be changed. i.e. this will be the
base address of the shellcode. It is a dynamically created value.

dwSize

Size of the region in bytes. It is a dynamically created value using
ROP chains.

flNewProtect
lpflOldProtect

Set to 0×00000040 : PAGE_EXECUTE_READWRITE. This parameter
specifies the new protection flag. It is also dynamically created.
Pointer to variable that will receive the old protection
flag. It is a writable static address.

@ajinabraham
Ways to write a ROP Chain
Basically three ways.


1. We can load all the API parameters into the various
registers and use a PUSHAD instruction to push them to
the stack in the proper order.(Easiest)



2. we can directly write the parameters to the stack in
the proper order and then return to them (this will be
more difficult).



3. Create entire payload using ROP Chain (requires some
ninja skills).
@ajinabraham
Let‟s Exploit Something


We will use the VirtualAlloc() API call to disable DEP.



Our Strategy


Use ROP chains to put the parameters for VirtualAlloc() in the stack.



Call the function VirtualAlloc() which will disable DEP.



Jump to shellcode and execute it.

To achieve this we can put the required values in register and then use a
pushad instruction to put these values into the stack at once.

@ajinabraham
Exploit Code Structure
ESP

EIP

JUNK

RET

ROP Chain

NOPS

Exploit Shellcode

@ajinabraham
Thank You


References



https://www.corelan.be/index.php/2010/06/16/exploit-writingtutorial-part-10-chaining-dep-with-rop-the-rubikstm-cube/



http://www.fuzzysecurity.com/tutorials/expDev/7.html

@ajinabraham

More Related Content

PPTX
Exploit Research and Development Megaprimer: Unicode Based Exploit Development
PPTX
Exploit Research and Development Megaprimer: Win32 Egghunter
PPTX
Return Oriented Programming (ROP) Based Exploits - Part I
PPTX
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
PPTX
How Functions Work
PDF
ROP 輕鬆談
PDF
System Hacking Tutorial #3 - Buffer Overflow - Egg Hunting
PDF
NTUSTxTDOH - Pwn基礎 2015/12/27
Exploit Research and Development Megaprimer: Unicode Based Exploit Development
Exploit Research and Development Megaprimer: Win32 Egghunter
Return Oriented Programming (ROP) Based Exploits - Part I
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
How Functions Work
ROP 輕鬆談
System Hacking Tutorial #3 - Buffer Overflow - Egg Hunting
NTUSTxTDOH - Pwn基礎 2015/12/27

What's hot (20)

PPTX
Introduction to Debuggers
PPTX
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
PPT
PDF
How to deploy node to production
ODP
What's new in Perl 5.10?
PDF
Phpをいじり倒す10の方法
PDF
CyberLink LabelPrint 2.5 Exploitation Process
PPTX
An introduction to ROP
TXT
Exploit techniques - a quick review
PDF
TDOH 南區 WorkShop 2016 Reversing on Windows
TXT
Mona cheatsheet
PDF
Course lecture - An introduction to the Return Oriented Programming
PPT
Unit 5
ODP
Caching and tuning fun for high scalability @ FrOSCon 2011
PDF
台科逆向簡報
PDF
Php engine
PDF
PHP 7 OPCache extension review
KEY
Yapcasia2011 - Hello Embed Perl
PDF
System Hacking Tutorial #2 - Buffer Overflow - Overwrite EIP
PPTX
Operating Systems - A Primer
Introduction to Debuggers
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
How to deploy node to production
What's new in Perl 5.10?
Phpをいじり倒す10の方法
CyberLink LabelPrint 2.5 Exploitation Process
An introduction to ROP
Exploit techniques - a quick review
TDOH 南區 WorkShop 2016 Reversing on Windows
Mona cheatsheet
Course lecture - An introduction to the Return Oriented Programming
Unit 5
Caching and tuning fun for high scalability @ FrOSCon 2011
台科逆向簡報
Php engine
PHP 7 OPCache extension review
Yapcasia2011 - Hello Embed Perl
System Hacking Tutorial #2 - Buffer Overflow - Overwrite EIP
Operating Systems - A Primer
Ad

Viewers also liked (20)

PPTX
Hacking Samsung's Tizen: The OS of Everything - Hack In the Box 2015
PPTX
BSidesTO 2016 - Incident Tracking
PDF
Hacking Tizen: The OS of everything - Whitepaper
PDF
Abusing, Exploiting and Pwning with Firefox Add-ons
PPTX
H2O.ai - Road Ahead - keynote presentation by Sri Ambati
PDF
Top 10 Data Science Practitioner Pitfalls
PPTX
Abusing Exploiting and Pwning with Firefox Addons
PPTX
Abusing Google Apps and Data API: Google is My Command and Control Center
PPTX
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
PDF
Introduction to Data Science with H2O- Mountain View
PPTX
H2O World - Top 10 Data Science Pitfalls - Mark Landry
PPT
Diane Uk 08 Presentation Veris Products
PPTX
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
PPTX
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
PPTX
H2O Open New York - Keynote, Sri Ambati, CEO H2O.ai
PPTX
Data Science Driven Malware Detection
PDF
Verizon - A Case Study
PDF
Intro to Data Science for Non-Data Scientists
PDF
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
PDF
Machine Learning with H2O, Spark, and Python at Strata 2015
Hacking Samsung's Tizen: The OS of Everything - Hack In the Box 2015
BSidesTO 2016 - Incident Tracking
Hacking Tizen: The OS of everything - Whitepaper
Abusing, Exploiting and Pwning with Firefox Add-ons
H2O.ai - Road Ahead - keynote presentation by Sri Ambati
Top 10 Data Science Practitioner Pitfalls
Abusing Exploiting and Pwning with Firefox Addons
Abusing Google Apps and Data API: Google is My Command and Control Center
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
Introduction to Data Science with H2O- Mountain View
H2O World - Top 10 Data Science Pitfalls - Mark Landry
Diane Uk 08 Presentation Veris Products
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
H2O Open New York - Keynote, Sri Ambati, CEO H2O.ai
Data Science Driven Malware Detection
Verizon - A Case Study
Intro to Data Science for Non-Data Scientists
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Machine Learning with H2O, Spark, and Python at Strata 2015
Ad

Similar to Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains (20)

PPTX
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
PPT
Writing Metasploit Plugins
PDF
Reversing & malware analysis training part 4 assembly programming basics
PDF
Dive into exploit development
PDF
Buffer overflow tutorial
PDF
Shellcoding in linux
PDF
Heap overflows for humans – 101
KEY
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
ODP
Code Red Security
PDF
Exploitation Crash Course
PPT
A Life of breakpoint
DOCX
OOP-Chap2.docx
PPTX
Vxcon 2016
PPTX
[ASM]Lab6
PPTX
08 - Return Oriented Programming, the chosen one
PPTX
Advanced malwareanalysis training session2 botnet analysis part1
PPTX
Everybody be cool, this is a ROPpery
PPTX
Reversing malware analysis training part4 assembly programming basics
PPTX
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Writing Metasploit Plugins
Reversing & malware analysis training part 4 assembly programming basics
Dive into exploit development
Buffer overflow tutorial
Shellcoding in linux
Heap overflows for humans – 101
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Code Red Security
Exploitation Crash Course
A Life of breakpoint
OOP-Chap2.docx
Vxcon 2016
[ASM]Lab6
08 - Return Oriented Programming, the chosen one
Advanced malwareanalysis training session2 botnet analysis part1
Everybody be cool, this is a ROPpery
Reversing malware analysis training part4 assembly programming basics
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1

More from Ajin Abraham (13)

PDF
AppSec PNW: Android and iOS Application Security with MobSF
PDF
Injecting Security into Web apps at Runtime Whitepaper
PDF
Injecting Security into vulnerable web apps at Runtime
PPTX
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
PPTX
Exploit Research and Development Megaprimer: mona.py, Exploit Writer's Swiss ...
PPTX
Exploit Research and Development Megaprimer: Buffer overflow for beginners
PDF
OWASP Xenotix XSS Exploit Framework v3 : Nullcon Goa 2013
PPTX
Pwning with XSS: from alert() to reverse shell: Defcon Banglore 2013
PDF
Abusing, Exploiting and Pwning with Firefox Add-ons: OWASP Appsec 2013 Presen...
PDF
Xenotix XSS Exploit Framework: Clubhack 2012
PDF
Wi-Fi Security with Wi-Fi P+
PPTX
Phishing With Data URI
PPTX
Buffer overflow for Beginners
AppSec PNW: Android and iOS Application Security with MobSF
Injecting Security into Web apps at Runtime Whitepaper
Injecting Security into vulnerable web apps at Runtime
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Exploit Research and Development Megaprimer: mona.py, Exploit Writer's Swiss ...
Exploit Research and Development Megaprimer: Buffer overflow for beginners
OWASP Xenotix XSS Exploit Framework v3 : Nullcon Goa 2013
Pwning with XSS: from alert() to reverse shell: Defcon Banglore 2013
Abusing, Exploiting and Pwning with Firefox Add-ons: OWASP Appsec 2013 Presen...
Xenotix XSS Exploit Framework: Clubhack 2012
Wi-Fi Security with Wi-Fi P+
Phishing With Data URI
Buffer overflow for Beginners

Recently uploaded (20)

PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
RMMM.pdf make it easy to upload and study
PDF
Insiders guide to clinical Medicine.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Classroom Observation Tools for Teachers
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
master seminar digital applications in india
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Computing-Curriculum for Schools in Ghana
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
PPH.pptx obstetrics and gynecology in nursing
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
RMMM.pdf make it easy to upload and study
Insiders guide to clinical Medicine.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Classroom Observation Tools for Teachers
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Microbial diseases, their pathogenesis and prophylaxis
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
master seminar digital applications in india
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Renaissance Architecture: A Journey from Faith to Humanism
Abdominal Access Techniques with Prof. Dr. R K Mishra
Supply Chain Operations Speaking Notes -ICLT Program
Computing-Curriculum for Schools in Ghana
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPH.pptx obstetrics and gynecology in nursing

Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains

  • 1. Exploit Research DEP Bypass with ROP Chains OPEN SECURITY WWW.OPENSECURITY.IN AJIN ABRAHAM @AJINABRAHAM
  • 2. Data Execution Prevention [DEP]  Hardware Data Execution Prevention utilizes the NX ("No eXecute page protection“ of AMD) or XD (“eXecute Disable“ of Intel) bit on DEP compatible CPU‟s, and will mark certain parts of the memory as non executable.  Normally the part in memory containing data (heap, stack and memory pool) are marked as non executable.  So arbitrary code injection on these areas won‟t get executed.  Different DEP options in Windows OS OptIn : Only a limited set of Windows system modules/binaries are protected by DEP. OptOut : All programs, processes, services on the Windows system are protected, except for processes in the exception list AlwaysOn : All programs, processes, services, etc on the Windows system are protected. No exceptions AlwaysOff : DEP is turned off. @ajinabraham
  • 3. How Will We Execute the Shellcode When DEP Is Enabled?  We will craft a Windows API call that will disable DEP for a specific memory region that we can control.  We have to use the instructions in the executable region of the process and chain them in a particular order to call the Windows API to disable DEP.  So once DEP is disabled, we can execute the shellcode in the memory region that we control.  For that purpose we use ROP Chains. @ajinabraham
  • 4. Bypassing DEP with ROP Chains  A ROP Chain is a chain of instruction that contains a sequence of gadgets.  A *Gadget is a group of instructions in the ROP Chain that ends with a RET instruction.  A ROP NOP is a pointer to a RET.  With ROP Chains, we will jump from one part of the chain to another part without executing a single instructions in the DEP protected region.  In Effect what we are doing is, we use ROP Chains to setup the stack with parameter for the Windows API call and finally call the API to disable DEP. * Gadget actually refers to higher-level macros/code snippets as per Hovav Shacham. @ajinabraham
  • 5. Exploitation when DEP is Enabled Exploitation in 2 Stages 1st Stage Disable DEP. 2nd Stage Jump to Shellcode and Execute it. @ajinabraham
  • 6. Windows APIs for disabling DEP API / OS XP SP2 XP SP3 Vista SP0 Vista SP1 Windows 7 Windows 8 Windows 2003 SP1 Windows 2008 VirtualAlloc yes yes yes yes yes yes yes yes HeapCreate yes yes yes yes yes yes yes yes no (1) yes no (1) yes no (2) no(2) no (1) yes NtSetInformationProcess yes yes yes no (2) no (2) no(2) yes no (2) VirtualProtect yes yes yes yes yes yes yes yes WriteProcessMemory yes yes yes yes yes yes yes yes SetProcessDEPPolicy (1) Doesn‟t exist. (2) Will fail because of default DEP Policy settings. Source: https://www.corelan.be/index.php/2010/06/16/exploit-writing-tutorial-part-10-chaining-dep-with-rop-the-rubikstm-cube/ @ajinabraham
  • 7. Universal APIs for disabling DEP  Available across all Windows Builds till date. VirtualAlloc() VirtualProtect() @ajinabraham
  • 8. Invoking a Function Stack Layout void add(int a, int b) { int x=25; char y=„a‟; printf(“Sum is %dn”,a+b); } ESP EBP - x add(2,3); } a Local Variables 25 EBP EBP int main() { Low Memory EBP + x RETN 2 3 High Memory Parameters
  • 9. VirtualAlloc() VirtualAlloc() is a Windows API present in kernel32.dll used to disable DEP.  it will allocate new memory. One of the parameters to this function specifies the execution/access level of the newly allocated memory, so the goal is to set that value to EXECUTE_READWRITE.  VirtualAlloc() Win API Call Structure  LPVOID WINAPI VirtualAlloc ( _In_opt_ LPVOID lpAddress, _In_ SIZE_T dwSize, _In_ DWORD flAllocationType, _In_ DWORD flProtect => A pointer to VirtualAlloc() => => => => Return Address (Redirect Execution to ESP) dwSize (0x1) flAllocationType (0x1000) ) flProtect (0x40) ); @ajinabraham
  • 10. Stack Should Contain Return Address Return Address pointing to another ROP chain that will copy the shellcode to the newly allocated memory and jump to it. lpAddress Starting address of the region where we want to allocate the memory. You can provide a hardcoded value. dwSize Size of the region in bytes. We use rop chains to create and write this value to the stack. flAllocationType Set to 0×1000 (MEM_COMMIT). We use rop chains to create and write this value to the stack. flProtect Set to 0×40 (EXECUTE_READWRITE). We use rop chains to create and write this value to the stack. @ajinabraham
  • 11. VirtualProtect()  VirtualProtect() is another Windows API present in kernel32.dll used to disable DEP.  The VirtualProtect function changes the access protection of memory in the calling process.  VirtualProtect() Win API Call Structure BOOL WINAPI VirtualProtect => A pointer to VirtualProtect() _In_ LPVOID lpAddress, => Return Address (Redirect Execution to ESP) _In_ SIZE_T dwSize, => dwSize (0x201) _In_ DWORD flNewProtect, => flNewProtect (0x40) _Out_ PDWORD lpflOldProtect => A writable pointer ( ); @ajinabraham
  • 12. Stack Should Contain Return Address Return Address pointing to the shellcode on the stack. This value is dynamically created using ROP chains. lpAddress Pointer to the base address of the region of pages whose access protection attributes need to be changed. i.e. this will be the base address of the shellcode. It is a dynamically created value. dwSize Size of the region in bytes. It is a dynamically created value using ROP chains. flNewProtect lpflOldProtect Set to 0×00000040 : PAGE_EXECUTE_READWRITE. This parameter specifies the new protection flag. It is also dynamically created. Pointer to variable that will receive the old protection flag. It is a writable static address. @ajinabraham
  • 13. Ways to write a ROP Chain Basically three ways.  1. We can load all the API parameters into the various registers and use a PUSHAD instruction to push them to the stack in the proper order.(Easiest)  2. we can directly write the parameters to the stack in the proper order and then return to them (this will be more difficult).  3. Create entire payload using ROP Chain (requires some ninja skills). @ajinabraham
  • 14. Let‟s Exploit Something  We will use the VirtualAlloc() API call to disable DEP.  Our Strategy  Use ROP chains to put the parameters for VirtualAlloc() in the stack.  Call the function VirtualAlloc() which will disable DEP.  Jump to shellcode and execute it. To achieve this we can put the required values in register and then use a pushad instruction to put these values into the stack at once. @ajinabraham
  • 15. Exploit Code Structure ESP EIP JUNK RET ROP Chain NOPS Exploit Shellcode @ajinabraham