February 16, 2012 2 Responses

AssetsProtector – Protect SWF, JPEG and XML files

I’ve developed a little tool to protect files like SWFs, PNGs, JPEGs or XMLs from beeing decompiled or directly used. So e.g. if you don’t like to hear your sounds playing in another game or you don’t want to allow poking around in your code AssetsProtector could help.

The AssetsProtector toolkit is composed of 3 components:

  • Protector Machine – an Air app to encrypt your assets – it also supports batch protecting and has a command line integration
  • Protector Agent – the preloader which loads your main SWF and assets and decrypts them at runtime
  • Assets Loader – an AS3 library to simplify the assets loading. If you want to load protected files you have to use this library – it will auto-detect if the loaded file is protected or not

The tool will at least make it a bit harder for people looking at your files from “outside” using decompilers like “ASV” or “Sothink SWF Decompiler” as both don’t know what to do with those encrypted SWFs and both completely crashed when trying to decompile the ProtectorAgent. The “Protector Agent” preloader also blocks PreloadSWFs like Doomsday Console or FlashPreloadProfiler.
Actually it won’t help against those smart guys poking around in memory at runtime – to make it really safe  put all your sensitive functions on a server…

Here is a brief tutorial of how to use the tool

The usage of the Asset Loader class is as easy as the following example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
private function startLoading():void
    //Create the asset loader and add the assets to the load queue
    _assetsLoader = new AssetsLoader();
    _assetsLoader.addAsset("agent", "assets/agent.swf", AssetType.DISPLAY_OBJECT);
    _assetsLoader.addAsset("xml", "assets/text.xml", AssetType.TEXT);
    _assetsLoader.addAsset("machine", "assets/machine.jpg", AssetType.DISPLAY_OBJECT);
    _assetsLoader.addAsset("assets", "assets/assets.png", AssetType.DISPLAY_OBJECT);
    _assetsLoader.addEventListener(Event.COMPLETE, onComplete);
    _assetsLoader.addEventListener(AssetProgressEvent.EVENT, onProgress);
    _assetsLoader.addEventListener(AssetLoadedEvent.EVENT, onAssetLoaded);
    _assetsLoader.load();
}
 
/**
 * Will be called if a asset has been loaded and is ready to use
 */
private function onAssetLoaded(e:AssetLoadedEvent):void
{
    //The "agent" asset has the logo movieclip exported for AS
    if (e.currentAssetKey == "agent")
    {
        _logo = Sprite( AssetsLoader.getAssetClassInstance("agent", "asset_logo") );
        _container.addChild(_logo);
        onResize(null);
    }
}
 
/**
 * Will be triggered while an asset is loading
 */
private function onProgress(e:AssetProgressEvent):void
{
    trace(e.currentAssetKey, e.assetsLoaded, e.assetsTotal, e.percent, e.bytesLoaded, e.bytesTotal);
}
 
/**
 * Will be called if all assets are loaded
 */
private function onComplete(e:Event):void
{
    //do something very important
}
private function startLoading():void
	//Create the asset loader and add the assets to the load queue
	_assetsLoader = new AssetsLoader();
	_assetsLoader.addAsset("agent", "assets/agent.swf", AssetType.DISPLAY_OBJECT);
	_assetsLoader.addAsset("xml", "assets/text.xml", AssetType.TEXT);
	_assetsLoader.addAsset("machine", "assets/machine.jpg", AssetType.DISPLAY_OBJECT);
	_assetsLoader.addAsset("assets", "assets/assets.png", AssetType.DISPLAY_OBJECT);
	_assetsLoader.addEventListener(Event.COMPLETE, onComplete);
	_assetsLoader.addEventListener(AssetProgressEvent.EVENT, onProgress);
	_assetsLoader.addEventListener(AssetLoadedEvent.EVENT, onAssetLoaded);
	_assetsLoader.load();
}

/**
 * Will be called if a asset has been loaded and is ready to use
 */
private function onAssetLoaded(e:AssetLoadedEvent):void
{
	//The "agent" asset has the logo movieclip exported for AS
	if (e.currentAssetKey == "agent")
	{
		_logo = Sprite( AssetsLoader.getAssetClassInstance("agent", "asset_logo") );
		_container.addChild(_logo);
		onResize(null);
	}
}

/**
 * Will be triggered while an asset is loading
 */
private function onProgress(e:AssetProgressEvent):void
{
	trace(e.currentAssetKey, e.assetsLoaded, e.assetsTotal, e.percent, e.bytesLoaded, e.bytesTotal);
}

/**
 * Will be called if all assets are loaded
 */
private function onComplete(e:Event):void
{
	//do something very important
}

 

See the tool’s website // www.assetsprotector.net

 

Filed in AS3, Flash

2 Responses

  1. swf encrypt on February 20, 2012, 8:45 am

    SWF Protector is the best solution for your SWF files

  2. bma on February 21, 2012, 9:20 am Author

    Really?