Buffer Overflow
Par Israël Hallé
Adapté par Olivier Arteau
int hello(int a, int* b, int c) { int hello_var = 0xdeadbeef; return 0xf00; } int main() { int main_var = 0x0; int result = hello(main_var, &main_var, 0x123456); return 0; }
main
hello
int main() { int some_var = 0; char buffer[12]; fgets(buffer, 9001, stdin); return 0; }
In computer security, a shellcode is a small piece of code used as the payload in the exploitation of a software vulnerability.
Pointer EIP vers le shellcode
Adresse de retour
Virtual Table (C++)
Call ou Jmp sur registre
GOT
cat ./flag.txt
p.send(exploit) p.send('cat flag.txt\n') print p.recv(1024)
set disassembly-flavor intel
readelf -l program
Win!
struct.pack("<I", 0x1234)
b"\x34\x12\x00\x00"
struct.unpack("<I", b"\x34\x12\x00\x00")
(0x1234, )
from pwn import *
context(arch = 'amd64', os = 'linux')
r = remote('192.168.4.178', 1239)
data = r.readline() # Réception
r.send(data) # Envoie
r.interactive() # Le terminal devient l'entrée et la sortie