Return To Libc
Return To Libc
Outline
● Non-executable Stack countermeasure
● How to defeat the countermeasure
● Tasks involved in the attack
● Function Prologue and Epilogue
● Launching attack
Non-executable Stack
Running shellcode in C program
Calls shellcode
Non-executable Stack
● With executable stack
● To find location in the stack to place “/bin/sh” address (argument for system())
Task A : To Find system()’s Address.
● Debug the vulnerable program using gdb
● Using p (print) command, print address of system() and exit().
Task B : To Find “/bin/sh” String Address
Export an environment variable called “MYSHELL” with value
“/bin/sh”.
2
1 Function prologue
2 Function epilogue
8(%ebp) ⇒ %ebp + 8
How to Find system()’s Argument Address?
Change ebp and esp
Modified Use of
vul_func() system()
Return system()’s
epilogue prologue
Address argument
ebp + 12
ebp + 8
ebp + 4
Launch the attack
● Execute the exploit code and then the vulnerable code
Summary
● The Non-executable-stack mechanism can be bypassed