Bypassing NX (DEP)
Summary
NX (NoExecute) is also called DEP (Data Execution Prevention) prevents execution of shellcode on the stack. This prevents the standard buffer overflow method since the shellcode on the memory doesnt get executed. This would result in a SIGSEGV error.
To bypass this limitation, you use pointers of things already defined and pass arguments to them, since that is still allowed.
Ret2Libc
LibC is a library on linux by default toi make low level functions work. This is imported in a lot of binaries to function.
When the EIP is overwritten as part of the exploit, we can point it to functions in LibC (assuming its imported) and pass args to them to execute code.
Checking LibC
Bash
GDB
Listing functions in the systems LibC
Calling a Function
When calling a function in LibC, we need to know how to prepare the stack. We will need to have the function address, the return address (such as exit()) and then the arguments for the function.
Calculating Addresses
Getting Args
The function called will need arguments and they cant be passed along as a normal string. If calling a function such as system() in LibC, then the arg could be a location in memory already including /bin/sh or something similar.
Execution
Python can either be used to launch it directly, or print it all out to term and then pipe. To use with the double cat method, pipe out to a file (exploit.txt), then use.
Last updated