ret2win
Most common challenge
1. Theory
❯ file ret2win
ret2win: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=516803899a2c7d12ad238bfafa4de3895d8c7adf, for GNU/Linux 3.2.0, not stripped#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Win function
void win() {
char buf[64];
FILE *f = fopen("flag.txt", "r");
fgets(buf, sizeof(buf), f);
fclose(f);
printf("Ret2win successfull here is your flag: %s\n", buf);
}
// Vuln function
void vuln() {
char buffer[20];
printf("What is your name\n> ");
scanf("%s", buffer);
printf("Hey there, nice to meet ya %s\n", buffer);
}
// Main
int main() {
vuln();
return 0;
}

2. Finding offset
GDB Plugins3. Finding address of win()
win()
4. Exploit
Last updated