Перейти к содержимому

Binary Exploitation: Finding and Exploiting call RSP with Ropper and GDB

Suit Up and Hack

0:00 / 0:00

Binary Exploitation: Finding and Exploiting call RSP with Ropper and GDB

1 208 просмотров · 3 года назад
Suit Up and Hack
1,34 тыс. подписчиков
1 208 просмотров · 3 года назад
This is your introduction to Return Oriented Programming — finding and using ROP gadgets with Ropper to control execution flow in a vulnerable binary. Part of the Bite-Sized Binary Exploitation series. In this episode we're working with a binary that has an executable stack, which lets us demonstrate the foundational ROP concept without additional complexity: using Ropper to enumerate gadgets in the binary, identifying the call RSP gadget at 0x401179 in the "nothing_important" function, and building a pwntools exploit that overflows the buffer (136-byte offset), overwrites the return address with our gadget address, and places shellcode directly after it on the stack. When the function returns, call RSP executes our shellcode and we pop a shell. This is the essential ROP entry point — understanding what gadgets are and how to chain execution before moving to full ROP chains against NX-protected binaries. 🧠 What You'll Learn: • What ROP gadgets are — instruction sequences ending in a RET or similar control-flow instruction that attackers use as "living off the land" primitives inside the binary • Running Ropper against a binary: ropper -f overflow_bin • Reading Ropper output — understanding gadget addresses, instruction sequences, and identifying high-value gadgets (call RSP, pop rdi, ret) • Using cyclic pattern generation in GDB/pwndbg to find the exact overflow offset (136 bytes) • Understanding call RSP — how it redirects execution from the stack pointer back into attacker-controlled shellcode • Building the pwntools exploit: b"A" * offset + p64(call_rsp_addr) + shellcode • Verifying shell access — whoami, ls, cd confirming code execution 💻 Exploit Structure: offset = 136 payload = b"A" * offset + p64(0x401179) + shellcode call RSP at 0x401179 → execute shellcode on stack 🔧 Tools Used: • Ropper — ROP gadget finder • GDB + pwndbg — debugging and pattern offset calculation • pwntools — exploit framework (pwn import, p64, process, interactive) • Python 3 — exploit scripting ⚙️ Concepts Covered: return oriented programming · ROP gadgets · buffer overflow · binary exploitation · ropper · pwntools · call RSP · exploit development · OSCP prep · CTF binary exploitation · GDB · pwndbg · shellcode · x64 exploit · living off the land binary ⏱️ Timestamps: 00:00 Introduction 01:16 Controlling Return Address 01:46 Living Off the Land 02:30 Using GDB to Set Breakpoint 03:23 Reviewing Stack Frame Set-up 04:41 Pattern Create 05:46 Identifying Offset 06:33 Noting Importance of call RSP 07:39 Shell Code Discussion 09:01 Using Ropper 10:53 Explaining the Overflow 13:57 Conclusion 🔗 Bite-Sized Binary Exploitation Series: → [Link previous episodes here] 🔗 Watch Next: → Process Hollowing: The Malware Technique EDRs Can't Detect → Local Shellcode Injection in C: VirtualAlloc → RtlMoveMemory → CreateThread → EDR Evasion: Direct Syscalls with ntdll — Replacing VirtualAlloc and CreateThread ⚠️ Disclaimer: This content is for educational purposes and security research only. All demonstrations are performed in a controlled, isolated lab environment. Understanding exploitation techniques builds better defenses. 🔔 Subscribe to Suit Up and Hack for binary exploitation, ROP chain development, malware development, and offensive security content. #ROP #ReturnOrientedProgramming #BufferOverflow #BinaryExploitation #Ropper #ExploitDevelopment #OSCP #Pwntools #CTF #CyberSecurity #EthicalHacking #ExploitDev #OffensiveSecurity #GDB #Shellcode #BinaryAnalysis #SecurityResearch #Pwn #OSCPPrep #RedTeam