【问题标题】:Hide Javascript inside SWF file在 SWF 文件中隐藏 Javascript
【发布时间】:2015-01-29 18:51:44
【问题描述】:

我宁愿使用 .SWF 文件来隐藏我的 .JS,而不是使用低密码来隐藏我的 .JS。

问题是我对 ActionScript 3 一无所知,所以我想也许有人可以在隧道尽头给我一个启示,告诉我我必须下载什么 APP 来编写 Swf 文件以及我需要什么代码必须使用它才能工作。

如果有人没有发现,我会明确表示:我想使用 SWF 文件调用 Javascript。

谢谢,抱歉英语不好,再见。

【问题讨论】:

  • 您的代码在 SWF 中并不安全,您可以反编译 SWF 以获取代码。你需要工具来操作,但是一个有一点动力的人可以很容易地找到它们。
  • 我知道,但它仍然比页面中单独的 Javascript 更难。我有人有答案,我将不胜感激。
  • 但是这里你应该知道从HTML调用js文件和从Flash调用是一模一样的!!
  • 对我来说似乎过于工程化了。老实说,您的代码可能没有那么特别。缩小器可能会更好地隐藏您的代码。

标签: javascript actionscript-3 flash


【解决方案1】:

在 Windows 上,您可以下载 FlashDevelop IDE,它会要求您下载 Flex SDK(as3 的免费编译器)。

您需要了解类 ExternalInterface (Reference)。

出于安全原因,您需要使用 Flash 播放器在网络服务器上运行您的代码。

在 HTML 中,您需要参数 allowScriptAccess。

HTML 调用Javascript

    <script src="js/swfobject.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
    <script>
        var flashvars = {
        };
        var params = {
            menu: "false",
            scale: "noScale",
            allowFullscreen: "true",
            allowScriptAccess: "always",
            bgcolor: "",
            wmode: "direct" // can cause issues with FP settings & webcam
        };
        var attributes = {
            id:"CallJavascript"
        };
        swfobject.embedSWF(
            "CallJavascript.swf", 
            "altContent", "250", "250", "10.0.0", 
            "expressInstall.swf", 
            flashvars, params, attributes);

        $( document ).ready(function() {
            var flash = document.getElementById("CallJavascript");

            $( "#btnSend" ).click(function() {  
                flash.jsMySecretMethod( $( "#field" ).val() );
            });
        });
    </script>
    <style>
        html, body { height:100%; overflow:hidden; }
        body { margin:0; background-color:#c0c0c0 }
    </style>
</head>
<body>
    <div id="altContent">
        <h1>CallJavascript</h1>
        <p><a href="http://www.adobe.com/go/getflashplayer">Get Adobe Flash player</a></p>
    </div>
    <input id="field" type="text"/><button id="btnSend">Send</button>
</body>
</html>

AS3

package 
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.external.ExternalInterface;
    import flash.text.TextField;

    /**
     * ...
     * @author 
     */
    public class Main extends Sprite 
    {
        private var _textfield:TextField;

        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);

            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            _textfield = new TextField();
            _textfield.multiline = true;
            _textfield.wordWrap = true;
            _textfield.x = 20;
            _textfield.y = 20;
            _textfield.width = 200;
            _textfield.height = 200;
            _textfield.textColor = 0x000000;
            _textfield.text = "start";
            _textfield.border = true;
            addChild( _textfield );

            if ( ExternalInterface.available ) {
                ExternalInterface.addCallback( "jsMySecretMethod", mySecretMethod );
            }
        }

        private function mySecretMethod( str:String ):void {
            trace( str );
            _textfield.appendText( str );
        }

    }

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-17
    • 1970-01-01
    • 2018-06-15
    • 1970-01-01
    • 2014-03-20
    • 1970-01-01
    • 2011-01-28
    • 1970-01-01
    相关资源
    最近更新 更多