2011-04-04 17 views
3

有人可以解釋我如何http://utf-8.jp/public/jjencode.html的作品,如果是好的使用它在我的代碼,我第一次嘗試它我想我需要有一些算法在我的代碼中,以便使用它,但它適用於每個站點,發生了什麼?有人可以解釋我如何jjencode的作品,如果是好的使用它在我的代碼

我已經看到了源代碼,但我不明白。

+0

您有興趣混淆你的代碼,或者你對jjencode如何工作感興趣?請注意,jjencode使輸出代碼顯着變大,因此不適合生產使用。 – 2011-04-04 06:19:02

回答

10

下面是使用JavaScript的類型轉換的可能性,這意味着如評論腳本 http://corkami.googlecode.com/svn-history/r399/trunk/misc/jjencode.txt

// this is a commented source of a jjencode script 
// jjencode, http://utf-8.jp/public/jjencode.html 

// reference: Peter Ferrie, 2011, http://pferrie2.tripod.com/papers/jjencode.pdf 

// for reference, 
// alert("Hello, JavaScript") 
// is encoded as 

// $=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$__:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$$+"\""+$.$_$_+(![]+"")[$._$_]+$.$$$_+"\\"+$.__$+$.$$_+$._$_+$.__+"(\\\"\\"+$.__$+$.__$+$.___+$.$$$_+(![]+"")[$._$_]+(![]+"")[$._$_]+$._$+",\\"+$.$__+$.___+"\\"+$.__$+$.__$+$._$_+$.$_$_+"\\"+$.__$+$.$$_+$.$$_+$.$_$_+"\\"+$.__$+$._$_+$._$$+$.$$__+"\\"+$.__$+$.$$_+$._$_+"\\"+$.__$+$.$_$+$.__$+"\\"+$.__$+$.$$_+$.___+$.__+"\\\"\\"+$.$__+$.___+")"+"\"")())(); 


// preliminary points 

// (a + "") gives the string representation of a 

// [] = empty array. 0 by value, -1 with ~ => ~[] = -1 
// as a string, ![] gives 'false' 

// {} = empty object. 
// as a string, {} gives '[object Object]' 

// if a is a x-long array, a[x] is 'undefined' as a string. same for absent properties. 

// "" is an empty string. !"" returns 'true' as it is indeed 'null' 


// now let's start with the actual code 

// creating $ variable with a value. 
$=~[]; // $ = -1 

// defining properties of a $ object. 
$ = 
{ 
    ___:++$,    // 0, $ = 0 

    $$$$:(![] + 」」)[$],  // 0th char of 'false',   => 'f' 

    __$:++$,    // 1, $ = 1 now... 

    $_$_:(![] + 」」)[$],  // 1st char of 'false'   => 'a' 

    _$_:++$,    // 2... 

    $_$$:({} + 」」)[$],   // 2nd char of '[object Object]' => 'b' 

    $$_$:($[$] + 」」)[$],  // 2nd char of 'undefined'  => 'd' 

    _$$:++$,    // 3... 

    $$$_:(!」」 + 」」)[$],  // 3rd char of 'true'    => 'e' 

    $__:++$,    // 4 

    $_$:++$,    // 5 

    $$__:({} + 」」)[$],   // 5th char of '[object Object]' => 'c' 

    $$_:++$,    // 6 

    $$$:++$,    // 7 

    $___:++$,   // 8 

    $__$:++$    // 9 
}; 

// => in order, ___, __$, _$_, _$$, $__, $_$, $$_, $$$, $___, $__$, $_$_, $_$$, $$__, $$_$, $$$_, $$$$ are now equal to 0...F, 
// note they are just binary numbers with character substitution 

$.$_ = 
    ($.$_ = $ + 」」)[$.$_$] +    // 5th character of '[object Object]' => $.$_ = 'c' 
    ($._$ = $.$_[$.__$]) +    // 1st character of ...    => $._$ = 'o' 
    ($.$$ = ($.$ + 」」)[$.__$]) +   // 1st char of 'undefined'    => $.$$ = 'n' 
    ((!$) + 」」)[$._$$] +     // 3rd char of 'false'     => 's'   // poor s, we don't save it... 
    ($.__ = $.$_[$.$$_]) +    // 6th char of '[object Object]'  => $.__ = 't' 
    ($.$ = (!」」 + 」」)[$.__$]) +   // 1st char of 'true'     => $.$ = 'r' 
    ($._ = (!」」 + 」」)[$._$_]) +   // 2nd char of 'true'     => $._ = 'u' 
    $.$_[$.$_$] +       // 5th char of '[object Object]']  => 'c'   // hey, we already have a c ! 
    $.__ +        // 't' 
    $._$ +        // 'o' 
    $.$;         // 'r' 

// => $.$_ = 'constructor' 


$.$$ = 
    $.$ +      // 'r' 
    (!」」 + 」」)[$._$$] +   // 'true'[3] => 'e' 
    $.__ +      // 't' 
    $._ +      // 'u' 
    $.$ +      // 'r' 
    $.$$;      // 'n' 

$.$ = 
    ($.___)[$.$_][$.$_];  // (0)[constructor][constructor] 


// summary of $ at this point 

// $ = {} 
// $.___ = '0'; 
// $.__$ = '1'; 
// $._$_ = '2'; 
// $._$$ = '3'; 
// $.$__ = '4'; 
// $.$_$ = '5'; 
// $.$$_ = '6'; 
// $.$$$ = '7'; 
// $.$___ = '8'; 
// $.$__$ = '9'; 
// $.$_$_ = 'a'; 
// $.$_$$ = 'b'; 
// $.$$__ = 'c'; 
// $.$$_$ = 'd'; 
// $.$$$_ = 'e'; 
// $.$$$$ = 'f'; 

// $.$_ = 'c' 
// $._$ = 'o' 
// $.$$ = 'n' 
// $.__ = 't' 
// $.$ = 'r' 
// $._ = 'u' 

// $.$_ = 'constructor'; 
// $.$$ = 'return'; 
// $.$ = (0)[constructor][constructor] 



// and finally, the only line of call 

$.$(
    $.$(
     $.$$ + 」\」」 + ENCODED + 」\」」 
     )() 
    )(); 

// 
(0)[constructor][constructor](
    (0)[constructor][constructor](
     return + " + ENCODED + " 
     )() 
    )() 

// 'equivalent' to eval(eval(ENCODED)) 


// encoding 
// !"#$%&’()*+,-./:;<>[email protected][]^_`{|}~ as is 
//abcdeftou => as $ properties. Ex : 'babe' = $.$_$$ + $.$_$_ + $.$_$$ + $.$$$_ 
// other ascii chars: as \xxx (octal) encoding. Ex: 'A' = char(65) = \101 = "\\" + $.__$ + $.___ + $.__$ 
// unicode chars as \u????. ex: 'sea', \u6d77 as "\\" + $._ + $.$$_ + $.$$_$ + $.$$$ + $.$$$ 

// so in the end, it's just defining a $ object and executing an eval on a string, that is built character by character. 

// to confirm, here is a small imperfect python decryption script 

// import sys 
// start = r'$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$__:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$$+"\""+' 
// end = r'+"\"")())();' 
// 
// with open(sys.argv[1], "rb") as f: 
//  r = f.read() 
// 
// r = r.replace(start, "").replace(end, "") 
// print r 
// 
// subst = [ 
//  ['$.$___','8'], 
//  ['$.$__$','9'], 
//  ['$.$_$_','a'], 
//  ['$.$_$$','b'], 
//  ['$.$$__','c'], 
//  ['$.$$_$','d'], 
//  ['$.$$$_','e'], 
//  ['$.$$$$','f'], 
//  ['$.___','0'], 
//  ['$.__$','1'], 
//  ['$._$_','2'], 
//  ['$._$$','3'], 
//  ['$.$__','4'], 
//  ['$.$_$','5'], 
//  ['$.$$_','6'], 
//  ['$.$$$','7'], 
//  ['$.$_', 'c'], 
//  ['$._$', 'o'], 
//  ['$.$$', 'n'], 
//  ['$.__', 't'], 
//  ['$.$', 'r'], 
//  ['$._', 'u'], 
//  [r'"\\"' , '\\'], 
//  ["\"\\\\\\\\\"", "\\\\"], 
//  ["+", ""], 
//  ] 
// 
// for s in subst: 
//  r = r.replace(s[0], s[1]) 
// 
// r = r.replace("+", "") 
// print r 

// Ange Albertini, BSD Licence 2011 
1

這是嚴重(AB)。數值1在JavaScript的內容中轉換爲字符串「1」。其他情況下,例如NULL元素的「Value」由JavaScript轉換爲文本字符串「NULL」等。因此,黑客可以使用這些字符串作爲「存儲庫」進行計算,字符串組裝等。

相關問題