当前位置:   article > 正文

python结合js逆向与影刀RPA——开发影刀指令(生成淘宝sign加密参数)_淘宝sign参数

淘宝sign参数

        在一些平台,我们在拿数据的时候,都会遇需要逆向才能拿到数据,就比如某宝的卖家、买家平台,大部分是请求参数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代码经过修改如下: 

  1. s = "12574478"
  2. l = (new Date).getTime()
  3. 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\"}"
  4. token = "0be2373e0c00b08d010ad71b4b99e9c5"
  5. h1 = token + "&" + l + "&" + s + "&" + data
  6. c = function(e) {
  7. function t(e, t) {
  8. return e << t | e >>> 32 - t
  9. }
  10. function n(e, t) {
  11. var n, r, i, a, o;
  12. return i = 2147483648 & e,
  13. a = 2147483648 & t,
  14. o = (1073741823 & e) + (1073741823 & t),
  15. (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
  16. }
  17. function r(e, r, i, a, o, s, l) {
  18. return e = n(e, n(n(function(e, t, n) {
  19. return e & t | ~e & n
  20. }(r, i, a), o), l)),
  21. n(t(e, s), r)
  22. }
  23. function i(e, r, i, a, o, s, l) {
  24. return e = n(e, n(n(function(e, t, n) {
  25. return e & n | t & ~n
  26. }(r, i, a), o), l)),
  27. n(t(e, s), r)
  28. }
  29. function a(e, r, i, a, o, s, l) {
  30. return e = n(e, n(n(function(e, t, n) {
  31. return e ^ t ^ n
  32. }(r, i, a), o), l)),
  33. n(t(e, s), r)
  34. }
  35. function o(e, r, i, a, o, s, l) {
  36. return e = n(e, n(n(function(e, t, n) {
  37. return t ^ (e | ~n)
  38. }(r, i, a), o), l)),
  39. n(t(e, s), r)
  40. }
  41. function s(e) {
  42. var t, n = "", r = "";
  43. for (t = 0; 3 >= t; t++)
  44. n += (r = "0" + (e >>> 8 * t & 255).toString(16)).substr(r.length - 2, 2);
  45. return n
  46. }
  47. var l, c, p, u, d, f, m, g, h, v;
  48. for (v = function(e) {
  49. 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; )
  50. o = s % 4 * 8,
  51. a[t = (s - s % 4) / 4] = a[t] | e.charCodeAt(s) << o,
  52. s++;
  53. return o = s % 4 * 8,
  54. a[t = (s - s % 4) / 4] = a[t] | 128 << o,
  55. a[i - 2] = n << 3,
  56. a[i - 1] = n >>> 29,
  57. a
  58. }(e = function(e) {
  59. e = e.replace(/\r\n/g, "\n");
  60. for (var t = "", n = 0; n < e.length; n++) {
  61. var r = e.charCodeAt(n);
  62. 128 > r ? t += String.fromCharCode(r) : r > 127 && 2048 > r ? (t += String.fromCharCode(r >> 6 | 192),
  63. t += String.fromCharCode(63 & r | 128)) : (t += String.fromCharCode(r >> 12 | 224),
  64. t += String.fromCharCode(r >> 6 & 63 | 128),
  65. t += String.fromCharCode(63 & r | 128))
  66. }
  67. return t
  68. }(e)),
  69. f = 1732584193,
  70. m = 4023233417,
  71. g = 2562383102,
  72. h = 271733878,
  73. l = 0; l < v.length; l += 16)
  74. c = f,
  75. p = m,
  76. u = g,
  77. d = h,
  78. f = r(f, m, g, h, v[l + 0], 7, 3614090360),
  79. h = r(h, f, m, g, v[l + 1], 12, 3905402710),
  80. g = r(g, h, f, m, v[l + 2], 17, 606105819),
  81. m = r(m, g, h, f, v[l + 3], 22, 3250441966),
  82. f = r(f, m, g, h, v[l + 4], 7, 4118548399),
  83. h = r(h, f, m, g, v[l + 5], 12, 1200080426),
  84. g = r(g, h, f, m, v[l + 6], 17, 2821735955),
  85. m = r(m, g, h, f, v[l + 7], 22, 4249261313),
  86. f = r(f, m, g, h, v[l + 8], 7, 1770035416),
  87. h = r(h, f, m, g, v[l + 9], 12, 2336552879),
  88. g = r(g, h, f, m, v[l + 10], 17, 4294925233),
  89. m = r(m, g, h, f, v[l + 11], 22, 2304563134),
  90. f = r(f, m, g, h, v[l + 12], 7, 1804603682),
  91. h = r(h, f, m, g, v[l + 13], 12, 4254626195),
  92. g = r(g, h, f, m, v[l + 14], 17, 2792965006),
  93. f = i(f, m = r(m, g, h, f, v[l + 15], 22, 1236535329), g, h, v[l + 1], 5, 4129170786),
  94. h = i(h, f, m, g, v[l + 6], 9, 3225465664),
  95. g = i(g, h, f, m, v[l + 11], 14, 643717713),
  96. m = i(m, g, h, f, v[l + 0], 20, 3921069994),
  97. f = i(f, m, g, h, v[l + 5], 5, 3593408605),
  98. h = i(h, f, m, g, v[l + 10], 9, 38016083),
  99. g = i(g, h, f, m, v[l + 15], 14, 3634488961),
  100. m = i(m, g, h, f, v[l + 4], 20, 3889429448),
  101. f = i(f, m, g, h, v[l + 9], 5, 568446438),
  102. h = i(h, f, m, g, v[l + 14], 9, 3275163606),
  103. g = i(g, h, f, m, v[l + 3], 14, 4107603335),
  104. m = i(m, g, h, f, v[l + 8], 20, 1163531501),
  105. f = i(f, m, g, h, v[l + 13], 5, 2850285829),
  106. h = i(h, f, m, g, v[l + 2], 9, 4243563512),
  107. g = i(g, h, f, m, v[l + 7], 14, 1735328473),
  108. f = a(f, m = i(m, g, h, f, v[l + 12], 20, 2368359562), g, h, v[l + 5], 4, 4294588738),
  109. h = a(h, f, m, g, v[l + 8], 11, 2272392833),
  110. g = a(g, h, f, m, v[l + 11], 16, 1839030562),
  111. m = a(m, g, h, f, v[l + 14], 23, 4259657740),
  112. f = a(f, m, g, h, v[l + 1], 4, 2763975236),
  113. h = a(h, f, m, g, v[l + 4], 11, 1272893353),
  114. g = a(g, h, f, m, v[l + 7], 16, 4139469664),
  115. m = a(m, g, h, f, v[l + 10], 23, 3200236656),
  116. f = a(f, m, g, h, v[l + 13], 4, 681279174),
  117. h = a(h, f, m, g, v[l + 0], 11, 3936430074),
  118. g = a(g, h, f, m, v[l + 3], 16, 3572445317),
  119. m = a(m, g, h, f, v[l + 6], 23, 76029189),
  120. f = a(f, m, g, h, v[l + 9], 4, 3654602809),
  121. h = a(h, f, m, g, v[l + 12], 11, 3873151461),
  122. g = a(g, h, f, m, v[l + 15], 16, 530742520),
  123. f = o(f, m = a(m, g, h, f, v[l + 2], 23, 3299628645), g, h, v[l + 0], 6, 4096336452),
  124. h = o(h, f, m, g, v[l + 7], 10, 1126891415),
  125. g = o(g, h, f, m, v[l + 14], 15, 2878612391),
  126. m = o(m, g, h, f, v[l + 5], 21, 4237533241),
  127. f = o(f, m, g, h, v[l + 12], 6, 1700485571),
  128. h = o(h, f, m, g, v[l + 3], 10, 2399980690),
  129. g = o(g, h, f, m, v[l + 10], 15, 4293915773),
  130. m = o(m, g, h, f, v[l + 1], 21, 2240044497),
  131. f = o(f, m, g, h, v[l + 8], 6, 1873313359),
  132. h = o(h, f, m, g, v[l + 15], 10, 4264355552),
  133. g = o(g, h, f, m, v[l + 6], 15, 2734768916),
  134. m = o(m, g, h, f, v[l + 13], 21, 1309151649),
  135. f = o(f, m, g, h, v[l + 4], 6, 4149444226),
  136. h = o(h, f, m, g, v[l + 11], 10, 3174756917),
  137. g = o(g, h, f, m, v[l + 2], 15, 718787259),
  138. m = o(m, g, h, f, v[l + 9], 21, 3951481745),
  139. f = n(f, c),
  140. m = n(m, p),
  141. g = n(g, u),
  142. h = n(h, d);
  143. return (s(f) + s(m) + s(g) + s(h)).toLowerCase()
  144. }(h1)
  145. console.log(c)

运行结果如下:

 

 可以发现这就是我们需要的的js文件了

 二,js文件引入影刀RPA,开始开发指令

        我们在影刀RPA里面编写调用我们刚才导入的js文件,然后把参数准备好,传进去,验证我们的结果:

接下来是封装成指令,我们只要把设置的变量改为入参就行,如下图:

以上操作完成后,我们发版这个指令集,然后创建应用来验证我们的结果。

三,验证结果

        这里,我新建了一个影刀应用(淘宝),可以看到,在Tool指令集下有我们开发的生成sign指令

 我随便在淘宝里找一个商品,查看它的信息:

 我直接把data和 t 拿下来传进去,token我就直接去cookie里面那了,这里我就不演示了,如下图:

我们直接对比我们生成的sign和原来的sign:

 

可以看到,一模一样,OK 到这里,我们开发一个生成加密参数sign指令就完成了。如果有时间,我会在写一篇生成得物sign的指令。。。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/282042
推荐阅读
相关标签
  

闽ICP备14008679号