打包的javascript代码,如何解压缩
本文关键字:解压缩 代码 javascript | 更新日期: 2023-09-27 18:30:38
我对javascript一无所知,我正在尝试用C#解压缩javascript打包的源代码。打包的代码被正则表达式过滤掉,然后应该解压缩。包装工来自迪恩·爱德华兹 - http://dean.edwards.name/packer/。
数据包代码为:
eval(function (p, r, o, x, y, s) {
y = function (c) {
return (c < r ? '' : y(parseInt(c / r))) + ((c = c % r) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
};
if (!''.replace(/^/, String)) {
while (o--) {
s[y(o)] = x[o] || y(o)
}
x = [function (y) {
return s[y]
}];
y = function () {
return '''w+'
};
o = 1
};
while (o--) {
if (x[o]) {
p = p.replace(new RegExp('''b' + y(o) + '''b', 'g'), x[o])
}
}
return p
}('g=D^C;f=B^E;h=1;n=8;l=F^A;e=5;o=H^G;t=6;s=J^y;c=4;k=2;d=u^x;i=z^w;j=0;m=v^I;r=7;b=3;q=U^V;a=W^X;p=9;K=j^l;L=h^i;N=k^g;O=b^a;Q=c^d;P=e^m;M=t^s;R=r^q;S=n^o;T=p^f;', 60, 60, '^^^^^^^^^^ZeroSixThree^Two^Six^ZeroOneFive^Zero^EightEightEight^Five5Seven^One^ZeroFiveNine^Five^Eight^OneZeroZero^Eight8Six^Three^Five2One^Seven^OneThreeTwo^Nine^Six2Four^Four^1425^9684^8909^6588^8888^7667^3129^3117^80^4977^1337^9868^8085^11077^81^5847^Eight8ZeroTwo^ThreeZeroSevenThree^SixEightTwoFive^EightNineSixSeven^Four6FourNine^Three1OneFour^NineFourThreeOne^Four7NineZero^NineEightFiveEight^FourThreeEightSix^11146^1080^4347^88'.split(''u005e'), 0, {}))
( JSFIDDLE 链接在这里)
所以我找到了这个网站,它可以让您在线解压缩打包的代码,http://packet.dn.ua/在此页面上,我找到了解包器的主要功能(至少我认为是这样),可以在此处查看
现在我对javascript代码有一些疑问,想知道我对这个函数是否正确,以及在if语句中到底发生了什么。
function _unpack(a) { // takes an array as parameter?
var x, p = ''; // defines two empty arrays?
p = a.match(/%2/); // Make a regex match of the value '/%2/' ?
if (p) { // no clue
x = _uncase(a);
return _uncase(x);
}
return _uncase(a);
}
function _unpack(a) { // takes a string as argument, we can see that it's a string because strings have the match method, which is used below a.match(...)
var x, p = ''; // declare x, declare p and initialize it with the empty string value
p = a.match(/%2/); // match will return ['%2'] (which is an array that contains the string '%2' at index 0) only if %2 is found in the string 'a', else it returns null
if (p) { // if p is thruthy (objects are), but null is falsey. It's like saying, if there was a match
x = _uncase(a);
return _uncase(x);
}
return _uncase(a);
}
function _unpack(a) { // this is a string because down below two line, you are calling a.match() where the method match is defined on the string object
var x, p = ''; // Defines two empty strings, notice the ''
p = a.match(/%2/); // Make a regex match of the value %2 inside a, notice p is now an array, in javascript variables are dynamic and can change their type at runtime
if (p) { // if p is not empty or in other words, if there are some matches then
x = _uncase(a);
return _uncase(x);
}
return _uncase(a);
}