level3
程序分析
通过ida打开程序,F5键生成C的代码如下:
int __cdecl main(int argc, const char **argv, const char **envp)
{
vulnerable_function();
write(1, "Hello, World!\n", 0xEu);
return 0;
}
ssize_t vulnerable_function()
{
char buf; // [esp+0h] [ebp-88h]
write(1, "Input:\n", 7u);
return read(0, &buf, 0x100u);
}
很明显,vulnerable_function的read函数有注入点,可以复写vulnerable_function的返回地址。
但这题程序中没有system调用,因此要先找到system和/bin/sh字符串在内存中的位置。
我们知道,write,read,system,"/bin/sh"虽然每次加载到内存中的位置都是不一样的,但是他们的相对位置是固定的,因此,可以利用write函数打印出write或read在内存中的位置,然后通过偏移值便可以得到system和/bin/sh在内存中的位置,通过第二次调用read函数复写返回地址便可以执行system('/bin/sh')。
获取地址偏移
from pwn import *
elf = ELF(

本文详细介绍了攻防世界PWN题目level3的解决过程,包括程序分析、获取地址偏移、两次调用read函数复写返回地址以实现控制流程,最终执行系统命令。使用ida进行反编译,利用pwntools获取函数地址偏移,并通过plt和got表进行地址操纵,确保连续执行read函数以成功执行系统调用。
213

被折叠的 条评论
为什么被折叠?



