目标网站:https://music.163.com/#/song?id=2054300084
需求:获取评论内容,用户名
案例分析
1、分析网站加载方式
动态加载,抓包
找到目标 url:https://music.163.com/weapi/comment/resource/comments/get?csrf_token=
2、分析请求方式
post,需要携带参数
3、多做测试,看参数值是否变化,不变化可直接携带,变化不可直接携带
4、数据是变化的,不能直接携带
5、把相关的都打上断点,然后刷新页面
6、可以确定需要的值是这里得到的
e4i.data = j4n.cr5w({
params: bVe2x.encText,
encSecKey: bVe2x.encSecKey
})
分析 params 是 bVe2x 这个函数的调用返回的内容赋值的
var bVe2x = window.asrsea(JSON.stringify(i4m), bsk8c(["流泪", "强"]), bsk8c(Vx8p.md), bsk8c(["爱心", "女孩", "惊恐", "大笑"]));
bVe2x 这里传递了4个参数,参数是用逗号隔开的,要分析这4个参数都是什么
7、先分析第一个参数,打断点,然后刷新页面
8、运行代码,查询值,发现 JSON.stringify(i4m) 的值和 d 的值是一样的
9、多次继续执行代码,直到值全部加载完成
10、分析值,多重复运行几次,看看参数值是否是会变化的
// 第一个参数
JSON.stringify(i4m)
'{
"rid":"R_SO_4_2054300084", // 歌曲的 id 值
"threadId":"R_SO_4_2054300084",
"pageNo":"1", // ⻚码
"pageSize":"20", // 评论数量
"cursor":"-1",
"offset":"0",
"orderType":"1",
"csrf_token":""
}'
11、分析第二个参数,也是多重复运行几次,看看参数值是否是会变化的
// 第二个参数
bsk8c(["流泪", "强"])
'010001'
12、分析第三个参数,也是多重复运行几次,看看参数值是否是会变化的
// 第三个参数
bsk8c(Vx8p.md)
'00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
13、分析第四个参数,也是多重复运行几次,看看参数值是否是会变化的
// 第四个参数
bsk8c(["爱心", "女孩", "惊恐", "大笑"])
'0CoJUm6Qyw8W8jud'
14、分析
// 第一个参数
JSON.stringify(i4m)--d
'{
"rid":"R_SO_4_2054300084", // 歌曲的 id 值
"threadId":"R_SO_4_2054300084",
"pageNo":"1", // ⻚码
"pageSize":"20", // 评论数量
"cursor":"-1",
"offset":"0",
"orderType":"1",
"csrf_token":""
}'
// 第二个参数
bsk8c(["流泪", "强"])--e
'010001'
// 第三个参数
bsk8c(Vx8p.md)--f
'00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
// 第四个参数
bsk8c(["爱心", "女孩", "惊恐", "大笑"])--g
'0CoJUm6Qyw8W8jud'
function d(d, e, f, g) {
var h = {}
, i = a(16);
return h.encText = b(d, g),
h.encText = b(h.encText, i),
h.encSecKey = c(i, e, f),
h
}
15、新建一个 Js 文件,将找到的数据复制进去
// wyyJs.js
var e = '010001'
var f = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
var g = '0CoJUm6Qyw8W8jud'
function d(d) {
var h = {}
, i = a(16);
return h.encText = b(d, g),
h.encText = b(h.encText, i),
h.encSecKey = c(i, e, f),
h
}
data = '{"rid":"R_SO_4_2054300084","threadId":"R_SO_4_2054300084","pageNo":"1","pageSize":"20","cursor":"-1","offset":"0","orderType":"1","csrf_token":""}'
console.log(d(data))
16、运行后报错
, i = a(16);
^
ReferenceError: a is not defined
17、去浏览器查看函数 a,找到 a 的来源
18、将函数 a 复制到代码中
function a(a) {
var d, e, b = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", c = "";
for (d = 0; a > d; d += 1)
e = Math.random() * b.length,
e = Math.floor(e),
c += b.charAt(e);
return c
}
19、运行后报错
return h.encText = b(d, g),
^
ReferenceError: b is not defined
20、去浏览器查看函数 b,找到 b 的来源
21、将函数 b 复制到代码中
function b(a, b) {
var c = CryptoJS.enc.Utf8.parse(b)
, d = CryptoJS.enc.Utf8.parse("0102030405060708")
, e = CryptoJS.enc.Utf8.parse(a)
, f = CryptoJS.AES.encrypt(e, c, {
iv: d,
mode: CryptoJS.mode.CBC
});
return f.toString()
}
22、运行后报错
var c = CryptoJS.enc.Utf8.parse(b)
^
ReferenceError: CryptoJS is not defined
23、CryptoJS 可以借助 node.js 来自己构造
进入项目文件夹下,在地址栏输入 cmd 打开终端,输入命令 npm install crypto-js 安装模块
安装好后项目文件夹下会出现一个 node_modules 文件夹
24、在代码中引入 crypto-js 模块
const CryptoJS = require('crypto-js')
25、运行后报错
h.encSecKey = c(i, e, f),
^
ReferenceError: c is not defined
26、去浏览器查看函数 c,找到 c 的来源
27、将函数 c 复制到代码中
function c(a, b, c) {
var d, e;
return setMaxDigits(131),
d = new RSAKeyPair(b,"",c),
e = encryptedString(d, a)
}
28、运行后报错
return setMaxDigits(131),
^
ReferenceError: setMaxDigits is not defined
29、去浏览器查看函数 setMaxDigits,找到 setMaxDigits 的来源
30、将函数 setMaxDigits 复制到代码中
function setMaxDigits(a) {
maxDigits = a,
ZERO_ARRAY = new Array(maxDigits);
for (var b = 0; b < ZERO_ARRAY.length; b++)
ZERO_ARRAY[b] = 0;
bigZero = new BigInt,
bigOne = new BigInt,
bigOne.digits[0] = 1
}
31、运行后报错
bigZero = new BigInt,
^
TypeError: BigInt is not a constructor
32、去浏览器查看函数 BigInt,找到 BigInt 的来源
33、将函数 BigInt 复制到代码中
function BigInt(a) {
this.digits = "boolean" == typeof a && 1 == a ? null : ZERO_ARRAY.slice(0),
this.isNeg = !1
}
34、运行后报错
d = new RSAKeyPair(b,"",c),
^
ReferenceError: RSAKeyPair is not defined
35、去浏览器查看函数 RSAKeyPair,找到 RSAKeyPair 的来源
36、将函数 RSAKeyPair 复制到代码中
function RSAKeyPair(a, b, c) {
this.e = biFromHex(a),
this.d = biFromHex(b),
this.m = biFromHex(c),
this.chunkSize = 2 * biHighIndex(this.m),
this.radix = 16,
this.barrett = new BarrettMu(this.m)
}
37、运行后报错
this.e = biFromHex(a),
^
ReferenceError: biFromHex is not defined
38、去浏览器查看函数 biFromHex,找到 biFromHex 的来源
39、将函数 biFromHex 复制到代码中
function biFromHex(a) {
var d, e, b = new BigInt, c = a.length;
for (d = c,
e = 0; d > 0; d -= 4,
++e)
b.digits[e] = hexToDigit(a.substr(Math.max(d - 4, 0), Math.min(d, 4)));
return b
}
40、运行后报错
b.digits[e] = hexToDigit(a.substr(Math.max(d - 4, 0), Math.min(d, 4)));
^
ReferenceError: hexToDigit is not defined
41、去浏览器查看函数 hexToDigit,找到 hexToDigit 的来源
42、将函数 hexToDigit 复制到代码中
function hexToDigit(a) {
var d, b = 0, c = Math.min(a.length, 4);
for (d = 0; c > d; ++d)
b <<= 4,
b |= charToHex(a.charCodeAt(d));
return b
}
43、运行后报错
b <<= 4,
^
ReferenceError: charToHex is not defined
44、去浏览器查看函数 charToHex,找到 charToHex 的来源
45、将函数 charToHex 复制到代码中
function charToHex(a) {
var h, b = 48, c = b + 9, d = 97, e = d + 25, f = 65, g = 90;
return h = a >= b && c >= a ? a - b : a >= f && g >= a ? 10 + a - f : a >= d && e >= a ? 10 + a - d : 0
}
46、运行后报错
this.m = biFromHex(c),
^
ReferenceError: biHighIndex is not defined
47、去浏览器查看函数 biHighIndex,找到 biHighIndex 的来源
48、将函数 biHighIndex 复制到代码中
function biHighIndex(a) {
for (var b = a.digits.length - 1; b > 0 && 0 == a.digits[b]; )
--b;
return b
}
49、运行后报错
this.barrett = new BarrettMu(this.m)
^
ReferenceError: BarrettMu is not defined
50、去浏览器查看函数 BarrettMu,找到 BarrettMu 的来源
51、将函数 BarrettMu 复制到代码中
function BarrettMu(a) {
this.modulus = biCopy(a),
this.k = biHighIndex(this.modulus) + 1;
var b = new BigInt;
b.digits[2 * this.k] = 1,
this.mu = biDivide(b, this.modulus),
this.bkplus1 = new BigInt,
this.bkplus1.digits[this.k + 1] = 1,
this.modulo = BarrettMu_modulo,
this.multiplyMod = BarrettMu_multiplyMod,
this.powMod = BarrettMu_powMod
}
52、运行后报错
this.modulus = biCopy(a),
^
ReferenceError: biCopy is not defined
53、去浏览器查看函数 biCopy,找到 biCopy 的来源
54、将函数 biCopy 复制到代码中
function biCopy(a) {
var b = new BigInt(!0);
return b.digits = a.digits.slice(0),
b.isNeg = a.isNeg,
b
}
55、运行后报错
b.digits[2 * this.k] = 1,
^
ReferenceError: biDivide is not defined
56、去浏览器查看函数 biDivide,找到 biDivide 的来源
57、将函数 biDivide 复制到代码中
function biDivide(a, b) {
return biDivideModulo(a, b)[0]
}
58、运行后报错
return biDivideModulo(a, b)[0]
^
ReferenceError: biDivideModulo is not defined
59、去浏览器查看函数 biDivideModulo,找到 biDivideModulo 的来源
60、将函数 biDivideModulo 复制到代码中
function biDivideModulo(a, b) {
var f, g, h, i, j, k, l, m, n, o, p, q, r, s, c = biNumBits(a), d = biNumBits(b), e = b.isNeg;
if (d > c)
return a.isNeg ? (f = biCopy(bigOne),
f.isNeg = !b.isNeg,
a.isNeg = !1,
b.isNeg = !1,
g = biSubtract(b, a),
a.isNeg = !0,
b.isNeg = e) : (f = new BigInt,
g = biCopy(a)),
new Array(f,g);
for (f = new BigInt,
g = a,
h = Math.ceil(d / bitsPerDigit) - 1,
i = 0; b.digits[h] < biHalfRadix; )
b = biShiftLeft(b, 1),
++i,
++d,
h = Math.ceil(d / bitsPerDigit) - 1;
for (g = biShiftLeft(g, i),
c += i,
j = Math.ceil(c / bitsPerDigit) - 1,
k = biMultiplyByRadixPower(b, j - h); -1 != biCompare(g, k); )
++f.digits[j - h],
g = biSubtract(g, k);
for (l = j; l > h; --l) {
for (m = l >= g.digits.length ? 0 : g.digits[l],
n = l - 1 >= g.digits.length ? 0 : g.digits[l - 1],
o = l - 2 >= g.digits.length ? 0 : g.digits[l - 2],
p = h >= b.digits.length ? 0 : b.digits[h],
q = h - 1 >= b.digits.length ? 0 : b.digits[h - 1],
f.digits[l - h - 1] = m == p ? maxDigitVal : Math.floor((m * biRadix + n) / p),
r = f.digits[l - h - 1] * (p * biRadix + q),
s = m * biRadixSquared + (n * biRadix + o); r > s; )
--f.digits[l - h - 1],
r = f.digits[l - h - 1] * (p * biRadix | q),
s = m * biRadix * biRadix + (n * biRadix + o);
k = biMultiplyByRadixPower(b, l - h - 1),
g = biSubtract(g, biMultiplyDigit(k, f.digits[l - h - 1])),
g.isNeg && (g = biAdd(g, k),
--f.digits[l - h - 1])
}
return g = biShiftRight(g, i),
f.isNeg = a.isNeg != e,
a.isNeg && (f = e ? biAdd(f, bigOne) : biSubtract(f, bigOne),
b = biShiftRight(b, i),
g = biSubtract(b, g)),
0 == g.digits[0] && 0 == biHighIndex(g) && (g.isNeg = !1),
new Array(f,g)
}
61、运行后报错
var f, g, h, i, j, k, l, m, n, o, p, q, r, s, c = biNumBits(a), d = biNumBits(b), e = b.isNeg;
^
ReferenceError: biNumBits is not defined
62、去浏览器查看函数 biNumBits,找到 biNumBits 的来源
63、将函数 biNumBits 复制到代码中
function biNumBits(a) {
var e, b = biHighIndex(a), c = a.digits[b], d = (b + 1) * bitsPerDigit;
for (e = d; e > d - bitsPerDigit && 0 == (32768 & c); --e)
c <<= 1;
return e
}
64、运行后报错
var e, b = biHighIndex(a), c = a.digits[b], d = (b + 1) * bitsPerDigit;
^
ReferenceError: bitsPerDigit is not defined
65、去浏览器查看 bitsPerDigit 值
66、将 bitsPerDigit 值复制到代码中
var bitsPerDigit = 16
67、运行后报错
i = 0; b.digits[h] < biHalfRadix; )
^
ReferenceError: biHalfRadix is not defined
68、去浏览器查看 biHalfRadix 值
69、将 biHalfRadix 值复制到代码中
var biHalfRadix = 32768
70、运行后报错
for (g = biShiftLeft(g, i),
^
ReferenceError: biShiftLeft is not defined
71、去浏览器查看函数 biShiftLeft,找到 biShiftLeft 的来源
72、将函数 biShiftLeft 复制到代码中
function biShiftLeft(a, b) {
var e, f, g, h, c = Math.floor(b / bitsPerDigit), d = new BigInt;
for (arrayCopy(a.digits, 0, d.digits, c, d.digits.length - c),
e = b % bitsPerDigit,
f = bitsPerDigit - e,
g = d.digits.length - 1,
h = g - 1; g > 0; --g,
--h)
d.digits[g] = d.digits[g] << e & maxDigitVal | (d.digits[h] & highBitMasks[e]) >>> f;
return d.digits[0] = d.digits[g] << e & maxDigitVal,
d.isNeg = a.isNeg,
d
}
73、运行后报错
for (arrayCopy(a.digits, 0, d.digits, c, d.digits.length - c),
^
ReferenceError: arrayCopy is not defined
74、去浏览器查看函数 arrayCopy,找到 arrayCopy 的来源
75、将函数 arrayCopy 复制到代码中
function arrayCopy(a, b, c, d, e) {
var g, h, f = Math.min(b + e, a.length);
for (g = b,
h = d; f > g; ++g,
++h)
c[h] = a[g]
}
76、运行后报错
d.digits[g] = d.digits[g] << e & maxDigitVal | (d.digits[h] & highBitMasks[e]) >>> f;
^
ReferenceError: maxDigitVal is not defined
77、去浏览器查看 maxDigitVal 值
78、将 maxDigitVal 值复制到代码中
var maxDigitVal = 65535
79、运行后报错
d.digits[g] = d.digits[g] << e & maxDigitVal | (d.digits[h] & highBitMasks[e]) >>> f;
^
ReferenceError: highBitMasks is not defined
80、去浏览器查看 highBitMasks 值
81、将 highBitMasks 值复制到代码中
var highBitMasks = [0, 32768, 49152, 57344, 61440, 63488, 64512, 65024, 65280, 65408, 65472, 65504, 65520, 65528, 65532, 65534, 65535]
82、运行后报错
j = Math.ceil(c / bitsPerDigit) - 1,
^
ReferenceError: biMultiplyByRadixPower is not defined
83、去浏览器查看函数 biMultiplyByRadixPower,找到 biMultiplyByRadixPower 的来源
84、将函数 biMultiplyByRadixPower 复制到代码中
function biMultiplyByRadixPower(a, b) {
var c = new BigInt;
return arrayCopy(a.digits, 0, c.digits, b, c.digits.length - b),
c
}
85、运行后报错
k = biMultiplyByRadixPower(b, j - h); -1 != biCompare(g, k); )
^
ReferenceError: biCompare is not defined
86、去浏览器查看函数 biCompare,找到 biCompare 的来源
87、将函数 biCompare 复制到代码中
function biCompare(a, b) {
if (a.isNeg != b.isNeg)
return 1 - 2 * Number(a.isNeg);
for (var c = a.digits.length - 1; c >= 0; --c)
if (a.digits[c] != b.digits[c])
return a.isNeg ? 1 - 2 * Number(a.digits[c] > b.digits[c]) : 1 - 2 * Number(a.digits[c] < b.digits[c]);
return 0
}
88、运行后报错
f.digits[l - h - 1] = m == p ? maxDigitVal : Math.floor((m * biRadix + n) / p),
^
ReferenceError: biRadix is not defined
89、去浏览器查看 biRadix 值
90、将 biRadix 值复制到代码中
var biRadix = 65536
91、运行后报错
s = m * biRadixSquared + (n * biRadix + o); r > s; )
^
ReferenceError: biRadixSquared is not defined
92、去浏览器查看 biRadixSquared 值
93、将 biRadixSquared 值复制到代码中
var biRadixSquared = 4294967296
94、运行后报错
k = biMultiplyByRadixPower(b, l - h - 1),
^
ReferenceError: biSubtract is not defined
95、去浏览器查看函数 biSubtract,找到 biSubtract 的来源
96、将函数 biSubtract 复制到代码中
function biSubtract(a, b) {
var c, d, e, f;
if (a.isNeg != b.isNeg)
b.isNeg = !b.isNeg,
c = biAdd(a, b),
b.isNeg = !b.isNeg;
else {
for (c = new BigInt,
e = 0,
f = 0; f < a.digits.length; ++f)
d = a.digits[f] - b.digits[f] + e,
c.digits[f] = 65535 & d,
c.digits[f] < 0 && (c.digits[f] += biRadix),
e = 0 - Number(0 > d);
if (-1 == e) {
for (e = 0,
f = 0; f < a.digits.length; ++f)
d = 0 - c.digits[f] + e,
c.digits[f] = 65535 & d,
c.digits[f] < 0 && (c.digits[f] += biRadix),
e = 0 - Number(0 > d);
c.isNeg = !a.isNeg
} else
c.isNeg = a.isNeg
}
return c
}
97、运行后报错
g = biSubtract(g, biMultiplyDigit(k, f.digits[l - h - 1])),
^
ReferenceError: biMultiplyDigit is not defined
98、去浏览器查看函数 biMultiplyDigit,找到 biMultiplyDigit 的来源
99、将函数 biMultiplyDigit 复制到代码中
function biMultiplyDigit(a, b) {
var c, d, e, f;
for (result = new BigInt,
c = biHighIndex(a),
d = 0,
f = 0; c >= f; ++f)
e = result.digits[f] + a.digits[f] * b + d,
result.digits[f] = e & maxDigitVal,
d = e >>> biRadixBits;
return result.digits[1 + c] = d,
result
}
100、运行后报错
d = e >>> biRadixBits;
^
ReferenceError: biRadixBits is not defined
101、去浏览器查看 biRadixBits 值
102、将 biRadixBits 值复制到代码中
var biRadixBits = 16
103、运行后报错
return g = biShiftRight(g, i),
^
ReferenceError: biShiftRight is not defined
104、去浏览器查看函数 biShiftRight,找到 biShiftRight 的来源
105、将函数 biShiftRight 复制到代码中
function biShiftRight(a, b) {
var e, f, g, h, c = Math.floor(b / bitsPerDigit), d = new BigInt;
for (arrayCopy(a.digits, c, d.digits, 0, a.digits.length - c),
e = b % bitsPerDigit,
f = bitsPerDigit - e,
g = 0,
h = g + 1; g < d.digits.length - 1; ++g,
++h)
d.digits[g] = d.digits[g] >>> e | (d.digits[h] & lowBitMasks[e]) << f;
return d.digits[d.digits.length - 1] >>>= e,
d.isNeg = a.isNeg,
d
}
106、运行后报错
d.digits[g] = d.digits[g] >>> e | (d.digits[h] & lowBitMasks[e]) << f;
^
ReferenceError: lowBitMasks is not defined
107、去浏览器查看 lowBitMasks 值
108、将 lowBitMasks 值复制到代码中
var lowBitMasks = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]
109、运行后报错
this.modulo = BarrettMu_modulo,
^
ReferenceError: BarrettMu_modulo is not defined
110、去浏览器查看函数 BarrettMu_modulo,找到 BarrettMu_modulo 的来源
111、将函数 BarrettMu_modulo 复制到代码中
function BarrettMu_modulo(a) {
var i, b = biDivideByRadixPower(a, this.k - 1), c = biMultiply(b, this.mu), d = biDivideByRadixPower(c, this.k + 1), e = biModuloByRadixPower(a, this.k + 1), f = biMultiply(d, this.modulus), g = biModuloByRadixPower(f, this.k + 1), h = biSubtract(e, g);
for (h.isNeg && (h = biAdd(h, this.bkplus1)),
i = biCompare(h, this.modulus) >= 0; i; )
h = biSubtract(h, this.modulus),
i = biCompare(h, this.modulus) >= 0;
return h
}
112、运行后报错
this.multiplyMod = BarrettMu_multiplyMod,
^
ReferenceError: BarrettMu_multiplyMod is not defined
113、去浏览器查看函数 BarrettMu_multiplyMod,找到 BarrettMu_multiplyMod 的来源
114、将函数 BarrettMu_multiplyMod 复制到代码中
function BarrettMu_multiplyMod(a, b) {
var c = biMultiply(a, b);
return this.modulo(c)
}
115、运行后报错
this.powMod = BarrettMu_powMod
^
ReferenceError: BarrettMu_powMod is not defined
116、去浏览器查看函数 BarrettMu_powMod,找到 BarrettMu_powMod 的来源
117、将函数 BarrettMu_powMod 复制到代码中
function BarrettMu_powMod(a, b) {
var d, e, c = new BigInt;
for (c.digits[0] = 1,
d = a,
e = b; ; ) {
if (0 != (1 & e.digits[0]) && (c = this.multiplyMod(c, d)),
e = biShiftRight(e, 1),
0 == e.digits[0] && 0 == biHighIndex(e))
break;
d = this.multiplyMod(d, d)
}
return c
}
118、运行后报错
d = new RSAKeyPair(b,"",c),
^
ReferenceError: encryptedString is not defined
119、去浏览器查看函数 encryptedString,找到 encryptedString 的来源
120、将函数 encryptedString 复制到代码中
function encryptedString(a, b) {
for (var f, g, h, i, j, k, l, c = new Array, d = b.length, e = 0; d > e; )
c[e] = b.charCodeAt(e),
e++;
for (; 0 != c.length % a.chunkSize; )
c[e++] = 0;
for (f = c.length,
g = "",
e = 0; f > e; e += a.chunkSize) {
for (j = new BigInt,
h = 0,
i = e; i < e + a.chunkSize; ++h)
j.digits[h] = c[i++],
j.digits[h] += c[i++] << 8;
k = a.barrett.powMod(j, a.e),
l = 16 == a.radix ? biToHex(k) : biToString(k, a.radix),
g += l + " "
}
return g.substring(0, g.length - 1)
}
121、运行后报错
var c = biMultiply(a, b);
^
ReferenceError: biMultiply is not defined
122、去浏览器查看函数 biMultiply,找到 biMultiply 的来源
123、将函数 biMultiply 复制到代码中
function biMultiply(a, b) {
var d, h, i, k, c = new BigInt, e = biHighIndex(a), f = biHighIndex(b);
for (k = 0; f >= k; ++k) {
for (d = 0,
i = k,
j = 0; e >= j; ++j,
++i)
h = c.digits[i] + a.digits[j] * b.digits[k] + d,
c.digits[i] = h & maxDigitVal,
d = h >>> biRadixBits;
c.digits[k + e + 1] = d
}
return c.isNeg = a.isNeg != b.isNeg,
c
}
124、运行后报错
var i, b = biDivideByRadixPower(a, this.k - 1), c = biMultiply(b, this.mu), d = biDivideByRadixPower(c, this.k + 1), e = biModuloByRadixPower(a, this.k + 1), f = biMultiply(d, this.modulus), g = biModuloByRadixPower(f, this.k + 1), h = biSubtract(e, g);
^
ReferenceError: biDivideByRadixPower is not defined
125、去浏览器查看函数 biDivideByRadixPower,找到 biDivideByRadixPower 的来源
126、将函数 biDivideByRadixPower 复制到代码中
function biDivideByRadixPower(a, b) {
var c = new BigInt;
return arrayCopy(a.digits, b, c.digits, 0, c.digits.length - b),
c
}
127、运行后报错
var i, b = biDivideByRadixPower(a, this.k - 1), c = biMultiply(b, this.mu), d = biDivideByRadixPower(c, this.k + 1), e = biModuloByRadixPower(a, this.k + 1), f = biMultiply(d, this.modulus), g = biModuloByRadixPower(f, this.k + 1), h = biSubtract(e, g);
^
ReferenceError: biModuloByRadixPower is not defined
128、去浏览器查看函数 biModuloByRadixPower,找到 biModuloByRadixPower 的来源
129、将函数 biModuloByRadixPower 复制到代码中
function biModuloByRadixPower(a, b) {
var c = new BigInt;
return arrayCopy(a.digits, 0, c.digits, 0, b),
c
}
130、运行后报错
l = 16 == a.radix ? biToHex(k) : biToString(k, a.radix),
^
ReferenceError: biToHex is not defined
131、去浏览器查看函数 biToHex,找到 biToHex 的来源
132、将函数 biToHex 复制到代码中
function biToHex(a) {
var d, b = "";
for (biHighIndex(a),
d = biHighIndex(a); d > -1; --d)
b += digitToHex(a.digits[d]);
return b
}
133、运行后报错
b += digitToHex(a.digits[d]);
^
ReferenceError: digitToHex is not defined
134、去浏览器查看函数 digitToHex,找到 digitToHex 的来源
135、将函数 digitToHex 复制到代码中
function digitToHex(a) {
var b = 15
, c = "";
for (i = 0; 4 > i; ++i)
c += hexToChar[a & b],
a >>>= 4;
return reverseStr(c)
}
136、运行后报错
c += hexToChar[a & b],
^
ReferenceError: hexToChar is not defined
137、去浏览器查看 hexToChar 值
138、将 hexToChar 值复制到代码中
var hexToChar = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
139、运行后报错
return reverseStr(c)
^
ReferenceError: reverseStr is not defined
140、去浏览器查看函数 reverseStr,找到 reverseStr 的来源
140、将函数 reverseStr 复制到代码中
function reverseStr(a) {
var c, b = "";
for (c = a.length - 1; c > -1; --c)
b += a.charAt(c);
return b
}
141、整体代码
// wyyJs.js
var e = '010001'
var f = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
var g = '0CoJUm6Qyw8W8jud'
var bitsPerDigit = 16
var biHalfRadix = 32768
var maxDigitVal = 65535
var highBitMasks = [0, 32768, 49152, 57344, 61440, 63488, 64512, 65024, 65280, 65408, 65472, 65504, 65520, 65528, 65532, 65534, 65535]
var biRadix = 65536
var biRadixSquared = 4294967296
var biRadixBits = 16
var lowBitMasks = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]
var hexToChar = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
const CryptoJS = require('crypto-js')
function reverseStr(a) {
var c, b = "";
for (c = a.length - 1; c > -1; --c)
b += a.charAt(c);
return b
}
function digitToHex(a) {
var b = 15
, c = "";
for (i = 0; 4 > i; ++i)
c += hexToChar[a & b],
a >>>= 4;
return reverseStr(c)
}
function biToHex(a) {
var d, b = "";
for (biHighIndex(a),
d = biHighIndex(a); d > -1; --d)
b += digitToHex(a.digits[d]);
return b
}
function biModuloByRadixPower(a, b) {
var c = new BigInt;
return arrayCopy(a.digits, 0, c.digits, 0, b),
c
}
function biDivideByRadixPower(a, b) {
var c = new BigInt;
return arrayCopy(a.digits, b, c.digits, 0, c.digits.length - b),
c
}
function biMultiply(a, b) {
var d, h, i, k, c = new BigInt, e = biHighIndex(a), f = biHighIndex(b);
for (k = 0; f >= k; ++k) {
for (d = 0,
i = k,
j = 0; e >= j; ++j,
++i)
h = c.digits[i] + a.digits[j] * b.digits[k] + d,
c.digits[i] = h & maxDigitVal,
d = h >>> biRadixBits;
c.digits[k + e + 1] = d
}
return c.isNeg = a.isNeg != b.isNeg,
c
}
function encryptedString(a, b) {
for (var f, g, h, i, j, k, l, c = new Array, d = b.length, e = 0; d > e; )
c[e] = b.charCodeAt(e),
e++;
for (; 0 != c.length % a.chunkSize; )
c[e++] = 0;
for (f = c.length,
g = "",
e = 0; f > e; e += a.chunkSize) {
for (j = new BigInt,
h = 0,
i = e; i < e + a.chunkSize; ++h)
j.digits[h] = c[i++],
j.digits[h] += c[i++] << 8;
k = a.barrett.powMod(j, a.e),
l = 16 == a.radix ? biToHex(k) : biToString(k, a.radix),
g += l + " "
}
return g.substring(0, g.length - 1)
}
function BarrettMu_powMod(a, b) {
var d, e, c = new BigInt;
for (c.digits[0] = 1,
d = a,
e = b; ; ) {
if (0 != (1 & e.digits[0]) && (c = this.multiplyMod(c, d)),
e = biShiftRight(e, 1),
0 == e.digits[0] && 0 == biHighIndex(e))
break;
d = this.multiplyMod(d, d)
}
return c
}
function BarrettMu_multiplyMod(a, b) {
var c = biMultiply(a, b);
return this.modulo(c)
}
function BarrettMu_modulo(a) {
var i, b = biDivideByRadixPower(a, this.k - 1), c = biMultiply(b, this.mu), d = biDivideByRadixPower(c, this.k + 1), e = biModuloByRadixPower(a, this.k + 1), f = biMultiply(d, this.modulus), g = biModuloByRadixPower(f, this.k + 1), h = biSubtract(e, g);
for (h.isNeg && (h = biAdd(h, this.bkplus1)),
i = biCompare(h, this.modulus) >= 0; i; )
h = biSubtract(h, this.modulus),
i = biCompare(h, this.modulus) >= 0;
return h
}
function biShiftRight(a, b) {
var e, f, g, h, c = Math.floor(b / bitsPerDigit), d = new BigInt;
for (arrayCopy(a.digits, c, d.digits, 0, a.digits.length - c),
e = b % bitsPerDigit,
f = bitsPerDigit - e,
g = 0,
h = g + 1; g < d.digits.length - 1; ++g,
++h)
d.digits[g] = d.digits[g] >>> e | (d.digits[h] & lowBitMasks[e]) << f;
return d.digits[d.digits.length - 1] >>>= e,
d.isNeg = a.isNeg,
d
}
function biMultiplyDigit(a, b) {
var c, d, e, f;
for (result = new BigInt,
c = biHighIndex(a),
d = 0,
f = 0; c >= f; ++f)
e = result.digits[f] + a.digits[f] * b + d,
result.digits[f] = e & maxDigitVal,
d = e >>> biRadixBits;
return result.digits[1 + c] = d,
result
}
function biSubtract(a, b) {
var c, d, e, f;
if (a.isNeg != b.isNeg)
b.isNeg = !b.isNeg,
c = biAdd(a, b),
b.isNeg = !b.isNeg;
else {
for (c = new BigInt,
e = 0,
f = 0; f < a.digits.length; ++f)
d = a.digits[f] - b.digits[f] + e,
c.digits[f] = 65535 & d,
c.digits[f] < 0 && (c.digits[f] += biRadix),
e = 0 - Number(0 > d);
if (-1 == e) {
for (e = 0,
f = 0; f < a.digits.length; ++f)
d = 0 - c.digits[f] + e,
c.digits[f] = 65535 & d,
c.digits[f] < 0 && (c.digits[f] += biRadix),
e = 0 - Number(0 > d);
c.isNeg = !a.isNeg
} else
c.isNeg = a.isNeg
}
return c
}
function biCompare(a, b) {
if (a.isNeg != b.isNeg)
return 1 - 2 * Number(a.isNeg);
for (var c = a.digits.length - 1; c >= 0; --c)
if (a.digits[c] != b.digits[c])
return a.isNeg ? 1 - 2 * Number(a.digits[c] > b.digits[c]) : 1 - 2 * Number(a.digits[c] < b.digits[c]);
return 0
}
function biMultiplyByRadixPower(a, b) {
var c = new BigInt;
return arrayCopy(a.digits, 0, c.digits, b, c.digits.length - b),
c
}
function arrayCopy(a, b, c, d, e) {
var g, h, f = Math.min(b + e, a.length);
for (g = b,
h = d; f > g; ++g,
++h)
c[h] = a[g]
}
function biShiftLeft(a, b) {
var e, f, g, h, c = Math.floor(b / bitsPerDigit), d = new BigInt;
for (arrayCopy(a.digits, 0, d.digits, c, d.digits.length - c),
e = b % bitsPerDigit,
f = bitsPerDigit - e,
g = d.digits.length - 1,
h = g - 1; g > 0; --g,
--h)
d.digits[g] = d.digits[g] << e & maxDigitVal | (d.digits[h] & highBitMasks[e]) >>> f;
return d.digits[0] = d.digits[g] << e & maxDigitVal,
d.isNeg = a.isNeg,
d
}
function biNumBits(a) {
var e, b = biHighIndex(a), c = a.digits[b], d = (b + 1) * bitsPerDigit;
for (e = d; e > d - bitsPerDigit && 0 == (32768 & c); --e)
c <<= 1;
return e
}
function biDivideModulo(a, b) {
var f, g, h, i, j, k, l, m, n, o, p, q, r, s, c = biNumBits(a), d = biNumBits(b), e = b.isNeg;
if (d > c)
return a.isNeg ? (f = biCopy(bigOne),
f.isNeg = !b.isNeg,
a.isNeg = !1,
b.isNeg = !1,
g = biSubtract(b, a),
a.isNeg = !0,
b.isNeg = e) : (f = new BigInt,
g = biCopy(a)),
new Array(f,g);
for (f = new BigInt,
g = a,
h = Math.ceil(d / bitsPerDigit) - 1,
i = 0; b.digits[h] < biHalfRadix; )
b = biShiftLeft(b, 1),
++i,
++d,
h = Math.ceil(d / bitsPerDigit) - 1;
for (g = biShiftLeft(g, i),
c += i,
j = Math.ceil(c / bitsPerDigit) - 1,
k = biMultiplyByRadixPower(b, j - h); -1 != biCompare(g, k); )
++f.digits[j - h],
g = biSubtract(g, k);
for (l = j; l > h; --l) {
for (m = l >= g.digits.length ? 0 : g.digits[l],
n = l - 1 >= g.digits.length ? 0 : g.digits[l - 1],
o = l - 2 >= g.digits.length ? 0 : g.digits[l - 2],
p = h >= b.digits.length ? 0 : b.digits[h],
q = h - 1 >= b.digits.length ? 0 : b.digits[h - 1],
f.digits[l - h - 1] = m == p ? maxDigitVal : Math.floor((m * biRadix + n) / p),
r = f.digits[l - h - 1] * (p * biRadix + q),
s = m * biRadixSquared + (n * biRadix + o); r > s; )
--f.digits[l - h - 1],
r = f.digits[l - h - 1] * (p * biRadix | q),
s = m * biRadix * biRadix + (n * biRadix + o);
k = biMultiplyByRadixPower(b, l - h - 1),
g = biSubtract(g, biMultiplyDigit(k, f.digits[l - h - 1])),
g.isNeg && (g = biAdd(g, k),
--f.digits[l - h - 1])
}
return g = biShiftRight(g, i),
f.isNeg = a.isNeg != e,
a.isNeg && (f = e ? biAdd(f, bigOne) : biSubtract(f, bigOne),
b = biShiftRight(b, i),
g = biSubtract(b, g)),
0 == g.digits[0] && 0 == biHighIndex(g) && (g.isNeg = !1),
new Array(f,g)
}
function biDivide(a, b) {
return biDivideModulo(a, b)[0]
}
function biCopy(a) {
var b = new BigInt(!0);
return b.digits = a.digits.slice(0),
b.isNeg = a.isNeg,
b
}
function BarrettMu(a) {
this.modulus = biCopy(a),
this.k = biHighIndex(this.modulus) + 1;
var b = new BigInt;
b.digits[2 * this.k] = 1,
this.mu = biDivide(b, this.modulus),
this.bkplus1 = new BigInt,
this.bkplus1.digits[this.k + 1] = 1,
this.modulo = BarrettMu_modulo,
this.multiplyMod = BarrettMu_multiplyMod,
this.powMod = BarrettMu_powMod
}
function biHighIndex(a) {
for (var b = a.digits.length - 1; b > 0 && 0 == a.digits[b]; )
--b;
return b
}
function charToHex(a) {
var h, b = 48, c = b + 9, d = 97, e = d + 25, f = 65, g = 90;
return h = a >= b && c >= a ? a - b : a >= f && g >= a ? 10 + a - f : a >= d && e >= a ? 10 + a - d : 0
}
function hexToDigit(a) {
var d, b = 0, c = Math.min(a.length, 4);
for (d = 0; c > d; ++d)
b <<= 4,
b |= charToHex(a.charCodeAt(d));
return b
}
function biFromHex(a) {
var d, e, b = new BigInt, c = a.length;
for (d = c,
e = 0; d > 0; d -= 4,
++e)
b.digits[e] = hexToDigit(a.substr(Math.max(d - 4, 0), Math.min(d, 4)));
return b
}
function RSAKeyPair(a, b, c) {
this.e = biFromHex(a),
this.d = biFromHex(b),
this.m = biFromHex(c),
this.chunkSize = 2 * biHighIndex(this.m),
this.radix = 16,
this.barrett = new BarrettMu(this.m)
}
function BigInt(a) {
this.digits = "boolean" == typeof a && 1 == a ? null : ZERO_ARRAY.slice(0),
this.isNeg = !1
}
function setMaxDigits(a) {
maxDigits = a,
ZERO_ARRAY = new Array(maxDigits);
for (var b = 0; b < ZERO_ARRAY.length; b++)
ZERO_ARRAY[b] = 0;
bigZero = new BigInt,
bigOne = new BigInt,
bigOne.digits[0] = 1
}
function c(a, b, c) {
var d, e;
return setMaxDigits(131),
d = new RSAKeyPair(b,"",c),
e = encryptedString(d, a)
}
function b(a, b) {
var c = CryptoJS.enc.Utf8.parse(b)
, d = CryptoJS.enc.Utf8.parse("0102030405060708")
, e = CryptoJS.enc.Utf8.parse(a)
, f = CryptoJS.AES.encrypt(e, c, {
iv: d,
mode: CryptoJS.mode.CBC
});
return f.toString()
}
function a(a) {
var d, e, b = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", c = "";
for (d = 0; a > d; d += 1)
e = Math.random() * b.length,
e = Math.floor(e),
c += b.charAt(e);
return c
}
function d(d) {
var h = {}
, i = a(16);
return h.encText = b(d, g),
h.encText = b(h.encText, i),
h.encSecKey = c(i, e, f),
h
}
data = '{"rid":"R_SO_4_2054300084","threadId":"R_SO_4_2054300084","pageNo":"1","pageSize":"20","cursor":"-1","offset":"0","orderType":"1","csrf_token":""}'
console.log(d(data))
运行后得出
{
encText: 'V22v+tPx0AGcunKSQLZJXiQ2vVBAXx7bA4NEy35CO0AuP8yYhq6XWWq82P6r1yHw3CjqYi1wRcNbFeMjQWELI9eVINLiI1ggr9/g3Gj+WDxrZcB1Gv8/HHYxrTZBw8X+KBzM6gI9vY7KAP7GkC306+gcsXJSLkMeng3gnX0ahy3mGXObJi+/WdEcrKT6c6JevQPggDl/RYRtYrlMdlYVJywMU4Nulviszdi36Q4A9pV9KQBUw9/2mVVO2m76hC90KDGZbqCmGD3FhYWyffp6OFz7r4D05FUWIKAkjTdURWI=',
encSecKey: '60a3abf51cb6dfb5f8ce977b46c151dd6caed57cc7b61be391b6989f534704a44b658d46a3a19b543e392e4d2e9e2be2f4791238fb31c28fa1856ccb5d35bce17a6243863e89fb5f0800c2fb164e61ef6f725dc3759712df4286760f8d57778918d3795dd1528147e954dc7b607b573e1580ff91efb675ba2f7cb5556cdd4f29'
}
142、获取到参数之后,携带参数获取数据。
# 网易云爬取.py
import requests # 导入 requests 库,用于发送 HTTP 请求
from JsReverse import get_js # 导入自定义模块 JsReverse 中的 get_js 函数
# 传入 wyyJs.js 里的参数
data = '{"rid":"R_SO_4_2054300084","threadId":"R_SO_4_2054300084","pageNo":"1","pageSize":"20","cursor":"-1","offset":"0","orderType":"1","csrf_token":""}'
# 调用 get_js 函数,将文件路径、函数名和数据作为参数,获取返回的字典
data_dict = get_js('wyyJs.js', 'd', data)
# 打印获取的字典
print(data_dict)
# 创建一个空字典
dic = {}
# 传入网站的参数
dic['params'] = data_dict['encText']
dic['encSecKey'] = data_dict['encSecKey']
# 目标 url
url = 'https://music.163.com/weapi/comment/resource/comments/get?csrf_token='
# 请求头
head = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'
}
# 发送 POST 请求,传递参数 dic 和 headers,并获取响应对象
res = requests.post(url, data=dic, headers=head)
# 打印响应对象的文本内容
print(res.text)
# JsReverse.py
# 安装方法:pip install PyExecJs -i https://pypi.tuna.tsinghua.edu.cn/simple
import execjs # 用于执行 JavaScript 代码的库
# 定义函数
def get_js(js_path, fuc_name, func_args):
'''
:param js_path: js代码的文件路径
:param fuc_name: 调用的js函数名称
:param func_args: 传入的参数
:return:
'''
# 1. 读取 js 代码
with open(js_path, 'r', encoding='utf-8') as f:
js_code = f.read()
# 2. 编译 js 代码
cjs = execjs.compile(js_code)
# 3. 执行 js 代码,函数后面跟上一个参数
# print(fuc_name, func_args)
return cjs.call(fuc_name, func_args)
记录学习过程,欢迎讨论交流,尊重原创,转载请注明出处~