Binary Exploitation
Binary Exploitation is the process of finding vulnerabilities in the binary file.
Prerequisites
This post uses rizin
for dynamic analysis.
And pwntools
python package is useful for binary exploitation.
Investigation
Basic
Security Properties
First check the executable properties.
RELRO (stands for Relocation Read-Only)
Partial RELRO - We can read/write the global offset table.
Full RELRO - We can only read the global offset table. So we cannot overwrite GOT.
STACK CANARY
No canary found - It’s vulnerable to buffer overflow.
NX (stands for Non-eXecutable segments)
NX enabled - We cannot execute custom shellcode from the stack.
PIE (stands for Position Independent Executable)
No PIE - The binary always starts at same address.
Disabling ASLR (Address Space Layout Randomization)
ASLR is a security technique involved in preventing exploitation of memory corruption vulnerabilities.
0 - The address space is NOT randomized.
1 - The address space is randomized.
2 - The address space is randomized, and data segment as well.
To disable ASLR, run the following command.
Debugging
1. Start Debugger
2. Analyzing
3. List functions
4. Disassemble & Decompile Functions
If you want to decompile using “pdg” command as above, you need to install the “rizin-plugin-ghidra” so install it by running the following command.
Format String (Pointer)
Exploitation Examples
Last updated