zoukankan      html  css  js  c++  java
  • antitoken 反爬token生成

      1 var restify = require('restify');
      2 
      3 // 先找到e,e_token原始token,结果:b3b7bf1272752-420b-a354-640e36535125(b7bf12727545d425035e810faa7dc296)
      4 e_token="b3285924-9e62-420b-a354-640e36535125"
      5 e = "b3285924-9e62-420b-a354-640e365351252021-01-1212";
      6 
      7 
      8 //定义antitoken
      9 function antitoken(e){
     10     var a56 = {
     11         utf8: {
     12             stringToBytes: function(e) {
     13                 return a56.bin.stringToBytes(unescape(encodeURIComponent(e)))
     14             },
     15             bytesToString: function(e) {
     16                 return decodeURIComponent(escape(a.bin.bytesToString(e)))
     17             }
     18         },
     19         bin: {
     20             stringToBytes: function(e) {
     21                 for (var t = [], a = 0; a < e.length; a++)
     22                     t.push(255 & e.charCodeAt(a));
     23                 return t
     24             },
     25             bytesToString: function(e) {
     26                 for (var t = [], a = 0; a < e.length; a++)
     27                     t.push(String.fromCharCode(e[a]));
     28                 return t.join("")
     29             }
     30         }
     31     };
     32     // 这里t取任意值都行
     33     // var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
     34     var t = null;
     35     var n, i, o, s, r;
     36     // n = a117,
     37     n = {
     38         rotl: function(e, t) {
     39             return e << t | e >>> 32 - t
     40         },
     41         rotr: function(e, t) {
     42             return e << 32 - t | e >>> t
     43         },
     44         endian: function(e) {
     45             if (e.constructor == Number)
     46                 return 16711935 & n.rotl(e, 8) | 4278255360 & n.rotl(e, 24);
     47             for (var t = 0; t < e.length; t++)
     48                 e[t] = n.endian(e[t]);
     49             return e
     50         },
     51         bytesToWords: function(e) {
     52             for (var t = [], a = 0, n = 0; a < e.length; a++,
     53             n += 8)
     54                 t[n >>> 5] |= e[a] << 24 - n % 32;
     55             return t
     56         },
     57         wordsToBytes: function(e) {
     58             for (var t = [], a = 0; a < 32 * e.length; a += 8)
     59                 t.push(e[a >>> 5] >>> 24 - a % 32 & 255);
     60             return t
     61         },
     62         bytesToHex: function(e) {
     63             for (var t = [], a = 0; a < e.length; a++)
     64                 t.push((e[a] >>> 4).toString(16)),
     65                 t.push((15 & e[a]).toString(16));
     66             return t.join("")
     67         }
     68     },
     69     i = a56.utf8,
     70     o = null,
     71     s = a56.bin,
     72        (r = function(e, t) {
     73         e.constructor == String ? e = t && "binary" === t.encoding ? s.stringToBytes(e) : i.stringToBytes(e) : o(e) ? e = Array.prototype.slice.call(e, 0) : Array.isArray(e) || (e = e.toString());
     74         for (var a = n.bytesToWords(e), l = 8 * e.length, c = 1732584193, d = -271733879, p = -1732584194, u = 271733878, m = 0; m < a.length; m++)
     75             a[m] = 16711935 & (a[m] << 8 | a[m] >>> 24) | 4278255360 & (a[m] << 24 | a[m] >>> 8);
     76 
     77         a[l >>> 5] |= 128 << l % 32,
     78         a[14 + (l + 64 >>> 9 << 4)] = l;
     79         var f = r._ff
     80           , h = r._gg
     81           , v = r._hh
     82           , g = r._ii;
     83         for (m = 0; m < a.length; m += 16) {
     84             var y = c
     85               , _ = d
     86               , b = p
     87               , $ = u;
     88             d = g(d = g(d = g(d = g(d = v(d = v(d = v(d = v(d = h(d = h(d = h(d = h(d = f(d = f(d = f(d = f(d, p = f(p, u = f(u, c = f(c, d, p, u, a[m + 0], 7, -680876936), d, p, a[m + 1], 12, -389564586), c, d, a[m + 2], 17, 606105819), u, c, a[m + 3], 22, -1044525330), p = f(p, u = f(u, c = f(c, d, p, u, a[m + 4], 7, -176418897), d, p, a[m + 5], 12, 1200080426), c, d, a[m + 6], 17, -1473231341), u, c, a[m + 7], 22, -45705983), p = f(p, u = f(u, c = f(c, d, p, u, a[m + 8], 7, 1770035416), d, p, a[m + 9], 12, -1958414417), c, d, a[m + 10], 17, -42063), u, c, a[m + 11], 22, -1990404162), p = f(p, u = f(u, c = f(c, d, p, u, a[m + 12], 7, 1804603682), d, p, a[m + 13], 12, -40341101), c, d, a[m + 14], 17, -1502002290), u, c, a[m + 15], 22, 1236535329), p = h(p, u = h(u, c = h(c, d, p, u, a[m + 1], 5, -165796510), d, p, a[m + 6], 9, -1069501632), c, d, a[m + 11], 14, 643717713), u, c, a[m + 0], 20, -373897302), p = h(p, u = h(u, c = h(c, d, p, u, a[m + 5], 5, -701558691), d, p, a[m + 10], 9, 38016083), c, d, a[m + 15], 14, -660478335), u, c, a[m + 4], 20, -405537848), p = h(p, u = h(u, c = h(c, d, p, u, a[m + 9], 5, 568446438), d, p, a[m + 14], 9, -1019803690), c, d, a[m + 3], 14, -187363961), u, c, a[m + 8], 20, 1163531501), p = h(p, u = h(u, c = h(c, d, p, u, a[m + 13], 5, -1444681467), d, p, a[m + 2], 9, -51403784), c, d, a[m + 7], 14, 1735328473), u, c, a[m + 12], 20, -1926607734), p = v(p, u = v(u, c = v(c, d, p, u, a[m + 5], 4, -378558), d, p, a[m + 8], 11, -2022574463), c, d, a[m + 11], 16, 1839030562), u, c, a[m + 14], 23, -35309556), p = v(p, u = v(u, c = v(c, d, p, u, a[m + 1], 4, -1530992060), d, p, a[m + 4], 11, 1272893353), c, d, a[m + 7], 16, -155497632), u, c, a[m + 10], 23, -1094730640), p = v(p, u = v(u, c = v(c, d, p, u, a[m + 13], 4, 681279174), d, p, a[m + 0], 11, -358537222), c, d, a[m + 3], 16, -722521979), u, c, a[m + 6], 23, 76029189), p = v(p, u = v(u, c = v(c, d, p, u, a[m + 9], 4, -640364487), d, p, a[m + 12], 11, -421815835), c, d, a[m + 15], 16, 530742520), u, c, a[m + 2], 23, -995338651), p = g(p, u = g(u, c = g(c, d, p, u, a[m + 0], 6, -198630844), d, p, a[m + 7], 10, 1126891415), c, d, a[m + 14], 15, -1416354905), u, c, a[m + 5], 21, -57434055), p = g(p, u = g(u, c = g(c, d, p, u, a[m + 12], 6, 1700485571), d, p, a[m + 3], 10, -1894986606), c, d, a[m + 10], 15, -1051523), u, c, a[m + 1], 21, -2054922799), p = g(p, u = g(u, c = g(c, d, p, u, a[m + 8], 6, 1873313359), d, p, a[m + 15], 10, -30611744), c, d, a[m + 6], 15, -1560198380), u, c, a[m + 13], 21, 1309151649), p = g(p, u = g(u, c = g(c, d, p, u, a[m + 4], 6, -145523070), d, p, a[m + 11], 10, -1120210379), c, d, a[m + 2], 15, 718787259), u, c, a[m + 9], 21, -343485551),
     89             c = c + y >>> 0,
     90             d = d + _ >>> 0,
     91             p = p + b >>> 0,
     92             u = u + $ >>> 0
     93         }
     94         return n.endian([c, d, p, u])
     95     }
     96     )._ff = function(e, t, a, n, i, o, s) {
     97         var r = e + (t & a | ~t & n) + (i >>> 0) + s;
     98         return (r << o | r >>> 32 - o) + t
     99     }
    100     ,
    101     r._gg = function(e, t, a, n, i, o, s) {
    102         var r = e + (t & n | a & ~n) + (i >>> 0) + s;
    103         return (r << o | r >>> 32 - o) + t
    104     }
    105     ,
    106     r._hh = function(e, t, a, n, i, o, s) {
    107         var r = e + (t ^ a ^ n) + (i >>> 0) + s;
    108         return (r << o | r >>> 32 - o) + t
    109     }
    110     ,
    111     r._ii = function(e, t, a, n, i, o, s) {
    112         var r = e + (a ^ (t | ~n)) + (i >>> 0) + s;
    113         return (r << o | r >>> 32 - o) + t
    114     }
    115     ,
    116     r._blocksize = 16,
    117     r._digestsize = 16;
    118 
    119     var a = n.wordsToBytes(r(e, t));
    120     return t && t.asBytes ? a : t && t.asString ? s.bytesToString(a) : n.bytesToHex(a);
    121 };
    122 
    123 function respond(req, res, next) {
    124   res.send('hello ' + req.params.name);
    125   next();
    126 }
    127 
    128 function token_res(req, res, next) {
    129   var token = req.query.token;
    130   var start_date = req.query.dt;
    131   var metric_length = req.query.size;
    132   var token_str = "".concat(token).concat(start_date).concat(metric_length)
    133   console.log(token_str)
    134   var atoken = antitoken(token_str);
    135   var part1 = token.slice(0,2);
    136   var part2 = atoken.slice(0,10);
    137   var part3 = token.slice(12);
    138   var dynamic_token = "".concat(part1).concat(part2).concat(part3);
    139  
    140   res.contentType = 'json';
    141   res.setHeader('content-type', 'application/json');
    142   res.send({dynamic_token: dynamic_token,query:req.query})
    143   next()
    144 }
    145 
    146 
    147 
    148 var server = restify.createServer();
    149 server.use(require('restify-plugins').queryParser());
    150 server.use(restify.plugins.queryParser());
    151 server.get('/hello/:name', respond);
    152 server.get('/token',token_res);
    153 server.head('/hello/:name', respond);
    154 
    155 server.listen(8080, function() {
    156   console.log('%s listening at %s', server.name, server.url);
    157 });
  • 相关阅读:
    用python抓取百度指数 以及 用cxfreeze打包的经验
    selenium中send_keys的使用
    python之文件调用
    学习python之selenium
    学习python图像识别
    解决方案: 运行ugarchroll,报错Error in try(.C("c_qstd", p = as.double(p), mu = as.double(mu), sigma = as.double(sigma), : NA/NaN/Inf in foreign function call (arg 3)
    int 转 const char*
    均值,方差,协方差,协方差矩阵,特征值,特征向量
    OpenCv 图片上添加汉字
    OpenCV获取与设置像素点的值的几个方法
  • 原文地址:https://www.cnblogs.com/yako/p/14271690.html
Copyright © 2011-2022 走看看