将二进制数据嵌入到 Flash 应用程序中 [英] Embedding binary data into Flash applications

查看:35
本文介绍了将二进制数据嵌入到 Flash 应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在反编译混淆的 Adob​​e Flash 应用程序时,我注意到其中许多包含加密的二进制组件:

While decompiling obfuscated Adobe flash applications, I noticed that many of them contain an encrypted binary component:

我的问题是,如何在应用程序中包含二进制组件(如上所述)以及如何使用 ActionScript 加载它以进一步处理它?

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?

注意:我的 IDE 是 Fl​​ash Builder,我正在使用 Adob​​e AIR 应用程序.

Note: My IDE is Flash Builder and I am working with a Adobe AIR application.

推荐答案

只是为了扩展@Denis-Kokorin 的回答并消除您的疑虑...

Just to expand on @Denis-Kokorin's answer and clear your concerns...

我注意到其中许多包含加密的二进制组件:

I noticed that many of them contain an encrypted binary component:

请注意,DefineBinaryData"是 SWF 格式的标准段(称为标签),而不是反编译器技巧.要让它存在,您只需通过 AS3 代码 [embed] 一个文件.这将成为标签中定义的二进制数据.

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.

我的问题是,你如何包含一个二进制组件(如描述的以上)在您的应用程序中,以及如何使用 ActionScript 加载它以便进一步处理?

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?

加载取决于您嵌入的文件格式.将 Bitmap 用于图像(jpg、png 等)&movieClip 对于 SWF,使用 Sound 将 MP3 数据解码为可播放 (PCM) 声音.Netstream 的 AppendBytes 将解码视频字节.如果您想要任何加密"的内容,请在嵌入之前进行.您必须决定使用哪种加密方法或自行发明,当然您的 AS3 应用程序必须具有解密"代码,然后才能尝试对其进行处理.

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.

在下面的代码中,我展示了加载不同格式内容的示例.从那里你可以像往常一样处理它(例如:bitmapdata 用于编辑像素或 sound.extract 用于编辑音频样本等).我还展示了如何将字节放入 ByteArray 以防它是您要编辑的字节值.阅读处理ByteArray.此指南也可能对您有所帮助.

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();
    }

}

}

这篇关于将二进制数据嵌入到 Flash 应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆