⚓ Shipwreck Ex

Exploit Writing Essentials

Learn to create and analyze exploits in a controlled environment with real-world examples and interactive labs

Start Lab View Defenses

Common Exploit Types

Buffer Overflow Example


#include <stdio.h>
#include <string.h>

void vulnerable(char *input) {
    char buffer[32];
    strcpy(buffer, input);
    printf("Buffer: %s\n", buffer);
}

int main(int argc, char* argv[]) {
    vulnerable(argv[1]);
    return 0;
}
                
This vulnerable function overflows the stack buffer, potentially overwriting return address.

Mitigation Techniques

DEP / ASLR

Modern compilers and OSes use Data Execution Prevention and Address Space Layout Randomization for protection

Safe Functions

strncpy snprintf malloc

Compiler Flags

-fstack-protector-strong

Stack canary protection against buffer overflows

Bounds Checking

Use safe libraries like C++ std::vector or Rust String

Exploit Simulation

root@exploit-lab exploit ~ #
[Buffer Overflow Example] $ make exploit gcc -o vuln vuln.c gcc -o exploit exploit.c $ ./exploit vuln [+] Generating shellcode... [!] Overwrite length: 128 bytes [*] Spawning shell shell# whoami user

Exploit Lifecycle

Exploit Execution Stages
Recon
Network scanning, service identification
Exploit Development
Crafting custom payloads
Post-Exploitation
Maintaining control after breach