I made a Universal SWF Decrypter based on the method/code I posted the other day.
you can find the windows binary here or on my downloads page.
It should work on all swf encryptions that use an AS3 loader. which means it should work on ALL mochicrypt games. and probably on all other SWF encryptions, too.
*edit*
Go Here for the new Universal SWF Decryptor V3
Tuesday, April 10, 2012
Universal SWF Decrypter
Labels:
actionscript,
adobe,
AS3,
AVM2,
decrypter,
decryption,
encryption,
mochicrypt,
programming
Thursday, April 5, 2012
Decrypting AS3 SWF's
Today, I found a massive flaw in Mochicrypt and probably all AS3 encryption methods. I'm sure others already know about it, but I'll post it anyway.
Firstly, let me start by explaining how these encryptions work:
The swf is encrypted and stored (generally in the decryptor/loader).
The encrypted swf is decrypted and turned into a byteArray
The decrypted byteArray is loaded using the Loader.loadBytes() method.
The Loader is added to the stage.
and, as it turns out, getting the unencrypted swf from the loader is incredibly easy.
there's this usefull as3 class called "LoaderInfo" that will solve all our problems.
in fact, Loader.contentLoaderInfo.bytes contains the byteArray for the loaded swf.
so, what we can do is load the decrypter, scan the stage's children for Loader objects, find the one for the decrypted swf and dump it's data.
Here's a working example I made for Bloons TD 5:
To use it, place the Bloons TD 5 swf in it's folder (make sure it's called "btd5.swf"), open the decrypter, wait for the game to load and then press numpad 0 to save the decrypted swf.
Here's a link to the compiled version of the decrypter (same as the code above):
http://www.mediafire.com/?lfk94ox5ge9i85k
Also note that the above code and decrypter may work on more/all mochicrypt swfs/loaders. I've only tested it on Bloons TD 5's mochicrypt loader as that's what it's made for, but it may very well work on all mochicrypt loaders.
*edit*
it only works on some, not all. I'll release a universal SWF decrypter I've made later today.
Firstly, let me start by explaining how these encryptions work:
The swf is encrypted and stored (generally in the decryptor/loader).
The encrypted swf is decrypted and turned into a byteArray
The decrypted byteArray is loaded using the Loader.loadBytes() method.
The Loader is added to the stage.
and, as it turns out, getting the unencrypted swf from the loader is incredibly easy.
there's this usefull as3 class called "LoaderInfo" that will solve all our problems.
in fact, Loader.contentLoaderInfo.bytes contains the byteArray for the loaded swf.
so, what we can do is load the decrypter, scan the stage's children for Loader objects, find the one for the decrypted swf and dump it's data.
Here's a working example I made for Bloons TD 5:
package
{
import flash.display.*;
import flash.net.*;
import flash.events.*;
public class BTD5Decryptor extends MovieClip
{
private var ldr:Loader = new Loader();
private var swf:Object;
public function BTD5Decryptor()
{
ldr.load(new URLRequest("btd5.swf"));
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
addChild(ldr);
stage.addEventListener(KeyboardEvent.KEY_DOWN, doKeys);
}
private function onComplete(evt:Event):void
{
var ldrInfo:LoaderInfo = evt.target as LoaderInfo;
swf = ldrInfo.content;
}
private function doKeys(e:KeyboardEvent)
{
if (e.keyCode == 96)
{
var file:FileReference = new FileReference();
file.save((swf.getChildAt(1) as Loader).contentLoaderInfo.bytes,"unencrypted.swf");
}
}
}
}
To use it, place the Bloons TD 5 swf in it's folder (make sure it's called "btd5.swf"), open the decrypter, wait for the game to load and then press numpad 0 to save the decrypted swf.
Here's a link to the compiled version of the decrypter (same as the code above):
http://www.mediafire.com/?lfk94ox5ge9i85k
Also note that the above code and decrypter may work on more/all mochicrypt swfs/loaders. I've only tested it on Bloons TD 5's mochicrypt loader as that's what it's made for, but it may very well work on all mochicrypt loaders.
*edit*
it only works on some, not all. I'll release a universal SWF decrypter I've made later today.
Labels:
5,
actionscript,
adobe,
AS3,
AVM2,
bloons,
decrypter,
decryption,
encryption,
mochicrypt,
programming,
td,
tower defense
Friday, March 23, 2012
Getting around SecurityError #2070
So, today I started playing with some SWF loading code in Flash Builder, and I ran into a common sandbox problem.
You get Error #2070 when a loaded swf in another directory tries to access the stage.
I couldn't get around it by using Security.allowDomain("*") either, because it was an AIR application.
So, to get around this problem I decided instead of directly loading the file using Loader.load() I'd load it by loading the file into a byteArray and useing Loader.loadBytes() instead. and guess what? it works.
It completely gets around the sandbox issue.
Have some code:
There's probably a better, simpler way to get around this sandbox issue, but at least this works.
You get Error #2070 when a loaded swf in another directory tries to access the stage.
I couldn't get around it by using Security.allowDomain("*") either, because it was an AIR application.
So, to get around this problem I decided instead of directly loading the file using Loader.load() I'd load it by loading the file into a byteArray and useing Loader.loadBytes() instead. and guess what? it works.
It completely gets around the sandbox issue.
Have some code:
private function loadSwfFromUrl(url:String):void{
var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
var ldr:Loader = new Loader();
var swf:ByteArray = new ByteArray();
var fs:FileStream = new FileStream();
fs.open(new File(url), FileMode.READ);
fs.readBytes(swf);
fs.close();
context.allowCodeImport = true;
ldr.loadBytes(swf,context);
stage.addChild(ldr);
}
There's probably a better, simpler way to get around this sandbox issue, but at least this works.
Labels:
2070,
actionscript,
adobe,
AIR,
AS3,
AVM2,
programming,
sandbox,
securityerror
Saturday, March 17, 2012
Universal Flash Variable Scanner
So, I had an idea for a universal swf variable scanner.
one that works on AVM1 (AS1/AS2) and AVM2 (AS3) swf's.
The main problem you face when attempting to create such a thing is that AVM1 swf's and AVM2 swf's have separate sandboxes.
AVM2 loaders CAN get and set variables in loaded AVM2 swf's.
AVM2 loaders CANNOT get and set variables in loaded AVM1 swf's.
However, there are ways to get around this.
You could theoretically make a universal scanner made up of an AVM2 loader and scanner and an AVM1 loader and scanner.
for scanning AVM2 swf's there is no problem:
AVM2 Master swf loads AVM2 movie and scans it.
But for AVM1 swf's, you have to get around sandbox issues.
My idea works like so:
AVM2 Master swf loads AVM1 Scanner.
AVM1 Scanner loads AVM1 movie.
AVM1 Scanner communicates with AVM2 Master swf using LocalConnection.
AVM1 Scanner scans AVM1 movie.
If you were smart, you could probably remove the need for communication between the AVM1 and AVM2 scanner parts and have them functioning pretty much completely independantly.
one that works on AVM1 (AS1/AS2) and AVM2 (AS3) swf's.
The main problem you face when attempting to create such a thing is that AVM1 swf's and AVM2 swf's have separate sandboxes.
AVM2 loaders CAN get and set variables in loaded AVM2 swf's.
AVM2 loaders CANNOT get and set variables in loaded AVM1 swf's.
However, there are ways to get around this.
You could theoretically make a universal scanner made up of an AVM2 loader and scanner and an AVM1 loader and scanner.
for scanning AVM2 swf's there is no problem:
AVM2 Master swf loads AVM2 movie and scans it.
But for AVM1 swf's, you have to get around sandbox issues.
My idea works like so:
AVM2 Master swf loads AVM1 Scanner.
AVM1 Scanner loads AVM1 movie.
AVM1 Scanner communicates with AVM2 Master swf using LocalConnection.
AVM1 Scanner scans AVM1 movie.
If you were smart, you could probably remove the need for communication between the AVM1 and AVM2 scanner parts and have them functioning pretty much completely independantly.
Labels:
actionscript,
AS3,
AVM1,
AVM2,
programming,
scanner,
variable
Subscribe to:
Posts (Atom)