在一些平台,我们在拿数据的时候,都会遇需要逆向才能拿到数据,就比如某宝的卖家、买家平台,大部分是请求参数sign参数加密,那就以这个为例,我们用影刀RPA工具,结合python,js逆向,来开发一个通用的影刀RPA指令——生成某宝sign加密参数指令。这样我们不管是在某宝的卖家或者买家平台拿数据,遇到sign参数加密,直接调用这个指令就可以生成加密参数,减少我们逆向的次数。
我们随便打开某宝中的一个商品,查找接口发现,在请求参数中有一个sign的加密参数,
一般,在请求参数加密的,是把请求参数中的几个或全部作为传参传进加密函数生成sign(这里提一嘴,某物中的sign参数也是这个原理),如下图:
像这样,我们直接全局搜索sign: 或sign=,如下图:
然后发现,在搜索sign:时,发现一个可疑的地方,点开,发现是通过赋值给sign的,那这样,打断点调试,验证sign,发现正确。如下图:
sign是由l赋值的,所以我们往上面找到l,发现是一个函数,我们直接把这个函数扣下来
这个函数的传参为:r.token(cookie中拿),s(时间戳),o(常量),n.data(请求参数中的data),也刚好对应请求参数中的appkey, t, data,除了token是在cookie中拿。如下图:
拿下来的js代码经过修改如下:
s = "12574478"
l = (new Date).getTime()
data = "{\"id\":\"737587704463\",\"ali_refid\":\"a3_430582_1006:1680540096:N:LM6ng4O4SfOJxxIk9LoWfze4KqSTEy%2BhvN7l%2BES3tx0%3D:717688e1ff53d10b8ed95ed6a49903b2\",\"ali_trackid\":\"230_717688e1ff53d10b8ed95ed6a49903b2\",\"spm\":\"a21n57.1.0.0\",\"detail_v\":\"3.3.0\"}"
token = "0be2373e0c00b08d010ad71b4b99e9c5"
h1 = token + "&" + l + "&" + s + "&" + data
c = function(e) {
function t(e, t) {
return e << t | e >>> 32 - t
}
function n(e, t) {
var n, r, i, a, o;
return i = 2147483648 & e,
a = 2147483648 & t,
o = (1073741823 & e) + (1073741823 & t),
(n = 1073741824 & e) & (r = 1073741824 & t) ? 2147483648 ^ o ^ i ^ a : n | r ? 1073741824 & o ? 3221225472 ^ o ^ i ^ a : 1073741824 ^ o ^ i ^ a : o ^ i ^ a
}
function r(e, r, i, a, o, s, l) {
return e = n(e, n(n(function(e, t, n) {
return e & t | ~e & n
}(r, i, a), o), l)),
n(t(e, s), r)
}
function i(e, r, i, a, o, s, l) {
return e = n(e, n(n(function(e, t, n) {
return e & n | t & ~n
}(r, i, a), o), l)),
n(t(e, s), r)
}
function a(e, r, i, a, o, s, l) {
return e = n(e, n(n(function(e, t, n) {
return e ^ t ^ n
}(r, i, a), o), l)),
n(t(e, s), r)
}
function o(e, r, i, a, o, s, l) {
return e = n(e, n(n(function(e, t, n) {
return t ^ (e | ~n)
}(r, i, a), o), l)),
n(t(e, s), r)
}
function s(e) {
var t, n = "", r = "";
for (t = 0; 3 >= t; t++)
n += (r = "0" + (e >>> 8 * t & 255).toString(16)).substr(r.length - 2, 2);
return n
}
var l, c, p, u, d, f, m, g, h, v;
for (v = function(e) {
for (var t, n = e.length, r = n + 8, i = 16 * ((r - r % 64) / 64 + 1), a = new Array(i - 1), o = 0, s = 0; n > s; )
o = s % 4 * 8,
a[t = (s - s % 4) / 4] = a[t] | e.charCodeAt(s) << o,
s++;
return o = s % 4 * 8,
a[t = (s - s % 4) / 4] = a[t] | 128 << o,
a[i - 2] = n << 3,
a[i - 1] = n >>> 29,
a
}(e = function(e) {
e = e.replace(/\r\n/g, "\n");
for (var t = "", n = 0; n < e.length; n++) {
var r = e.charCodeAt(n);
128 > r ? t += String.fromCharCode(r) : r > 127 && 2048 > r ? (t += String.fromCharCode(r >> 6 | 192),
t += String.fromCharCode(63 & r | 128)) : (t += String.fromCharCode(r >> 12 | 224),
t += String.fromCharCode(r >> 6 & 63 | 128),
t += String.fromCharCode(63 & r | 128))
}
return t
}(e)),
f = 1732584193,
m = 4023233417,
g = 2562383102,
h = 271733878,
l = 0; l < v.length; l += 16)
c = f,
p = m,
u = g,
d = h,
f = r(f, m, g, h, v[l + 0], 7, 3614090360),
h = r(h, f, m, g, v[l + 1], 12, 3905402710),
g = r(g, h, f, m, v[l + 2], 17, 606105819),
m = r(m, g, h, f, v[l + 3], 22, 3250441966),
f = r(f, m, g, h, v[l + 4], 7, 4118548399),
h = r(h, f, m, g, v[l + 5], 12, 1200080426),
g = r(g, h, f, m, v[l + 6], 17, 2821735955),
m = r(m, g, h, f, v[l + 7], 22, 4249261313),
f = r(f, m, g, h, v[l + 8], 7, 1770035416),
h = r(h, f, m, g, v[l + 9], 12, 2336552879),
g = r(g, h, f, m, v[l + 10], 17, 4294925233),
m = r(m, g, h, f, v[l + 11], 22, 2304563134),
f = r(f, m, g, h, v[l + 12], 7, 1804603682),
h = r(h, f, m, g, v[l + 13], 12, 4254626195),
g = r(g, h, f, m, v[l + 14], 17, 2792965006),
f = i(f, m = r(m, g, h, f, v[l + 15], 22, 1236535329), g, h, v[l + 1], 5, 4129170786),
h = i(h, f, m, g, v[l + 6], 9, 3225465664),
g = i(g, h, f, m, v[l + 11], 14, 643717713),
m = i(m, g, h, f, v[l + 0], 20, 3921069994),
f = i(f, m, g, h, v[l + 5], 5, 3593408605),
h = i(h, f, m, g, v[l + 10], 9, 38016083),
g = i(g, h, f, m, v[l + 15], 14, 3634488961),
m = i(m, g, h, f, v[l + 4], 20, 3889429448),
f = i(f, m, g, h, v[l + 9], 5, 568446438),
h = i(h, f, m, g, v[l + 14], 9, 3275163606),
g = i(g, h, f, m, v[l + 3], 14, 4107603335),
m = i(m, g, h, f, v[l + 8], 20, 1163531501),
f = i(f, m, g, h, v[l + 13], 5, 2850285829),
h = i(h, f, m, g, v[l + 2], 9, 4243563512),
g = i(g, h, f, m, v[l + 7], 14, 1735328473),
f = a(f, m = i(m, g, h, f, v[l + 12], 20, 2368359562), g, h, v[l + 5], 4, 4294588738),
h = a(h, f, m, g, v[l + 8], 11, 2272392833),
g = a(g, h, f, m, v[l + 11], 16, 1839030562),
m = a(m, g, h, f, v[l + 14], 23, 4259657740),
f = a(f, m, g, h, v[l + 1], 4, 2763975236),
h = a(h, f, m, g, v[l + 4], 11, 1272893353),
g = a(g, h, f, m, v[l + 7], 16, 4139469664),
m = a(m, g, h, f, v[l + 10], 23, 3200236656),
f = a(f, m, g, h, v[l + 13], 4, 681279174),
h = a(h, f, m, g, v[l + 0], 11, 3936430074),
g = a(g, h, f, m, v[l + 3], 16, 3572445317),
m = a(m, g, h, f, v[l + 6], 23, 76029189),
f = a(f, m, g, h, v[l + 9], 4, 3654602809),
h = a(h, f, m, g, v[l + 12], 11, 3873151461),
g = a(g, h, f, m, v[l + 15], 16, 530742520),
f = o(f, m = a(m, g, h, f, v[l + 2], 23, 3299628645), g, h, v[l + 0], 6, 4096336452),
h = o(h, f, m, g, v[l + 7], 10, 1126891415),
g = o(g, h, f, m, v[l + 14], 15, 2878612391),
m = o(m, g, h, f, v[l + 5], 21, 4237533241),
f = o(f, m, g, h, v[l + 12], 6, 1700485571),
h = o(h, f, m, g, v[l + 3], 10, 2399980690),
g = o(g, h, f, m, v[l + 10], 15, 4293915773),
m = o(m, g, h, f, v[l + 1], 21, 2240044497),
f = o(f, m, g, h, v[l + 8], 6, 1873313359),
h = o(h, f, m, g, v[l + 15], 10, 4264355552),
g = o(g, h, f, m, v[l + 6], 15, 2734768916),
m = o(m, g, h, f, v[l + 13], 21, 1309151649),
f = o(f, m, g, h, v[l + 4], 6, 4149444226),
h = o(h, f, m, g, v[l + 11], 10, 3174756917),
g = o(g, h, f, m, v[l + 2], 15, 718787259),
m = o(m, g, h, f, v[l + 9], 21, 3951481745),
f = n(f, c),
m = n(m, p),
g = n(g, u),
h = n(h, d);
return (s(f) + s(m) + s(g) + s(h)).toLowerCase()
}(h1)
console.log(c)
运行结果如下:
可以发现这就是我们需要的的js文件了
我们在影刀RPA里面编写调用我们刚才导入的js文件,然后把参数准备好,传进去,验证我们的结果:
接下来是封装成指令,我们只要把设置的变量改为入参就行,如下图:
以上操作完成后,我们发版这个指令集,然后创建应用来验证我们的结果。
这里,我新建了一个影刀应用(淘宝),可以看到,在Tool指令集下有我们开发的生成sign指令
我随便在淘宝里找一个商品,查看它的信息:
我直接把data和 t 拿下来传进去,token我就直接去cookie里面那了,这里我就不演示了,如下图:
我们直接对比我们生成的sign和原来的sign:
可以看到,一模一样,OK 到这里,我们开发一个生成加密参数sign指令就完成了。如果有时间,我会在写一篇生成得物sign的指令。。。