0

我知道没有真正的方法来保护 js 文件内容,但我发现有人这样做了,这使得任何人都很难获得原始内容,我希望你能帮助我知道来源是什么以及如何做同样的事情加密方式。

var cf = parent['cboxform'];
var cm = window;
var frmod = 'http://france10s.com/cbox/?';

function include(_0xce28x5, _0xce28x6) {
    head = _0xce28x6['document']['getElementsByTagName']('head')[0];
    var _0xce28x7 = _0xce28x6['document']['createElement']('script');
    _0xce28x7['setAttribute']('type', 'text/javascript');
    _0xce28x7['setAttribute']('src', _0xce28x5);
    head['insertBefore'](_0xce28x7, head['lastChild']);
};
include(frmod + 'g', cm);
include(frmod + 'cl', cm);
include(frmod + 'ft', cm);
include(frmod + 'pk', cm);
include(frmod + 'tm', cm);
include(frmod + 'm', cm);

包含的内容很难用任何东西解密,我知道这就是为什么我想知道我该怎么做。

谢谢

4

1 回答 1

0

What you're looking for is called an obfuscator. Searching for "JavaScript obfuscator" gives plenty of results, and then the results they give are truly horrible, just how you'd like, for example, here's what http://www.jsobfuscate.com/ did with your code:

eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('6 f=e[\'h\'];6 3=i;6 2=\'k://j.d/l/?\';c 1(a,7){4=7[\'8\'][\'b\'](\'4\')[0];6 5=7[\'8\'][\'t\'](\'y\');5[\'9\'](\'v\',\'n/x\');5[\'9\'](\'w\',a);4[\'u\'](5,4[\'p\'])};1(2+\'g\',3);1(2+\'o\',3);1(2+\'q\',3);1(2+\'r\',3);1(2+\'s\',3);1(2+\'m\',3);',35,35,'|include|frmod|cm|head|_0xce28x7|var|_0xce28x6|document|setAttribute|_0xce28x5|getElementsByTagName|function|com|parent|cf||cboxform|window|france10s|http|cbox||text|cl|lastChild|ft|pk|tm|createElement|insertBefore|type|src|javascript|script'.split('|'),0,{}))

Edit: Your sample looks very similar to http://javascriptobfuscator.com/, here's an example:

var _0x81b5=[];function foo(_0xd99cx2){var _0xd99cx3=3;function _0xd99cx4(_0xd99cx5){alert(_0xd99cx2+_0xd99cx5+(++_0xd99cx3));} ;_0xd99cx4(10);} ;foo(2);

于 2013-06-08T10:30:52.843 回答