While decompiling obfuscated Adobe flash applications, I noticed that many of them contain an encrypted binary component:
My question is, how do you includ
Just to expand on @Denis-Kokorin's answer and clear your concerns...
I noticed that many of them contain an encrypted binary component:
Just be aware that "DefineBinaryData" is a standard segment (called Tags) of the SWF format, not a decompiler trick. To have it exist, you simply [embed]
a file via your AS3 code. That becomes the binary data as defined within the Tag.
My question is, how do you include a binary component (as described above) in your application and how do you load it using ActionScript in order to further process it?
Loading depends on what file format you embed. Use Bitmap
for images (jpg, png etc) & movieClip
for SWF, use Sound
for decoding MP3 data to playable (PCM) sound. Netstream's AppendBytes
will decode video bytes. If you want anything "encrypted" then do so before you embed it. You'll have to decide which encryption method to use or invent your own, of course your AS3 app must have the "decryption" code before you try to process it.
In the code below I've shown an example of loading content of different formats. From there you can process it as usual (eg: bitmapdata
for editing pixels or sound.extract
for editing audio samples, etc). I've also shown how to get bytes into a ByteArray
incase if it's the byte values you want to edit. Read the manual for handling ByteArray. This guide might also help you.
package
{
import flash.display.MovieClip;
import flash.utils.*;
import flash.display.*;
import flash.events.*;
import flash.media.*;
public class embed_test extends MovieClip
{
[Embed(source="image.jpg")] private var emb_Image : Class;
[Embed(source="track.mp3")] private var emb_MP3 : Class;
[Embed(source="vctest.swf")] private var emb_SWF : Class;
//# for access to bytes (binary data)
[Embed(source="image.jpg", mimeType="application/octet-stream")] private var emb_Bytes : Class;
public function embed_test()
{
var my_Pic : Bitmap = new emb_Image();
addChild(my_Pic); //# display image on stage
var my_Snd : Sound = new emb_MP3();
my_Snd.play(); //# play sound
var my_Swf : MovieClip = new emb_SWF();
addChild(my_Swf); //# display SWF on stage
var my_BA : ByteArray = new emb_Bytes as ByteArray;
trace("bytes length : " + my_BA.length); //# check bytes total is correct
trace("bytes (HEX) : " + bytes_toHex(my_BA) ); //# check bytes in hex format
}
private function bytes_toHex (input : ByteArray) : String
{
var strOut : String = ""; var strRead:String = "";
var input_Size : uint = input.length;
input.position = 0;
for (var i:int = 0; i < input_Size; i++)
{
strRead = input.readUnsignedByte().toString(16);
if(strRead.length < 2) { strRead = "0" + strRead; } //# do padding
strOut += strRead ;
}
return strOut.toUpperCase();
}
}
}
You could prepare some binary data and load it at runtime it via [Embed] meta tag.