如何解码这个JavaScript?

时间:2013-04-23 13:11:24

标签: javascript

我的问题是我如何解码这个JavaScript以及如何编码(使用哪个程序或在线工具)。

以下是我要解码的JavaScript: http://pastebin.com/hZvKySjj

3 个答案:

答案 0 :(得分:9)

每个混淆的脚本都需要某种eval。在这里,行

_L = 'constr\x75\x63\x74\x6F\x72';
[][_L][_L](_Z[_h._t4](_F))();

正在这样做。 _L是字符串"constructor"[].constructor.constructorFunction构造函数。它将使用已解码的脚本调用,并将调用生成的函数。我们可以用alert替换它,将脚本粘贴到控制台*中,等待结果 - 我们甚至不需要了解解码的工作原理。在您的情况下,结果是(是的,包括所有评论和换行符):

var alarm ="0";
var content = document;

if ((content.getElementById("wrapper") != null))
{
    document.getElementById('wrapper').style.display = 'block';
}

function a ()
{
    if ((content.getElementById("links") != null))
    {
        var temp = content.getElementById("links").innerHTML;
        if ((temp.indexOf('nofollow')+1) > 0)  alarm = "1";
        else if ((temp.indexOf('noindex')+1) > 0)  alarm = "1";
    }
    else alarm = "1";
}

function b ()
{
    if ((content.getElementById("aa") != null) && (content.getElementById("ab") != null))
    {
        temp = document.getElementById("aa").href;
        if ("http://uc-portaller.ru/" != temp) alarm = "1";

        temp = document.getElementById("ab").innerHTML;
        if ("скрипты для ucoz" != temp) alarm = "1";
    }
    else alarm = "1";
}

function c ()
{
    if ((content.getElementById("ba") != null) && (content.getElementById("bb") != null))
    {

        temp = content.getElementById("ba").href;
        if ("http://austere.ru/" != temp) alarm = "1";

        temp = content.getElementById("bb").innerHTML;
        if ("доска объявлений" != temp) alarm = "1";
    }
    else alarm = "1";
}

function d ()
{
    if ((content.getElementById("ca") != null) && (content.getElementById("cb") != null))
    {

        temp = content.getElementById("ca").href;
        if ("http://www.for-creative.com/" != temp) alarm = "1";

        temp = content.getElementById("cb").innerHTML;
        if ("темы для ucoz" != temp) alarm = "1";
    }
    else alarm = "1";
}

a ();

if (alarm == "0") b ();
if (alarm == "0") c ();
if (alarm == "0") d ();

if (alarm == "1") prompt('Нарушены условия использования, по всем вопросам обращайтесь в ICQ:', '376880395');












$(document).ready(function(){

    //When you click on a link with class of poplight and the href starts with a # 
    $('a.poplight[href^=#]').click(function() {
        var popID = $(this).attr('rel'); //Get Popup Name
        var popURL = $(this).attr('href'); //Get Popup href to define size

        //Pull Query & Variables from href URL
        var query= popURL.split('?');
        var dim= query[1].split('&');
        var popWidth = dim[0].split('=')[1]; //Gets the first query string value

        //Fade in the Popup and add close button
        $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('');

        //Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
        var popMargTop = ($('#' + popID).height() + 80) / 2;
        var popMargLeft = ($('#' + popID).width() + 80) / 2;

        //Apply Margin to Popup
        $('#' + popID).css({ 
            'margin-top' : -popMargTop,
            'margin-left' : -popMargLeft
        });

        //Fade in Background
        $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
        $('#fade').css({'filter' : 'alpha(opacity=0)'}).fadeIn(); //Fade in the fade layer 

        return false;
    });


    //Close Popups and Fade Layer
    $('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
        $('#fade , .popup_block').fadeOut(function() {
            $('#fade, a.close').remove();  
    }); //fade them both out

        return false;
    });


});




        $.fn.tabs = function () {
            return this.each(function () {
               var $tabwrapper = $(this); 

               var $panels = $tabwrapper.find('> div');
               var $tabs = $tabwrapper.find('> ul a');

               $tabs.click(function () {  
                   $tabs.removeClass('selected');
                   $(this).addClass('selected');

                   $panels
                    .hide() // hide ALL the panels
                    .filter(this.hash) // filter down to 'this.hash'
                        .show(); // show only this one

                   return false;
               }).filter(window.location.hash ? '[hash=' + window.location.hash + ']' : ':first').click();
            });
        };

        $(document).ready(function () {
            // console.log(window.location.hash);

            $('div.tabs').tabs();
        });

*)当然,您需要确定自己在做什么。这是一个很小的风险,它是一个恶意脚本,你可能还没有找到所有eval。 @jfriend00逐行执行解码片段的提示是一种更安全的方式。

答案 1 :(得分:2)

我知道理解这段代码的唯一方法是找到一个安全的环境(如果代码有恶意),并在调试器中逐行执行,并观察它在反混淆自身时的作用把自己变成普通的javascript。变量名称通常会保持模糊,但_O中的巨型字符串将被解码为某些内容(可能是javascript代码)。

答案 2 :(得分:0)

查看:http://www.labnol.org/software/deobfuscate-javascript/19815/

他们向您展示了如何做到这一点,基本上是使用chrome调试器来“美化”代码并使其更易于阅读。

某些版本的chrome在上下文菜单中没有命令,只需查看命令“Pretty print”(有一个图标,如&gt; {}

完成后,您可以使用javascript控制台评估代码的小片段以对其进行反向工程。例如。表达式(在代码的开头)

1) (s\u0065lf + ([] * 0) * 1)
2) '\x5B'
3) ((s\u0065lf + ([] * 0) * 1)[0 ^ 0] == '\x5B')

在我的浏览器上返回此字符串

1) "[object Window]0"
2) "["
3) true

找到起点并从那里开始。混淆的代码遵循与正常规则相同的规则,它只是搞砸了。

相关问题