本帖最后由 thepoy 于 2020-10-17 21:50 编辑
练习爬某网站时,遇到签名问题,找到了签名函数,但js代码压缩混淆,变量名看着头疼,请问高手和大佬,这种代码如何转为python代码啊?[JavaScript] 纯文本查看 复制代码 function r(e) {
function t(e, t) {
return e >>> t | e << 32 - t
}
for (var n, i, o = Math.pow, a = o(2, 32), s = "length", u = "", l = [], c = 8 * e[s], h = r.h = r.h || [], d = r.k = r.k || [], f = d[s], p = {}, m = 2; f < 64; m++)
if (!p[m]) {
for (n = 0; n < 313; n += m) p[n] = m;
h[f] = o(m, .5) * a | 0, d[f++] = o(m, 1 / 3) * a | 0
} e += "?";
while (e[s] % 64 - 56) e += "\0";
for (n = 0; n < e[s]; n++) {
if (i = e.charCodeAt(n), i >> 8) return;
l[n >> 2] |= i << (3 - n) % 4 * 8
}
for (l[l[s]] = c / a | 0, l[l[s]] = c, i = 0; i < l[s];) {
var g = l.slice(i, i += 16),
v = h;
for (h = h.slice(0, 8), n = 0; n < 64; n++) {
var y = g[n - 15],
b = g[n - 2],
x = h[0],
_ = h[4],
w = h[7] + (t(_, 6) ^ t(_, 11) ^ t(_, 25)) + (_ & h[5] ^ ~_ & h[6]) + d[n] + (g[n] = n < 16 ? g[n] : g[n - 16] + (t(y, 7) ^ t(y, 18) ^ y >>> 3) + g[n - 7] + (t(b, 17) ^ t(b, 19) ^ b >>> 10) | 0),
S = (t(x, 2) ^ t(x, 13) ^ t(x, 22)) + (x & h[1] ^ x & h[2] ^ h[1] & h[2]);
h = [w + S | 0].concat(h), h[4] = h[4] + w | 0
}
for (n = 0; n < 8; n++) h[n] = h[n] + v[n] | 0
}
for (n = 0; n < 8; n++)
for (i = 3; i + 1; i--) {
var C = h[n] >> 8 * i & 255;
u += (C < 16 ? 0 : "") + C.toString(16)
}
return u
}
已手动改完,耗时一整天。 |