A collection of binary exploitation challenges focusing on various vulnerabilities and exploitation techniques. Each level contains a SUID binary that must be exploited to escalate privileges and retrieve the password for the next level.
Each level directory contains:
- source.c: Reconstructed C code mimicking the binary's behavior
- readme.md: Complete documentation including vulnerability analysis, exploitation steps, and prevention methods
- Ressources/: Binary files and helper scripts for testing
- flag: Password for the next level
- Additional helper scripts (Python exploit scripts, C utilities, etc.)
- Connect to the VM:
ssh level00@localhost -p 4242 - Analyze the binary: Use tools like GDB, objdump, or Ghidra
- Develop exploit: Test locally using files in Ressources/
- Execute exploit: Gain access and retrieve the password from
/home/users/levelXX/.pass
- Vulnerability: Hardcoded Credentials (CWE-798)
- Technique: Reverse engineering to extract hardcoded password
- Key Learning: Never embed credentials in binaries
- Vulnerability: Stack-Based Buffer Overflow (CWE-121)
- Technique: Overwrite return address with shellcode
- Key Learning: Proper bounds checking with buffer operations
- Vulnerability: Improper Output Neutralization for Logs (CWE-134)
- Technique: Format string exploitation to leak password from stack
- Key Learning: Never pass user input directly to printf; use explicit format strings
- Vulnerability: Insufficient Entropy (CWE-331)
- Technique: Reverse-engineer XOR cipher to calculate correct input
- Key Learning: Custom cryptography is weak; use proven cryptographic libraries
- Vulnerability: Improper Restriction of Operations within Bounds (CWE-119)
- Technique: Buffer overflow with custom shellcode bypassing syscall filtering
- Key Learning: gets() is inherently unsafe; ptrace monitoring isn't foolproof protection
- Vulnerability: Improper Neutralization of Format String (CWE-134)
- Technique: GOT overwrite using %n format specifier to redirect execution
- Key Learning: Format strings enable arbitrary memory writes; RELRO prevents GOT overwrites
- Vulnerability: Predictable Algorithm (CWE-330)
- Technique: Bypass ptrace anti-debugging and reverse-engineer hash algorithm
- Key Learning: Anti-debugging provides no real security; never implement custom cryptography
- Vulnerability: Integer Overflow to Buffer Overflow (CWE-190)
- Technique: Integer overflow to bypass array bounds checks and overwrite return address
- Key Learning: Always validate array indices; check for integer overflow before operations
- Vulnerability: Path Traversal (CWE-22)
- Technique: Exploit relative paths to access files outside intended directory
- Key Learning: Use absolute paths in SUID binaries; validate and canonicalize file paths
- Vulnerability: Off-by-One Error (CWE-193)
- Technique: Off-by-one overwrites length field, enabling buffer overflow to hidden function
- Key Learning: Loop conditions matter (< vs <=); off-by-one errors are subtle but dangerous
- Buffer Overflows (Level 1, 4, 7, 9): Stack-based overflows from unbounded input
- Format Strings (Level 2, 5): Arbitrary read/write through printf vulnerabilities
- Off-by-One Errors (Level 9): Subtle boundary mistakes with major impact
- Return Address Overwrite: Redirect execution flow to shellcode or functions
- GOT Overwrites: Hijack function pointers in Global Offset Table
- Shellcode Injection: Custom assembly payloads in stack or environment
- Integer Overflow: Bypass bounds checks through arithmetic wraparound
- Anti-Debugging (Level 3, 4, 6): Ptrace detection and syscall filtering
- Input Validation (Level 3, 6, 7): Logic flaws in security checks
- Custom Cryptography (Level 3, 6): Weak algorithms vulnerable to analysis
- GDB Analysis: Disassembly, breakpoints, register inspection
- Stack Layout: Understanding function prologue/epilogue, local variables
- Assembly Patterns: Recognizing loops, conditionals, function calls
- Algorithm Recovery: Reconstructing logic from machine code
Based on vulnerabilities exploited in this project:
- Input Validation: Never trust user input; validate length, format, and content
- Safe Functions: Use bounds-checked alternatives (fgets vs gets, snprintf vs sprintf)
- Format Strings: Always use explicit format specifiers:
printf("%s", input) - Memory Protection: Enable stack canaries, NX, ASLR, RELRO, PIE
- Cryptography: Use proven libraries (libsodium, OpenSSL) not custom algorithms
- Path Handling: Use absolute paths and canonicalization in privileged programs
- Integer Safety: Check for overflow before arithmetic operations
- Compiler Flags: Enable warnings and FORTIFY_SOURCE protections
- CWE - Common Weakness Enumeration
- OWASP Top 10
- Exploit Education
- Shell-Storm Shellcode Database
- GDB Tutorial
- Linux x86 Program Start Up
- SSH Port: 4242
- Users: level00-level09
- Password Location:
/home/users/levelXX/.pass
This project covers 10 levels of progressively challenging binary exploitation scenarios, from simple hardcoded passwords to complex off-by-one vulnerabilities with PIE bypasses. Each level includes detailed documentation, source code reconstruction, and exploit scripts for educational purposes.