Dive into ROP - a quick introduction to Return Oriented Programming

Saumil Shah
Saumil ShahCEO and Founder, Net Square um Net Square
net-square © Saumil Shah
Dive into ROP
Return Oriented Programming
Introduction and Core Concepts
SAUMIL SHAH
www.net-square.com
net-square © Saumil Shah
Introduction
This tutorial shall introduce you
to Return Oriented Programming
commonly known as "ROP".
We will cover the core concepts
behind ROP and a small example
demonstrating them.
net-square © Saumil Shah
# who am i
Saumil Shah
CEO Net-square.
• Hacker, Speaker, Trainer,
Author.
• M.S. Computer Science
Purdue University.
• @therealsaumil
• LinkedIn: saumilshah
net-square © Saumil Shah
Background
• Here are some good refresher tutorials
before you dive into ROP:
• Operating Systems – A Primer
– understand how processes run,
• How Functions Work
– stack, frames, calls, returns, etc.,
• Introduction to Debuggers
– to try the discussed code example yourself.
net-square © Saumil Shah
Background
• And you need to know how stack
overflows work.
net-square © Saumil Shah
Agenda
Exploit Mitigation via DEP
Executable vs. Non-executable
regions
Ret2LibC
Return Oriented Programming
net-square © Saumil Shah
DEP: Data Execution Prevention
• Execute Code, not Data.
• Data areas marked non-executable.
– Stack marked non-executable.
– Heap marked non-executable.
• Hardware enforced (NX).
• You can load your shellcode in the stack
or the heap...
• ...but you can't jump to it.
net-square © Saumil Shah
Exploitation – the good old way
• Memory corruption exploits work in two
stages:
• Stage 1 – leverage memory corruption to
control process execution.
• Stage 2 – direct process execution to
injected shellcode.
net-square © Saumil Shah
Exploitation – the good old way
EIP CONTROL
Memory
Corruption
Jump to
Shellcode
Pre EIP Post EIP
net-square © Saumil Shah
Example: Stack Overflow
Set EIP to land
in shellcode in
the stack
Overwrite
Return Address
in frame
Execute
shellcode from
stack
Pre EIP Post EIP
• Exceed bounds of local variable.
• Overwrite saved return address in
the frame.
• Control EIP when vulnerable
function returns.
• Shellcode is injected on the stack
as part of the payload.
• EIP can be set directly to a stack
address, or...
• ...perform a "jump through
register" technique.
net-square © Saumil Shah
Stack Overflow with DEP
Set EIP to land
in shellcode in
the stack
Overwrite
Return Address
in frame
Execute
shellcode from
stack
Pre EIP Post EIP
• Entire stack region is marked as
"non-executable".
• EIP can land in the stack...
• ...but no execution.
• CPU will refuse to fetch-and-
execute.
net-square © Saumil Shah
EIP control
• EIP movement
restricted.
– Can't jump to Heap.
– Can't jump to Stack.
• Can only land in
executable regions.
Program Image
Heap
Stack
DLL
DLL
DLL
net-square © Saumil Shah
The Solution?
• We borrow bits and pieces of code...
• ...that already exists in executable
regions of the process!
• We then create a SEQUENCE of operations
to be carried out.
net-square © Saumil Shah
Orchestrating Code Execution
• Assume a series of cards where each card
indicates an operation to be performed.
• The code for that operation is present in
the executable regions of the process
memory.
– binary or shared library.
• A card shall contain the address of the
code it wants to execute.
net-square © Saumil Shah
Orchestrating Code Execution
• If we can create a chain of cards, each
corresponding to a basic operation...
• ...we can perform complex operations.
• Example: Assume a complex operation
broken down into a sequence of basic
operations A, D, C, B, D, E.
net-square © Saumil Shah
binobj1 (read,exec)
binobj3 (read,exec)
binobj2 (read,exec)
A
E
H
D
F
B
C
G
Execute A, take next card
Execute D, take next card
Execute C, take next card
Execute B, take next card
Execute D, take next card
Execute E, take next card
net-square © Saumil Shah
Orchestrating Code Execution
• Complex code can therefore be
transformed into a sequence of primitive
operations...
• ...which are already present in the
process' executable regions.
• These operations are called GADGETS.
net-square © Saumil Shah
ROP – The Origins
• The first idea of executing EXISTING code
was discussed in 1997.
• Solar Designer's Ret2LibC technique.
• Devised to defeat non executable stack.
net-square © Saumil Shah
Ret2LibC
• Make EIP "return to an existing function"
after a stack overflow.
• If we can't execute shellcode...
• ...we will "return" to system("/bin/sh")
net-square © Saumil Shah
Ret2LibC - how does it work?
• Create a fake frame on the stack.
• After an overflowed function returns...
• ...set the EIP return address to the new
function.
• Append the fake frame.
• New function executes.
– parameters consumed from the fake frame.
• system("/bin/sh")
net-square © Saumil Shah
Ret2LibC – how does it work?
• The following function is vulnerable to a
stack overflow:
void func1(char *s)
{
char buffer[80];
strcpy(buffer, s);
:
:
}
net-square © Saumil Shah
Stack frame for func1()
buffer
return address
s
• If s points to a string greater than 80
characters, it will result in a stack
overflow.
• The return address will be overwritten
with an attacker controlled value.
• When func1() returns, EIP can be set to
an arbitrary address, resulting in
process execution hijacking.
net-square © Saumil Shah
Jump to shellcode - regular way
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
addr of shellcode on stack
shellcode
• Traditional way of implementing a
"Post-EIP" jump to shellcode.
• Other technique involve a "trampoline
jump" or "Jump Through Register".
• Either way, EIP lands in stack memory,
occupied by shellcode.
net-square © Saumil Shah
Jump to shellcode – with DEP
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
addr of shellcode on stack
shellcode
• The traditional way does NOT work if
stack is marked as non-executable.
• EIP cannot be made to land in stack
memory.
• EIP MUST stay within the binary or
shared libraries (valid executable
memory regions)
net-square © Saumil Shah
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
address of system() in libc
return from system()
The Ret2LibC way
• func1() is made to "return" to
system() by overwriting its return
address with the address of
system() in libc.
• A fake calling frame for system()
is appended after the return
address for func1()
• Return address for system() and
parameter (pointer to "/bin/sh")
are provided in the fake calling
frame.
address of string "/bin/sh"
"/bin
/sh0"
net-square © Saumil Shah
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
address of system() in libc
return from system()
The Ret2LibC way
address of string "/bin/sh"
"/bin
/sh0"
libc
system()
RET
• Before func1() returns, ESP points
to the overwritten return
address...
• ...which now contains address of
system() in libc.
ESP
net-square © Saumil Shah
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
address of system() in libc
return from system()
The Ret2LibC way
address of string "/bin/sh"
"/bin
/sh0"
libc
system()
RET
• After func1() returns, the saved
return address is popped off the
stack and EIP returns to system().
ESP
net-square © Saumil Shah
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
address of system() in libc
return from system()
The Ret2LibC way
address of string "/bin/sh"
"/bin
/sh0"
libc
system()
RET
• system() will execute "/bin/sh"
passed to it as a parameter.
• When system() returns, EIP can be
made to return to an attacker
controlled address.
ESP
EIP
net-square © Saumil Shah
Ret2LibC - Conclusions
• It is possible to invoke an arbitrary
function simply by placing a fake frame in
stack memory.
• It is also possible to retain EIP control
after the arbitrary function returns.
• Ret2LibC is the basis for Return Oriented
Programming.
net-square © Saumil Shah
Return Oriented Programming
• Series of returns to functions.
• Chained frames.
• Transform EIP based primitives into stubs
(gadgets) that can be "returned into".
• We govern arbitrary code execution by
controlling frames on the stack.
• ESP is the new EIP!
net-square © Saumil Shah
Introduction to Return
Oriented Programming
Basic Concepts
net-square © Saumil Shah
Concepts
• Functions revisited
• Function calls and returns
• Stack overflows revisited
• Creating stack frames
• Chaining frames
• ESP control
net-square © Saumil Shah
Functions Revisited
• How is a function called?
• What does the stack frame look like?
net-square © Saumil Shah
Calling a function
• Add two ints x, y.
• add(3,4)
• What does the calling
frame look like?
void add(int x, int y)
{
int sum;
sum = x + y;
printf("%dn", sum);
}
int main()
{
add(3, 4);
}
net-square © Saumil Shah
Stack frame for add(3,4)
frame for add()
return address from add()
3
4
call add
net-square © Saumil Shah
Return from add(3,4)
• add() is about to return.
• RET after epilogue of add().
• Where does ESP point to?
– immediately before the RET
• What does the stack look like?
net-square © Saumil Shah
Before the RET
return address from add()
3
4
ESP
net-square © Saumil Shah
Another function
• Stack overflow in
func1.
• Can we call add(5, 6)
after returning from
func1?
void func1(char *s)
{
char buffer[128];
strcpy(buffer, s);
}
int main()
{
func1(argv[1]);
}
net-square © Saumil Shah
Stack frame for func1()
buffer
return address from func1
s
net-square © Saumil Shah
strcpy(buffer, s)
buffer
return address from func1
s
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAA
AAAA
AAAA
AAAA
net-square © Saumil Shah
Before the RET
buffer
return address from func1
s
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAA
AAAA
AAAA
AAAA
ESP
net-square © Saumil Shah
After the RET
buffer
return address from func1
s
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAA
AAAA
AAAA
AAAA
EIP = 0x41414141
ESP
net-square © Saumil Shah
Return to add()
• Insert a fake frame in the buffer.
• Make func1() return to:
add(01010101, 02020202)
• What does the stack frame look like?
net-square © Saumil Shah
strcpy(buffer, s)
buffer
return address from func1
s
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
address of add()
return from add()
01010101
02020202
net-square © Saumil Shah
Before func1() returns
buffer
return address from func1
s
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
address of add()
return from add()
01010101
02020202
ESP
net-square © Saumil Shah
Return to add()
buffer
return address from func1
s
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
address of add()
return from add()
01010101
02020202
ESP
EIP = add()
net-square © Saumil Shah
Return to add()
• By carefully creating a frame...
• ...we can make the program "return to
our function".
• We control the parameters.
• We also control where to jump to after
our function returns.
net-square © Saumil Shah
rop_victim.c
int main(int argc, char *argv[])
{
add(3, 4);
func1(argv[1]);
}
void func1(char *s)
{
char buffer[128];
strcpy(buffer, s);
}
void print_hello(void)
{
printf("Hello Worldn");
}
void add(int x, int y)
{
int sum;
sum = x + y;
printf("%d + %d = %dn", x, y, sum);
}
stack overflow lurks here!
net-square © Saumil Shah
Building rop_victim
• Create a file called "rop_victim.c" with
the contents as shown in the previous
slide.
• Compile "rop_victim.c" as follows
• And run it normally:
$ gcc rop_victim.c –o rop_victim
$ ./rop_victim HELLOWORLD
net-square © Saumil Shah
Making func1() return to add()
• We shall exploit the stack overflow in
func1() and make it return to add().
• For this, we must inspect the calling
frame for add()...
• ...and eventually place a fake frame for
add() on the stack when overflowing
func1().
net-square © Saumil Shah
Inspecting add()'s calling frame
• Open "rop_victim" in gdb, and set a
breakpoint just before the call to add() in
main().
• We want to inspect the stack memory
before call add()...
• ...and immediately after call add() as
well.
$ gdb rop_victim
net-square © Saumil Shah
gdb'ing add
• Set a breakpoint before call add()
(gdb) disassemble main
0x08048454 <+0>: push %ebp
0x08048455 <+1>: mov %esp,%ebp
0x08048457 <+3>: and $0xfffffff0,%esp
0x0804845a <+6>: sub $0x10,%esp
0x0804845d <+9>: movl $0x4,0x4(%esp)
0x08048465 <+17>: movl $0x3,(%esp)
0x0804846c <+24>: call 0x80484bd <add>
0x08048471 <+29>: cmpl $0x1,0x8(%ebp)
0x08048475 <+33>: jle 0x8048487 <main+51>
0x08048477 <+35>: mov 0xc(%ebp),%eax
(gdb) break *0x0804846c
net-square © Saumil Shah
Before add
• Run rop_victim and single step into add()
• We are inside add() now.
• Look at the stack frame.
(gdb) run HELLOWORLD
Starting program: /home/krafty/rop_intro/rop_victim HELLOWORLD
Breakpoint 1, 0x0804846c in main ()
(gdb) stepi
0x080484bd in add ()
(gdb) where
#0 0x080484bd in add ()
#1 0x08048471 in main ()
net-square © Saumil Shah
Stack frame before add(3, 4)
• Dump the stack:
(gdb) x/10x $esp
0xbffff41c: 0x08048471 0x00000003 0x00000004 0x0804851b
0xbffff42c: 0x00292ff4 0x08048510 0x00000000 0xbffff4b8
0x08048471
3
4
return address
from add()
param1
param2
net-square © Saumil Shah
Overflowing func1()
• Overflow func1 and...
...return to add(01010101, 02020202)
• Create a fake frame.
• Overwrite stack memory.
return from func1
param1
param2
return from add
0x080484bd
0x01010101
0x02020202
0x42424242
net-square © Saumil Shah
Creating a fake frame
• Create the buffer overflow payload as
follows:
• Write a program to create such a buffer
and use it as an input to rop_victim.c
080484bdAAAAAA.........AAAAAA 42424242 01010101 02020202
distance
to EIP
address
of add
return
from add
param1 param2
net-square © Saumil Shah
ESP
• Where will ESP be after returning from
add?
• Verify
080484bdAAAAAA...140...AAAAAA 42424242 01010101 02020202
(gdb) x/64x $esp
0xbffff2e4: 0x01010101 0x02020202 0x00292f00 0x08048510
0xbffff2f4: 0x00000000 0xbffff378 0x00153bd6 0x00000002
ESP
net-square © Saumil Shah
Chaining functions
• After add(01010101, 02020202), we want
to run add(03030303, 04040404).
• How should we set up the frames?
• First, study the frame after add() returns.
net-square © Saumil Shah
After add() returns
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
address of add
42424242
01010101
02020202
ESP
EIP = 42424242
net-square © Saumil Shah
Where does the new frame go?
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
address of add
42424242
01010101
02020202
address of add
??
03030303
04040404
net-square © Saumil Shah
Where does the new frame go?
• We get only ONE chance at strcpy.
• How do we preserver params 01010101
and 02020202?
• We can only APPEND the second frame
below our first frame.
• We have to unwind the first frame before
returning to the second frame.
• Answer: Return to Epilogue!
net-square © Saumil Shah
Chaining the frames
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
address of add
address of POP/POP/RET
01010101
02020202
address of add
42424242
03030303
04040404
add(01010101, 02020202)
add(03030303, 04040404)
net-square © Saumil Shah
Keeping ESP in control
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
address of add
address of POP/POP/RET
01010101
02020202
address of add
42424242
03030303
04040404
ESP
Return from func1
net-square © Saumil Shah
Keeping ESP in control
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
address of add
address of POP/POP/RET
01010101
02020202
address of add
42424242
03030303
04040404
ESP
Return from func1
Return to add()
net-square © Saumil Shah
Keeping ESP in control
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
address of add
address of POP/POP/RET
01010101
02020202
address of add
42424242
03030303
04040404
ESP
Return from func1
Return to add()
Return to POP/POP/RET
net-square © Saumil Shah
Keeping ESP in control
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
address of add
address of POP/POP/RET
01010101
02020202
address of add
42424242
03030303
04040404
ESP
Return from func1
Return to add()
Return to POP/POP/RET
POP
POP
net-square © Saumil Shah
Keeping ESP in control
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
address of add
address of POP/POP/RET
01010101
02020202
address of add
42424242
03030303
04040404
Return from func1
Return to add()
Return to POP/POP/RET
POP
POP
ESP
RET - Return to add()
net-square © Saumil Shah
Keeping ESP in control
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
address of add
address of POP/POP/RET
01010101
02020202
address of add
42424242
03030303
04040404
Return from func1
Return to add()
Return to POP/POP/RET
POP
POP
ESP
RET - Return to add()
Finally EIP = 0x42424242
net-square © Saumil Shah
Chained Frames
• Create another buffer overflow payload:
080484bdAAAAAA...140...AAAAAA 08048422 01010101 02020202
distance
to EIP
address
of add
POP/POP
/RET
param1 param2
080484bd 42424242 03030303 04040404
address
of add
return
from add
param1 param2 Use msfelfscan to
find the address of
POP/POP/RET from
rop_victim binary.
net-square © Saumil Shah
It's all about ESP!
• ESP is the new EIP.
• ROP involves keeping the ESP moving
through the frames on the stack.
• Frames can be chained by returning to
epilogues of functions.
– to appropriately unwind the parameters
pushed on the stack.
• We must never lose sight of RET
net-square © Saumil Shah
Code Execution – The ROP Way
• Piece together snippets of code
• Gadgets – primitive operations, to be
searched for within the process binary or
shared libraries.
• Every gadget must end with a RET.
• We find gadgets in function epilogues.
net-square © Saumil Shah
binobj1
binobj3
binobj2
A
E
D
f1()
f6()
f4()
f2()
f3()
B
C
f7()
f5()
f8()
RET
RET
RET
RET
RET
RET
RET
RET
Execute A, take next card
Execute D, take next card
Execute C, take next card
Execute B, take next card
Execute D, take next card
Execute E, take next card
net-square © Saumil Shah
To Conclude
• ROP requires a different way of thinking
about code execution.
• Code is not executed as a series of
opcodes and operands.
• Instead, code is executed via a series of
chained frames on the stack.
• Rather, a series of chained GADGETS on
the stack.
net-square © Saumil Shah
To Conclude
• The objective of this tutorial was to
introduce you to the concept of "Return
Oriented Programming".
• There's a lot more to be talked about
when it comes to ROP.
• Exploits on modern operating systems
which implement DEP necessarily require
ROP to execute shellcode.
net-square © Saumil Shah
To Conclude
• ROP requires a lot of hands-on practice.
• There are sophisticated tools available
for assembling your own ROP chains.
– skyrack
– RoPeMe
– ropshell.com, etc.
net-square © Saumil Shah
All-New! EXPLOITLAB 2013
saumil@net-square.com
@therealsaumil | blog.exploitlab.net
1 von 76

Recomendados

How Functions Work von
How Functions WorkHow Functions Work
How Functions WorkSaumil Shah
27.1K views52 Folien
Operating Systems - A Primer von
Operating Systems - A PrimerOperating Systems - A Primer
Operating Systems - A PrimerSaumil Shah
23.9K views68 Folien
Part II: LLVM Intermediate Representation von
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationWei-Ren Chen
869 views39 Folien
OpenSCAP Overview(security scanning for docker image and container) von
OpenSCAP Overview(security scanning for docker image and container)OpenSCAP Overview(security scanning for docker image and container)
OpenSCAP Overview(security scanning for docker image and container)Jooho Lee
2.9K views13 Folien
BPF Hardware Offload Deep Dive von
BPF Hardware Offload Deep DiveBPF Hardware Offload Deep Dive
BPF Hardware Offload Deep DiveNetronome
714 views28 Folien

Más contenido relacionado

Was ist angesagt?

HTTP Request Smuggling via higher HTTP versions von
HTTP Request Smuggling via higher HTTP versionsHTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsneexemil
9.5K views41 Folien
Something About Dynamic Linking von
Something About Dynamic LinkingSomething About Dynamic Linking
Something About Dynamic LinkingWang Hsiangkai
2.2K views69 Folien
Sockets and Socket-Buffer von
Sockets and Socket-BufferSockets and Socket-Buffer
Sockets and Socket-BufferSourav Punoriyar
5.2K views28 Folien
Triggers and Stored Procedures von
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored ProceduresTharindu Weerasinghe
878 views23 Folien
Http request smuggling von
Http request smugglingHttp request smuggling
Http request smugglingn|u - The Open Security Community
376 views16 Folien
FISL XIV - The ELF File Format and the Linux Loader von
FISL XIV - The ELF File Format and the Linux LoaderFISL XIV - The ELF File Format and the Linux Loader
FISL XIV - The ELF File Format and the Linux LoaderJohn Tortugo
2.8K views38 Folien

Was ist angesagt?(20)

HTTP Request Smuggling via higher HTTP versions von neexemil
HTTP Request Smuggling via higher HTTP versionsHTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versions
neexemil9.5K views
Something About Dynamic Linking von Wang Hsiangkai
Something About Dynamic LinkingSomething About Dynamic Linking
Something About Dynamic Linking
Wang Hsiangkai2.2K views
FISL XIV - The ELF File Format and the Linux Loader von John Tortugo
FISL XIV - The ELF File Format and the Linux LoaderFISL XIV - The ELF File Format and the Linux Loader
FISL XIV - The ELF File Format and the Linux Loader
John Tortugo2.8K views
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...) von Jaime Sánchez
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)
Jaime Sánchez22.4K views
ELF(executable and linkable format) von Seungha Son
ELF(executable and linkable format)ELF(executable and linkable format)
ELF(executable and linkable format)
Seungha Son151 views
Pentesting Using Burp Suite von jasonhaddix
Pentesting Using Burp SuitePentesting Using Burp Suite
Pentesting Using Burp Suite
jasonhaddix22.8K views
Linux Basic Commands von Hanan Nmr
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
Hanan Nmr3.5K views
virtual hosting and configuration von HAMZA AHMED
virtual hosting and configurationvirtual hosting and configuration
virtual hosting and configuration
HAMZA AHMED678 views
Php and MySQL von Tiji Thomas
Php and MySQLPhp and MySQL
Php and MySQL
Tiji Thomas29.5K views
JavaScript Static Security Analysis made easy with JSPrime von Nishant Das Patnaik
JavaScript Static Security Analysis made easy with JSPrimeJavaScript Static Security Analysis made easy with JSPrime
JavaScript Static Security Analysis made easy with JSPrime
Nishant Das Patnaik10.6K views
The TCP/IP Stack in the Linux Kernel von Divye Kapoor
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
Divye Kapoor52.3K views

Destacado

Introduction to Debuggers von
Introduction to DebuggersIntroduction to Debuggers
Introduction to DebuggersSaumil Shah
26.6K views156 Folien
Advance ROP Attacks von
Advance ROP AttacksAdvance ROP Attacks
Advance ROP Attacksn|u - The Open Security Community
9.5K views32 Folien
Return oriented programming (ROP) von
Return oriented programming (ROP)Return oriented programming (ROP)
Return oriented programming (ROP)Pipat Methavanitpong
1.8K views9 Folien
Hack.LU - The Infosec Crossroads von
Hack.LU - The Infosec CrossroadsHack.LU - The Infosec Crossroads
Hack.LU - The Infosec CrossroadsSaumil Shah
2.8K views55 Folien
An introduction to ROP von
An introduction to ROPAn introduction to ROP
An introduction to ROPSaumil Shah
5.7K views55 Folien
Deadly pixels - NSC 2013 von
Deadly pixels - NSC 2013Deadly pixels - NSC 2013
Deadly pixels - NSC 2013Saumil Shah
6.5K views27 Folien

Destacado(20)

Introduction to Debuggers von Saumil Shah
Introduction to DebuggersIntroduction to Debuggers
Introduction to Debuggers
Saumil Shah26.6K views
Hack.LU - The Infosec Crossroads von Saumil Shah
Hack.LU - The Infosec CrossroadsHack.LU - The Infosec Crossroads
Hack.LU - The Infosec Crossroads
Saumil Shah2.8K views
An introduction to ROP von Saumil Shah
An introduction to ROPAn introduction to ROP
An introduction to ROP
Saumil Shah5.7K views
Deadly pixels - NSC 2013 von Saumil Shah
Deadly pixels - NSC 2013Deadly pixels - NSC 2013
Deadly pixels - NSC 2013
Saumil Shah6.5K views
Exploit Delivery von Saumil Shah
Exploit DeliveryExploit Delivery
Exploit Delivery
Saumil Shah9.7K views
Stegosploit - Hacking With Pictures HITB2015AMS von Saumil Shah
Stegosploit - Hacking With Pictures HITB2015AMSStegosploit - Hacking With Pictures HITB2015AMS
Stegosploit - Hacking With Pictures HITB2015AMS
Saumil Shah18.7K views
Metasploit for Penetration Testing: Beginner Class von Georgia Weidman
Metasploit for Penetration Testing: Beginner ClassMetasploit for Penetration Testing: Beginner Class
Metasploit for Penetration Testing: Beginner Class
Georgia Weidman31.9K views
Benefits Of Computer Software von poonam.rwalia
Benefits Of Computer SoftwareBenefits Of Computer Software
Benefits Of Computer Software
poonam.rwalia25.4K views
presentation on bonds...its types,method and bond terminologies. von sabaAkhan47
presentation on bonds...its types,method and bond terminologies.presentation on bonds...its types,method and bond terminologies.
presentation on bonds...its types,method and bond terminologies.
sabaAkhan4717.9K views
Reporting pearson correlation in apa von Ken Plummer
Reporting pearson correlation in apaReporting pearson correlation in apa
Reporting pearson correlation in apa
Ken Plummer160.4K views
Acoustical materials von shahzeb163
Acoustical materialsAcoustical materials
Acoustical materials
shahzeb163179.1K views
Blood components and preparation von rajkumarsrihari
Blood components and preparationBlood components and preparation
Blood components and preparation
rajkumarsrihari59.6K views
Customer Relationship Management Module Project Report von sachinkumar Bharadva
Customer Relationship Management Module Project ReportCustomer Relationship Management Module Project Report
Customer Relationship Management Module Project Report
sachinkumar Bharadva92.8K views
Cell suspension culture von Anushi Jain
Cell suspension cultureCell suspension culture
Cell suspension culture
Anushi Jain99K views
Internal Control and Compliance. von Mohammad Robiul
Internal Control and Compliance.Internal Control and Compliance.
Internal Control and Compliance.
Mohammad Robiul8.3K views

Similar a Dive into ROP - a quick introduction to Return Oriented Programming

XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora... von
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...The Linux Foundation
1.5K views41 Folien
13 superscalar von
13 superscalar13 superscalar
13 superscalarHammad Farooq
1.3K views38 Folien
13_Superscalar.ppt von
13_Superscalar.ppt13_Superscalar.ppt
13_Superscalar.pptLavleshkumarBais
1 view38 Folien
127 Ch 2: Stack overflows on Linux von
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on LinuxSam Bowne
596 views43 Folien
Week1 Electronic System-level ESL Design and SystemC Begin von
Week1 Electronic System-level ESL Design and SystemC BeginWeek1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC Begin敬倫 林
2.7K views63 Folien
Cassandra Day SV 2014: Spark, Shark, and Apache Cassandra von
Cassandra Day SV 2014: Spark, Shark, and Apache CassandraCassandra Day SV 2014: Spark, Shark, and Apache Cassandra
Cassandra Day SV 2014: Spark, Shark, and Apache CassandraDataStax Academy
7K views46 Folien

Similar a Dive into ROP - a quick introduction to Return Oriented Programming(20)

XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora... von The Linux Foundation
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
127 Ch 2: Stack overflows on Linux von Sam Bowne
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
Sam Bowne596 views
Week1 Electronic System-level ESL Design and SystemC Begin von 敬倫 林
Week1 Electronic System-level ESL Design and SystemC BeginWeek1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC Begin
敬倫 林2.7K views
Cassandra Day SV 2014: Spark, Shark, and Apache Cassandra von DataStax Academy
Cassandra Day SV 2014: Spark, Shark, and Apache CassandraCassandra Day SV 2014: Spark, Shark, and Apache Cassandra
Cassandra Day SV 2014: Spark, Shark, and Apache Cassandra
DataStax Academy7K views
ESIL - Universal IL (Intermediate Language) for Radare2 von Anton Kochkov
ESIL - Universal IL (Intermediate Language) for Radare2ESIL - Universal IL (Intermediate Language) for Radare2
ESIL - Universal IL (Intermediate Language) for Radare2
Anton Kochkov2.4K views
Java Jit. Compilation and optimization by Andrey Kovalenko von Valeriia Maliarenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey Kovalenko
Valeriia Maliarenko1.2K views
08 - Return Oriented Programming, the chosen one von Alexandre Moneger
08 - Return Oriented Programming, the chosen one08 - Return Oriented Programming, the chosen one
08 - Return Oriented Programming, the chosen one
Alexandre Moneger965 views
Low Level Exploits von hughpearse
Low Level ExploitsLow Level Exploits
Low Level Exploits
hughpearse1.5K views
Advanced technic for OS upgrading in 3 minutes von Hiroshi SHIBATA
Advanced technic for OS upgrading in 3 minutesAdvanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutes
Hiroshi SHIBATA42K views
Scala Frustrations von takezoe
Scala FrustrationsScala Frustrations
Scala Frustrations
takezoe3.7K views
R4ML: An R Based Scalable Machine Learning Framework von Alok Singh
R4ML: An R Based Scalable Machine Learning FrameworkR4ML: An R Based Scalable Machine Learning Framework
R4ML: An R Based Scalable Machine Learning Framework
Alok Singh54 views
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine von Vladimir Ivanov
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
Vladimir Ivanov9.7K views
Ratpack Web Framework von Daniel Woods
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
Daniel Woods5.1K views

Más de Saumil Shah

The Hand That Strikes, Also Blocks von
The Hand That Strikes, Also BlocksThe Hand That Strikes, Also Blocks
The Hand That Strikes, Also BlocksSaumil Shah
98 views67 Folien
Debugging with EMUX - RIngzer0 BACK2WORKSHOPS von
Debugging with EMUX - RIngzer0 BACK2WORKSHOPSDebugging with EMUX - RIngzer0 BACK2WORKSHOPS
Debugging with EMUX - RIngzer0 BACK2WORKSHOPSSaumil Shah
91 views23 Folien
Unveiling EMUX - ARM and MIPS IoT Emulation Framework von
Unveiling EMUX - ARM and MIPS IoT Emulation FrameworkUnveiling EMUX - ARM and MIPS IoT Emulation Framework
Unveiling EMUX - ARM and MIPS IoT Emulation FrameworkSaumil Shah
265 views20 Folien
Announcing ARMX Docker - DC11332 von
Announcing ARMX Docker - DC11332Announcing ARMX Docker - DC11332
Announcing ARMX Docker - DC11332Saumil Shah
6.8K views29 Folien
Precise Presentations von
Precise PresentationsPrecise Presentations
Precise PresentationsSaumil Shah
557 views18 Folien
Effective Webinars: Presentation Skills for a Virtual Audience von
Effective Webinars: Presentation Skills for a Virtual AudienceEffective Webinars: Presentation Skills for a Virtual Audience
Effective Webinars: Presentation Skills for a Virtual AudienceSaumil Shah
1.4K views28 Folien

Más de Saumil Shah(20)

The Hand That Strikes, Also Blocks von Saumil Shah
The Hand That Strikes, Also BlocksThe Hand That Strikes, Also Blocks
The Hand That Strikes, Also Blocks
Saumil Shah98 views
Debugging with EMUX - RIngzer0 BACK2WORKSHOPS von Saumil Shah
Debugging with EMUX - RIngzer0 BACK2WORKSHOPSDebugging with EMUX - RIngzer0 BACK2WORKSHOPS
Debugging with EMUX - RIngzer0 BACK2WORKSHOPS
Saumil Shah91 views
Unveiling EMUX - ARM and MIPS IoT Emulation Framework von Saumil Shah
Unveiling EMUX - ARM and MIPS IoT Emulation FrameworkUnveiling EMUX - ARM and MIPS IoT Emulation Framework
Unveiling EMUX - ARM and MIPS IoT Emulation Framework
Saumil Shah265 views
Announcing ARMX Docker - DC11332 von Saumil Shah
Announcing ARMX Docker - DC11332Announcing ARMX Docker - DC11332
Announcing ARMX Docker - DC11332
Saumil Shah6.8K views
Precise Presentations von Saumil Shah
Precise PresentationsPrecise Presentations
Precise Presentations
Saumil Shah557 views
Effective Webinars: Presentation Skills for a Virtual Audience von Saumil Shah
Effective Webinars: Presentation Skills for a Virtual AudienceEffective Webinars: Presentation Skills for a Virtual Audience
Effective Webinars: Presentation Skills for a Virtual Audience
Saumil Shah1.4K views
INSIDE ARM-X Cansecwest 2020 von Saumil Shah
INSIDE ARM-X Cansecwest 2020INSIDE ARM-X Cansecwest 2020
INSIDE ARM-X Cansecwest 2020
Saumil Shah425 views
Cyberspace And Security - India's Decade Ahead von Saumil Shah
Cyberspace And Security - India's Decade AheadCyberspace And Security - India's Decade Ahead
Cyberspace And Security - India's Decade Ahead
Saumil Shah1K views
Cybersecurity And Sovereignty - A Look At Society's Transformation In Cyberspace von Saumil Shah
Cybersecurity And Sovereignty - A Look At Society's Transformation In CyberspaceCybersecurity And Sovereignty - A Look At Society's Transformation In Cyberspace
Cybersecurity And Sovereignty - A Look At Society's Transformation In Cyberspace
Saumil Shah503 views
NSConclave2020 The Decade Behind And The Decade Ahead von Saumil Shah
NSConclave2020 The Decade Behind And The Decade AheadNSConclave2020 The Decade Behind And The Decade Ahead
NSConclave2020 The Decade Behind And The Decade Ahead
Saumil Shah155 views
Cybersecurity In India - The Decade Ahead von Saumil Shah
Cybersecurity In India - The Decade AheadCybersecurity In India - The Decade Ahead
Cybersecurity In India - The Decade Ahead
Saumil Shah361 views
INSIDE ARM-X - Countermeasure 2019 von Saumil Shah
INSIDE ARM-X - Countermeasure 2019INSIDE ARM-X - Countermeasure 2019
INSIDE ARM-X - Countermeasure 2019
Saumil Shah13.9K views
Introducing ARM-X von Saumil Shah
Introducing ARM-XIntroducing ARM-X
Introducing ARM-X
Saumil Shah18.3K views
The Road To Defendable Systems - Emirates NBD von Saumil Shah
The Road To Defendable Systems - Emirates NBDThe Road To Defendable Systems - Emirates NBD
The Road To Defendable Systems - Emirates NBD
Saumil Shah630 views
The CISO's Dilemma 44CON 2019 von Saumil Shah
The CISO's Dilemma 44CON 2019The CISO's Dilemma 44CON 2019
The CISO's Dilemma 44CON 2019
Saumil Shah1.1K views
The CISO's Dilemma HITBGSEC2019 von Saumil Shah
The CISO's Dilemma HITBGSEC2019The CISO's Dilemma HITBGSEC2019
The CISO's Dilemma HITBGSEC2019
Saumil Shah903 views
Schrödinger's ARM Assembly von Saumil Shah
Schrödinger's ARM AssemblySchrödinger's ARM Assembly
Schrödinger's ARM Assembly
Saumil Shah659 views
ARM Polyglot Shellcode - HITB2019AMS von Saumil Shah
ARM Polyglot Shellcode - HITB2019AMSARM Polyglot Shellcode - HITB2019AMS
ARM Polyglot Shellcode - HITB2019AMS
Saumil Shah1.9K views
What Makes a Compelling Photograph von Saumil Shah
What Makes a Compelling PhotographWhat Makes a Compelling Photograph
What Makes a Compelling Photograph
Saumil Shah341 views
Make ARM Shellcode Great Again - HITB2018PEK von Saumil Shah
Make ARM Shellcode Great Again - HITB2018PEKMake ARM Shellcode Great Again - HITB2018PEK
Make ARM Shellcode Great Again - HITB2018PEK
Saumil Shah373 views

Último

Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue von
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueShapeBlue
96 views20 Folien
HTTP headers that make your website go faster - devs.gent November 2023 von
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023Thijs Feryn
28 views151 Folien
20231123_Camunda Meetup Vienna.pdf von
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
46 views73 Folien
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... von
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...ShapeBlue
63 views13 Folien
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT von
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITShapeBlue
91 views8 Folien
NTGapps NTG LowCode Platform von
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform Mustafa Kuğu
141 views30 Folien

Último(20)

Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue von ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue96 views
HTTP headers that make your website go faster - devs.gent November 2023 von Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn28 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... von ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue63 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT von ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue91 views
NTGapps NTG LowCode Platform von Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu141 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows von Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software344 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... von ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue77 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online von ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue102 views
State of the Union - Rohit Yadav - Apache CloudStack von ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue145 views
Data Integrity for Banking and Financial Services von Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely56 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 von Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi141 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... von James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson133 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue von ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue85 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... von ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue57 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T von ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue56 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue von ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue46 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... von ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue83 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... von TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc77 views

Dive into ROP - a quick introduction to Return Oriented Programming

  • 1. net-square © Saumil Shah Dive into ROP Return Oriented Programming Introduction and Core Concepts SAUMIL SHAH www.net-square.com
  • 2. net-square © Saumil Shah Introduction This tutorial shall introduce you to Return Oriented Programming commonly known as "ROP". We will cover the core concepts behind ROP and a small example demonstrating them.
  • 3. net-square © Saumil Shah # who am i Saumil Shah CEO Net-square. • Hacker, Speaker, Trainer, Author. • M.S. Computer Science Purdue University. • @therealsaumil • LinkedIn: saumilshah
  • 4. net-square © Saumil Shah Background • Here are some good refresher tutorials before you dive into ROP: • Operating Systems – A Primer – understand how processes run, • How Functions Work – stack, frames, calls, returns, etc., • Introduction to Debuggers – to try the discussed code example yourself.
  • 5. net-square © Saumil Shah Background • And you need to know how stack overflows work.
  • 6. net-square © Saumil Shah Agenda Exploit Mitigation via DEP Executable vs. Non-executable regions Ret2LibC Return Oriented Programming
  • 7. net-square © Saumil Shah DEP: Data Execution Prevention • Execute Code, not Data. • Data areas marked non-executable. – Stack marked non-executable. – Heap marked non-executable. • Hardware enforced (NX). • You can load your shellcode in the stack or the heap... • ...but you can't jump to it.
  • 8. net-square © Saumil Shah Exploitation – the good old way • Memory corruption exploits work in two stages: • Stage 1 – leverage memory corruption to control process execution. • Stage 2 – direct process execution to injected shellcode.
  • 9. net-square © Saumil Shah Exploitation – the good old way EIP CONTROL Memory Corruption Jump to Shellcode Pre EIP Post EIP
  • 10. net-square © Saumil Shah Example: Stack Overflow Set EIP to land in shellcode in the stack Overwrite Return Address in frame Execute shellcode from stack Pre EIP Post EIP • Exceed bounds of local variable. • Overwrite saved return address in the frame. • Control EIP when vulnerable function returns. • Shellcode is injected on the stack as part of the payload. • EIP can be set directly to a stack address, or... • ...perform a "jump through register" technique.
  • 11. net-square © Saumil Shah Stack Overflow with DEP Set EIP to land in shellcode in the stack Overwrite Return Address in frame Execute shellcode from stack Pre EIP Post EIP • Entire stack region is marked as "non-executable". • EIP can land in the stack... • ...but no execution. • CPU will refuse to fetch-and- execute.
  • 12. net-square © Saumil Shah EIP control • EIP movement restricted. – Can't jump to Heap. – Can't jump to Stack. • Can only land in executable regions. Program Image Heap Stack DLL DLL DLL
  • 13. net-square © Saumil Shah The Solution? • We borrow bits and pieces of code... • ...that already exists in executable regions of the process! • We then create a SEQUENCE of operations to be carried out.
  • 14. net-square © Saumil Shah Orchestrating Code Execution • Assume a series of cards where each card indicates an operation to be performed. • The code for that operation is present in the executable regions of the process memory. – binary or shared library. • A card shall contain the address of the code it wants to execute.
  • 15. net-square © Saumil Shah Orchestrating Code Execution • If we can create a chain of cards, each corresponding to a basic operation... • ...we can perform complex operations. • Example: Assume a complex operation broken down into a sequence of basic operations A, D, C, B, D, E.
  • 16. net-square © Saumil Shah binobj1 (read,exec) binobj3 (read,exec) binobj2 (read,exec) A E H D F B C G Execute A, take next card Execute D, take next card Execute C, take next card Execute B, take next card Execute D, take next card Execute E, take next card
  • 17. net-square © Saumil Shah Orchestrating Code Execution • Complex code can therefore be transformed into a sequence of primitive operations... • ...which are already present in the process' executable regions. • These operations are called GADGETS.
  • 18. net-square © Saumil Shah ROP – The Origins • The first idea of executing EXISTING code was discussed in 1997. • Solar Designer's Ret2LibC technique. • Devised to defeat non executable stack.
  • 19. net-square © Saumil Shah Ret2LibC • Make EIP "return to an existing function" after a stack overflow. • If we can't execute shellcode... • ...we will "return" to system("/bin/sh")
  • 20. net-square © Saumil Shah Ret2LibC - how does it work? • Create a fake frame on the stack. • After an overflowed function returns... • ...set the EIP return address to the new function. • Append the fake frame. • New function executes. – parameters consumed from the fake frame. • system("/bin/sh")
  • 21. net-square © Saumil Shah Ret2LibC – how does it work? • The following function is vulnerable to a stack overflow: void func1(char *s) { char buffer[80]; strcpy(buffer, s); : : }
  • 22. net-square © Saumil Shah Stack frame for func1() buffer return address s • If s points to a string greater than 80 characters, it will result in a stack overflow. • The return address will be overwritten with an attacker controlled value. • When func1() returns, EIP can be set to an arbitrary address, resulting in process execution hijacking.
  • 23. net-square © Saumil Shah Jump to shellcode - regular way AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA addr of shellcode on stack shellcode • Traditional way of implementing a "Post-EIP" jump to shellcode. • Other technique involve a "trampoline jump" or "Jump Through Register". • Either way, EIP lands in stack memory, occupied by shellcode.
  • 24. net-square © Saumil Shah Jump to shellcode – with DEP AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA addr of shellcode on stack shellcode • The traditional way does NOT work if stack is marked as non-executable. • EIP cannot be made to land in stack memory. • EIP MUST stay within the binary or shared libraries (valid executable memory regions)
  • 25. net-square © Saumil Shah AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA address of system() in libc return from system() The Ret2LibC way • func1() is made to "return" to system() by overwriting its return address with the address of system() in libc. • A fake calling frame for system() is appended after the return address for func1() • Return address for system() and parameter (pointer to "/bin/sh") are provided in the fake calling frame. address of string "/bin/sh" "/bin /sh0"
  • 26. net-square © Saumil Shah AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA address of system() in libc return from system() The Ret2LibC way address of string "/bin/sh" "/bin /sh0" libc system() RET • Before func1() returns, ESP points to the overwritten return address... • ...which now contains address of system() in libc. ESP
  • 27. net-square © Saumil Shah AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA address of system() in libc return from system() The Ret2LibC way address of string "/bin/sh" "/bin /sh0" libc system() RET • After func1() returns, the saved return address is popped off the stack and EIP returns to system(). ESP
  • 28. net-square © Saumil Shah AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA address of system() in libc return from system() The Ret2LibC way address of string "/bin/sh" "/bin /sh0" libc system() RET • system() will execute "/bin/sh" passed to it as a parameter. • When system() returns, EIP can be made to return to an attacker controlled address. ESP EIP
  • 29. net-square © Saumil Shah Ret2LibC - Conclusions • It is possible to invoke an arbitrary function simply by placing a fake frame in stack memory. • It is also possible to retain EIP control after the arbitrary function returns. • Ret2LibC is the basis for Return Oriented Programming.
  • 30. net-square © Saumil Shah Return Oriented Programming • Series of returns to functions. • Chained frames. • Transform EIP based primitives into stubs (gadgets) that can be "returned into". • We govern arbitrary code execution by controlling frames on the stack. • ESP is the new EIP!
  • 31. net-square © Saumil Shah Introduction to Return Oriented Programming Basic Concepts
  • 32. net-square © Saumil Shah Concepts • Functions revisited • Function calls and returns • Stack overflows revisited • Creating stack frames • Chaining frames • ESP control
  • 33. net-square © Saumil Shah Functions Revisited • How is a function called? • What does the stack frame look like?
  • 34. net-square © Saumil Shah Calling a function • Add two ints x, y. • add(3,4) • What does the calling frame look like? void add(int x, int y) { int sum; sum = x + y; printf("%dn", sum); } int main() { add(3, 4); }
  • 35. net-square © Saumil Shah Stack frame for add(3,4) frame for add() return address from add() 3 4 call add
  • 36. net-square © Saumil Shah Return from add(3,4) • add() is about to return. • RET after epilogue of add(). • Where does ESP point to? – immediately before the RET • What does the stack look like?
  • 37. net-square © Saumil Shah Before the RET return address from add() 3 4 ESP
  • 38. net-square © Saumil Shah Another function • Stack overflow in func1. • Can we call add(5, 6) after returning from func1? void func1(char *s) { char buffer[128]; strcpy(buffer, s); } int main() { func1(argv[1]); }
  • 39. net-square © Saumil Shah Stack frame for func1() buffer return address from func1 s
  • 40. net-square © Saumil Shah strcpy(buffer, s) buffer return address from func1 s AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAA AAAA AAAA AAAA
  • 41. net-square © Saumil Shah Before the RET buffer return address from func1 s AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAA AAAA AAAA AAAA ESP
  • 42. net-square © Saumil Shah After the RET buffer return address from func1 s AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAA AAAA AAAA AAAA EIP = 0x41414141 ESP
  • 43. net-square © Saumil Shah Return to add() • Insert a fake frame in the buffer. • Make func1() return to: add(01010101, 02020202) • What does the stack frame look like?
  • 44. net-square © Saumil Shah strcpy(buffer, s) buffer return address from func1 s AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA address of add() return from add() 01010101 02020202
  • 45. net-square © Saumil Shah Before func1() returns buffer return address from func1 s AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA address of add() return from add() 01010101 02020202 ESP
  • 46. net-square © Saumil Shah Return to add() buffer return address from func1 s AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAA address of add() return from add() 01010101 02020202 ESP EIP = add()
  • 47. net-square © Saumil Shah Return to add() • By carefully creating a frame... • ...we can make the program "return to our function". • We control the parameters. • We also control where to jump to after our function returns.
  • 48. net-square © Saumil Shah rop_victim.c int main(int argc, char *argv[]) { add(3, 4); func1(argv[1]); } void func1(char *s) { char buffer[128]; strcpy(buffer, s); } void print_hello(void) { printf("Hello Worldn"); } void add(int x, int y) { int sum; sum = x + y; printf("%d + %d = %dn", x, y, sum); } stack overflow lurks here!
  • 49. net-square © Saumil Shah Building rop_victim • Create a file called "rop_victim.c" with the contents as shown in the previous slide. • Compile "rop_victim.c" as follows • And run it normally: $ gcc rop_victim.c –o rop_victim $ ./rop_victim HELLOWORLD
  • 50. net-square © Saumil Shah Making func1() return to add() • We shall exploit the stack overflow in func1() and make it return to add(). • For this, we must inspect the calling frame for add()... • ...and eventually place a fake frame for add() on the stack when overflowing func1().
  • 51. net-square © Saumil Shah Inspecting add()'s calling frame • Open "rop_victim" in gdb, and set a breakpoint just before the call to add() in main(). • We want to inspect the stack memory before call add()... • ...and immediately after call add() as well. $ gdb rop_victim
  • 52. net-square © Saumil Shah gdb'ing add • Set a breakpoint before call add() (gdb) disassemble main 0x08048454 <+0>: push %ebp 0x08048455 <+1>: mov %esp,%ebp 0x08048457 <+3>: and $0xfffffff0,%esp 0x0804845a <+6>: sub $0x10,%esp 0x0804845d <+9>: movl $0x4,0x4(%esp) 0x08048465 <+17>: movl $0x3,(%esp) 0x0804846c <+24>: call 0x80484bd <add> 0x08048471 <+29>: cmpl $0x1,0x8(%ebp) 0x08048475 <+33>: jle 0x8048487 <main+51> 0x08048477 <+35>: mov 0xc(%ebp),%eax (gdb) break *0x0804846c
  • 53. net-square © Saumil Shah Before add • Run rop_victim and single step into add() • We are inside add() now. • Look at the stack frame. (gdb) run HELLOWORLD Starting program: /home/krafty/rop_intro/rop_victim HELLOWORLD Breakpoint 1, 0x0804846c in main () (gdb) stepi 0x080484bd in add () (gdb) where #0 0x080484bd in add () #1 0x08048471 in main ()
  • 54. net-square © Saumil Shah Stack frame before add(3, 4) • Dump the stack: (gdb) x/10x $esp 0xbffff41c: 0x08048471 0x00000003 0x00000004 0x0804851b 0xbffff42c: 0x00292ff4 0x08048510 0x00000000 0xbffff4b8 0x08048471 3 4 return address from add() param1 param2
  • 55. net-square © Saumil Shah Overflowing func1() • Overflow func1 and... ...return to add(01010101, 02020202) • Create a fake frame. • Overwrite stack memory. return from func1 param1 param2 return from add 0x080484bd 0x01010101 0x02020202 0x42424242
  • 56. net-square © Saumil Shah Creating a fake frame • Create the buffer overflow payload as follows: • Write a program to create such a buffer and use it as an input to rop_victim.c 080484bdAAAAAA.........AAAAAA 42424242 01010101 02020202 distance to EIP address of add return from add param1 param2
  • 57. net-square © Saumil Shah ESP • Where will ESP be after returning from add? • Verify 080484bdAAAAAA...140...AAAAAA 42424242 01010101 02020202 (gdb) x/64x $esp 0xbffff2e4: 0x01010101 0x02020202 0x00292f00 0x08048510 0xbffff2f4: 0x00000000 0xbffff378 0x00153bd6 0x00000002 ESP
  • 58. net-square © Saumil Shah Chaining functions • After add(01010101, 02020202), we want to run add(03030303, 04040404). • How should we set up the frames? • First, study the frame after add() returns.
  • 59. net-square © Saumil Shah After add() returns AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA address of add 42424242 01010101 02020202 ESP EIP = 42424242
  • 60. net-square © Saumil Shah Where does the new frame go? AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAA address of add 42424242 01010101 02020202 address of add ?? 03030303 04040404
  • 61. net-square © Saumil Shah Where does the new frame go? • We get only ONE chance at strcpy. • How do we preserver params 01010101 and 02020202? • We can only APPEND the second frame below our first frame. • We have to unwind the first frame before returning to the second frame. • Answer: Return to Epilogue!
  • 62. net-square © Saumil Shah Chaining the frames AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA address of add address of POP/POP/RET 01010101 02020202 address of add 42424242 03030303 04040404 add(01010101, 02020202) add(03030303, 04040404)
  • 63. net-square © Saumil Shah Keeping ESP in control AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA address of add address of POP/POP/RET 01010101 02020202 address of add 42424242 03030303 04040404 ESP Return from func1
  • 64. net-square © Saumil Shah Keeping ESP in control AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA address of add address of POP/POP/RET 01010101 02020202 address of add 42424242 03030303 04040404 ESP Return from func1 Return to add()
  • 65. net-square © Saumil Shah Keeping ESP in control AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA address of add address of POP/POP/RET 01010101 02020202 address of add 42424242 03030303 04040404 ESP Return from func1 Return to add() Return to POP/POP/RET
  • 66. net-square © Saumil Shah Keeping ESP in control AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA address of add address of POP/POP/RET 01010101 02020202 address of add 42424242 03030303 04040404 ESP Return from func1 Return to add() Return to POP/POP/RET POP POP
  • 67. net-square © Saumil Shah Keeping ESP in control AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA address of add address of POP/POP/RET 01010101 02020202 address of add 42424242 03030303 04040404 Return from func1 Return to add() Return to POP/POP/RET POP POP ESP RET - Return to add()
  • 68. net-square © Saumil Shah Keeping ESP in control AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA address of add address of POP/POP/RET 01010101 02020202 address of add 42424242 03030303 04040404 Return from func1 Return to add() Return to POP/POP/RET POP POP ESP RET - Return to add() Finally EIP = 0x42424242
  • 69. net-square © Saumil Shah Chained Frames • Create another buffer overflow payload: 080484bdAAAAAA...140...AAAAAA 08048422 01010101 02020202 distance to EIP address of add POP/POP /RET param1 param2 080484bd 42424242 03030303 04040404 address of add return from add param1 param2 Use msfelfscan to find the address of POP/POP/RET from rop_victim binary.
  • 70. net-square © Saumil Shah It's all about ESP! • ESP is the new EIP. • ROP involves keeping the ESP moving through the frames on the stack. • Frames can be chained by returning to epilogues of functions. – to appropriately unwind the parameters pushed on the stack. • We must never lose sight of RET
  • 71. net-square © Saumil Shah Code Execution – The ROP Way • Piece together snippets of code • Gadgets – primitive operations, to be searched for within the process binary or shared libraries. • Every gadget must end with a RET. • We find gadgets in function epilogues.
  • 72. net-square © Saumil Shah binobj1 binobj3 binobj2 A E D f1() f6() f4() f2() f3() B C f7() f5() f8() RET RET RET RET RET RET RET RET Execute A, take next card Execute D, take next card Execute C, take next card Execute B, take next card Execute D, take next card Execute E, take next card
  • 73. net-square © Saumil Shah To Conclude • ROP requires a different way of thinking about code execution. • Code is not executed as a series of opcodes and operands. • Instead, code is executed via a series of chained frames on the stack. • Rather, a series of chained GADGETS on the stack.
  • 74. net-square © Saumil Shah To Conclude • The objective of this tutorial was to introduce you to the concept of "Return Oriented Programming". • There's a lot more to be talked about when it comes to ROP. • Exploits on modern operating systems which implement DEP necessarily require ROP to execute shellcode.
  • 75. net-square © Saumil Shah To Conclude • ROP requires a lot of hands-on practice. • There are sophisticated tools available for assembling your own ROP chains. – skyrack – RoPeMe – ropshell.com, etc.
  • 76. net-square © Saumil Shah All-New! EXPLOITLAB 2013 saumil@net-square.com @therealsaumil | blog.exploitlab.net