js反调试

打印 上一主题 下一主题

主题 1898|帖子 1898|积分 5694

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
1.非对称加密(补充常见加密算法)
通常1000行左右,以是一般团体扣代码下来。

案例实战:公务员、事业单元、西席、财会等考试培训-粉笔教诲
第一步找到加密入口
 直接通过搜索的方法查找加密函数位置,在可疑点打上断点:

 成功断住,找到解密入口,开始第二步调试分析

 在此处断点进一步确认:

发现此处整个js代码都可能是加密位置:

 第三步模仿执行,放在脚本代码中发现没有题目:

要调用加密函数,window.encrypt:
 

调用运行:
 由密码最后的= 猜测可能是bs64加密
 
最后在pycharm实现模仿执行过程(与浏览器执行方法有些不同,必要做修改):

对于缺少的window.navigator方法要么补齐要么删除 

发现它只是做一个判断,而且是false,不会执行 

 
再对js代码修改一下,最后就成功啦:

  1. window = {};
  2. (function(av) {
  3.     function l() {
  4.         this.i = 0;
  5.         this.j = 0;
  6.         this.S = new Array()
  7.     }
  8.     function f(aI) {
  9.         var aH, z, aG;
  10.         for (aH = 0; aH < 256; ++aH) {
  11.             this.S[aH] = aH
  12.         }
  13.         z = 0;
  14.         for (aH = 0; aH < 256; ++aH) {
  15.             z = (z + this.S[aH] + aI[aH % aI.length]) & 255;
  16.             aG = this.S[aH];
  17.             this.S[aH] = this.S[z];
  18.             this.S[z] = aG
  19.         }
  20.         this.i = 0;
  21.         this.j = 0
  22.     }
  23.     function b() {
  24.         var z;
  25.         this.i = (this.i + 1) & 255;
  26.         this.j = (this.j + this.S[this.i]) & 255;
  27.         z = this.S[this.i];
  28.         this.S[this.i] = this.S[this.j];
  29.         this.S[this.j] = z;
  30.         return this.S[(z + this.S[this.i]) & 255]
  31.     }
  32.     l.prototype.init = f;
  33.     l.prototype.next = b;
  34.     function au() {
  35.         return new l()
  36.     }
  37.     var O = 256;
  38.     var n;
  39.     var V;
  40.     var ag;
  41.     function d(t) {
  42.         V[ag++] ^= t & 255;
  43.         V[ag++] ^= (t >> 8) & 255;
  44.         V[ag++] ^= (t >> 16) & 255;
  45.         V[ag++] ^= (t >> 24) & 255;
  46.         if (ag >= O) {
  47.             ag -= O
  48.         }
  49.     }
  50.     function U() {
  51.         d(new Date().getTime())
  52.     }
  53.     if (V == null) {
  54.         V = new Array();
  55.         ag = 0;
  56.         var K;
  57.         // if (navigator.appName == "Netscape" && navigator.appVersion < "5" && av.crypto) {
  58.         //     var H = av.crypto.random(32);
  59.         //     for (K = 0; K < H.length; ++K) {
  60.         //         V[ag++] = H.charCodeAt(K) & 255
  61.         //     }
  62.         // }
  63.         while (ag < O) {
  64.             K = Math.floor(65536 * Math.random());
  65.             V[ag++] = K >>> 8;
  66.             V[ag++] = K & 255
  67.         }
  68.         ag = 0;
  69.         U()
  70.     }
  71.     function E() {
  72.         if (n == null) {
  73.             U();
  74.             n = au();
  75.             n.init(V);
  76.             for (ag = 0; ag < V.length; ++ag) {
  77.                 V[ag] = 0
  78.             }
  79.             ag = 0
  80.         }
  81.         return n.next()
  82.     }
  83.     function aB(z) {
  84.         var t;
  85.         for (t = 0; t < z.length; ++t) {
  86.             z[t] = E()
  87.         }
  88.     }
  89.     function ah() {}
  90.     ah.prototype.nextBytes = aB;
  91.     var aC;
  92.     var an = 244837814094590;
  93.     var ac = ((an & 16777215) == 15715070);
  94.     function ay(z, t, aG) {
  95.         if (z != null) {
  96.             if ("number" == typeof z) {
  97.                 this.fromNumber(z, t, aG)
  98.             } else {
  99.                 if (t == null && "string" != typeof z) {
  100.                     this.fromString(z, 256)
  101.                 } else {
  102.                     this.fromString(z, t)
  103.                 }
  104.             }
  105.         }
  106.     }
  107.     function i() {
  108.         return new ay(null)
  109.     }
  110.     function c(aI, t, z, aH, aK, aJ) {
  111.         while (--aJ >= 0) {
  112.             var aG = t * this[aI++] + z[aH] + aK;
  113.             aK = Math.floor(aG / 67108864);
  114.             z[aH++] = aG & 67108863
  115.         }
  116.         return aK
  117.     }
  118.     function aE(aI, aN, aO, aH, aL, t) {
  119.         var aK = aN & 32767
  120.           , aM = aN >> 15;
  121.         while (--t >= 0) {
  122.             var aG = this[aI] & 32767;
  123.             var aJ = this[aI++] >> 15;
  124.             var z = aM * aG + aJ * aK;
  125.             aG = aK * aG + ((z & 32767) << 15) + aO[aH] + (aL & 1073741823);
  126.             aL = (aG >>> 30) + (z >>> 15) + aM * aJ + (aL >>> 30);
  127.             aO[aH++] = aG & 1073741823
  128.         }
  129.         return aL
  130.     }
  131.     function aD(aI, aN, aO, aH, aL, t) {
  132.         var aK = aN & 16383
  133.           , aM = aN >> 14;
  134.         while (--t >= 0) {
  135.             var aG = this[aI] & 16383;
  136.             var aJ = this[aI++] >> 14;
  137.             var z = aM * aG + aJ * aK;
  138.             aG = aK * aG + ((z & 16383) << 14) + aO[aH] + aL;
  139.             aL = (aG >> 28) + (z >> 14) + aM * aJ;
  140.             aO[aH++] = aG & 268435455
  141.         }
  142.         return aL
  143.     }
  144.     if (false) {
  145.         ay.prototype.am = aE;
  146.         aC = 30
  147.     } else {
  148.         if (false) {
  149.             ay.prototype.am = c;
  150.             aC = 26
  151.         } else {
  152.             ay.prototype.am = aD;
  153.             aC = 28
  154.         }
  155.     }
  156.     ay.prototype.DB = aC;
  157.     ay.prototype.DM = ((1 << aC) - 1);
  158.     ay.prototype.DV = (1 << aC);
  159.     var ae = 52;
  160.     ay.prototype.FV = Math.pow(2, ae);
  161.     ay.prototype.F1 = ae - aC;
  162.     ay.prototype.F2 = 2 * aC - ae;
  163.     var aj = "0123456789abcdefghijklmnopqrstuvwxyz";
  164.     var al = new Array();
  165.     var aw, x;
  166.     aw = "0".charCodeAt(0);
  167.     for (x = 0; x <= 9; ++x) {
  168.         al[aw++] = x
  169.     }
  170.     aw = "a".charCodeAt(0);
  171.     for (x = 10; x < 36; ++x) {
  172.         al[aw++] = x
  173.     }
  174.     aw = "A".charCodeAt(0);
  175.     for (x = 10; x < 36; ++x) {
  176.         al[aw++] = x
  177.     }
  178.     function aF(t) {
  179.         return aj.charAt(t)
  180.     }
  181.     function C(z, t) {
  182.         var aG = al[z.charCodeAt(t)];
  183.         return (aG == null) ? -1 : aG
  184.     }
  185.     function ab(z) {
  186.         for (var t = this.t - 1; t >= 0; --t) {
  187.             z[t] = this[t]
  188.         }
  189.         z.t = this.t;
  190.         z.s = this.s
  191.     }
  192.     function o(t) {
  193.         this.t = 1;
  194.         this.s = (t < 0) ? -1 : 0;
  195.         if (t > 0) {
  196.             this[0] = t
  197.         } else {
  198.             if (t < -1) {
  199.                 this[0] = t + DV
  200.             } else {
  201.                 this.t = 0
  202.             }
  203.         }
  204.     }
  205.     function e(t) {
  206.         var z = i();
  207.         z.fromInt(t);
  208.         return z
  209.     }
  210.     function y(aK, z) {
  211.         var aH;
  212.         if (z == 16) {
  213.             aH = 4
  214.         } else {
  215.             if (z == 8) {
  216.                 aH = 3
  217.             } else {
  218.                 if (z == 256) {
  219.                     aH = 8
  220.                 } else {
  221.                     if (z == 2) {
  222.                         aH = 1
  223.                     } else {
  224.                         if (z == 32) {
  225.                             aH = 5
  226.                         } else {
  227.                             if (z == 4) {
  228.                                 aH = 2
  229.                             } else {
  230.                                 this.fromRadix(aK, z);
  231.                                 return
  232.                             }
  233.                         }
  234.                     }
  235.                 }
  236.             }
  237.         }
  238.         this.t = 0;
  239.         this.s = 0;
  240.         var aJ = aK.length
  241.           , aG = false
  242.           , aI = 0;
  243.         while (--aJ >= 0) {
  244.             var t = (aH == 8) ? aK[aJ] & 255 : C(aK, aJ);
  245.             if (t < 0) {
  246.                 if (aK.charAt(aJ) == "-") {
  247.                     aG = true
  248.                 }
  249.                 continue
  250.             }
  251.             aG = false;
  252.             if (aI == 0) {
  253.                 this[this.t++] = t
  254.             } else {
  255.                 if (aI + aH > this.DB) {
  256.                     this[this.t - 1] |= (t & ((1 << (this.DB - aI)) - 1)) << aI;
  257.                     this[this.t++] = (t >> (this.DB - aI))
  258.                 } else {
  259.                     this[this.t - 1] |= t << aI
  260.                 }
  261.             }
  262.             aI += aH;
  263.             if (aI >= this.DB) {
  264.                 aI -= this.DB
  265.             }
  266.         }
  267.         if (aH == 8 && (aK[0] & 128) != 0) {
  268.             this.s = -1;
  269.             if (aI > 0) {
  270.                 this[this.t - 1] |= ((1 << (this.DB - aI)) - 1) << aI
  271.             }
  272.         }
  273.         this.clamp();
  274.         if (aG) {
  275.             ay.ZERO.subTo(this, this)
  276.         }
  277.     }
  278.     function Q() {
  279.         var t = this.s & this.DM;
  280.         while (this.t > 0 && this[this.t - 1] == t) {
  281.             --this.t
  282.         }
  283.     }
  284.     function r(z) {
  285.         if (this.s < 0) {
  286.             return "-" + this.negate().toString(z)
  287.         }
  288.         var aG;
  289.         if (z == 16) {
  290.             aG = 4
  291.         } else {
  292.             if (z == 8) {
  293.                 aG = 3
  294.             } else {
  295.                 if (z == 2) {
  296.                     aG = 1
  297.                 } else {
  298.                     if (z == 32) {
  299.                         aG = 5
  300.                     } else {
  301.                         if (z == 4) {
  302.                             aG = 2
  303.                         } else {
  304.                             return this.toRadix(z)
  305.                         }
  306.                     }
  307.                 }
  308.             }
  309.         }
  310.         var aI = (1 << aG) - 1, aL, t = false, aJ = "", aH = this.t;
  311.         var aK = this.DB - (aH * this.DB) % aG;
  312.         if (aH-- > 0) {
  313.             if (aK < this.DB && (aL = this[aH] >> aK) > 0) {
  314.                 t = true;
  315.                 aJ = aF(aL)
  316.             }
  317.             while (aH >= 0) {
  318.                 if (aK < aG) {
  319.                     aL = (this[aH] & ((1 << aK) - 1)) << (aG - aK);
  320.                     aL |= this[--aH] >> (aK += this.DB - aG)
  321.                 } else {
  322.                     aL = (this[aH] >> (aK -= aG)) & aI;
  323.                     if (aK <= 0) {
  324.                         aK += this.DB;
  325.                         --aH
  326.                     }
  327.                 }
  328.                 if (aL > 0) {
  329.                     t = true
  330.                 }
  331.                 if (t) {
  332.                     aJ += aF(aL)
  333.                 }
  334.             }
  335.         }
  336.         return t ? aJ : "0"
  337.     }
  338.     function T() {
  339.         var t = i();
  340.         ay.ZERO.subTo(this, t);
  341.         return t
  342.     }
  343.     function aq() {
  344.         return (this.s < 0) ? this.negate() : this
  345.     }
  346.     function I(t) {
  347.         var aG = this.s - t.s;
  348.         if (aG != 0) {
  349.             return aG
  350.         }
  351.         var z = this.t;
  352.         aG = z - t.t;
  353.         if (aG != 0) {
  354.             return aG
  355.         }
  356.         while (--z >= 0) {
  357.             if ((aG = this[z] - t[z]) != 0) {
  358.                 return aG
  359.             }
  360.         }
  361.         return 0
  362.     }
  363.     function k(z) {
  364.         var aH = 1, aG;
  365.         if ((aG = z >>> 16) != 0) {
  366.             z = aG;
  367.             aH += 16
  368.         }
  369.         if ((aG = z >> 8) != 0) {
  370.             z = aG;
  371.             aH += 8
  372.         }
  373.         if ((aG = z >> 4) != 0) {
  374.             z = aG;
  375.             aH += 4
  376.         }
  377.         if ((aG = z >> 2) != 0) {
  378.             z = aG;
  379.             aH += 2
  380.         }
  381.         if ((aG = z >> 1) != 0) {
  382.             z = aG;
  383.             aH += 1
  384.         }
  385.         return aH
  386.     }
  387.     function w() {
  388.         if (this.t <= 0) {
  389.             return 0
  390.         }
  391.         return this.DB * (this.t - 1) + k(this[this.t - 1] ^ (this.s & this.DM))
  392.     }
  393.     function ax(aG, z) {
  394.         var t;
  395.         for (t = this.t - 1; t >= 0; --t) {
  396.             z[t + aG] = this[t]
  397.         }
  398.         for (t = aG - 1; t >= 0; --t) {
  399.             z[t] = 0
  400.         }
  401.         z.t = this.t + aG;
  402.         z.s = this.s
  403.     }
  404.     function aa(aG, z) {
  405.         for (var t = aG; t < this.t; ++t) {
  406.             z[t - aG] = this[t]
  407.         }
  408.         z.t = Math.max(this.t - aG, 0);
  409.         z.s = this.s
  410.     }
  411.     function u(aL, aH) {
  412.         var z = aL % this.DB;
  413.         var t = this.DB - z;
  414.         var aJ = (1 << t) - 1;
  415.         var aI = Math.floor(aL / this.DB), aK = (this.s << z) & this.DM, aG;
  416.         for (aG = this.t - 1; aG >= 0; --aG) {
  417.             aH[aG + aI + 1] = (this[aG] >> t) | aK;
  418.             aK = (this[aG] & aJ) << z
  419.         }
  420.         for (aG = aI - 1; aG >= 0; --aG) {
  421.             aH[aG] = 0
  422.         }
  423.         aH[aI] = aK;
  424.         aH.t = this.t + aI + 1;
  425.         aH.s = this.s;
  426.         aH.clamp()
  427.     }
  428.     function m(aK, aH) {
  429.         aH.s = this.s;
  430.         var aI = Math.floor(aK / this.DB);
  431.         if (aI >= this.t) {
  432.             aH.t = 0;
  433.             return
  434.         }
  435.         var z = aK % this.DB;
  436.         var t = this.DB - z;
  437.         var aJ = (1 << z) - 1;
  438.         aH[0] = this[aI] >> z;
  439.         for (var aG = aI + 1; aG < this.t; ++aG) {
  440.             aH[aG - aI - 1] |= (this[aG] & aJ) << t;
  441.             aH[aG - aI] = this[aG] >> z
  442.         }
  443.         if (z > 0) {
  444.             aH[this.t - aI - 1] |= (this.s & aJ) << t
  445.         }
  446.         aH.t = this.t - aI;
  447.         aH.clamp()
  448.     }
  449.     function af(z, aH) {
  450.         var aG = 0
  451.           , aI = 0
  452.           , t = Math.min(z.t, this.t);
  453.         while (aG < t) {
  454.             aI += this[aG] - z[aG];
  455.             aH[aG++] = aI & this.DM;
  456.             aI >>= this.DB
  457.         }
  458.         if (z.t < this.t) {
  459.             aI -= z.s;
  460.             while (aG < this.t) {
  461.                 aI += this[aG];
  462.                 aH[aG++] = aI & this.DM;
  463.                 aI >>= this.DB
  464.             }
  465.             aI += this.s
  466.         } else {
  467.             aI += this.s;
  468.             while (aG < z.t) {
  469.                 aI -= z[aG];
  470.                 aH[aG++] = aI & this.DM;
  471.                 aI >>= this.DB
  472.             }
  473.             aI -= z.s
  474.         }
  475.         aH.s = (aI < 0) ? -1 : 0;
  476.         if (aI < -1) {
  477.             aH[aG++] = this.DV + aI
  478.         } else {
  479.             if (aI > 0) {
  480.                 aH[aG++] = aI
  481.             }
  482.         }
  483.         aH.t = aG;
  484.         aH.clamp()
  485.     }
  486.     function F(z, aH) {
  487.         var t = this.abs()
  488.           , aI = z.abs();
  489.         var aG = t.t;
  490.         aH.t = aG + aI.t;
  491.         while (--aG >= 0) {
  492.             aH[aG] = 0
  493.         }
  494.         for (aG = 0; aG < aI.t; ++aG) {
  495.             aH[aG + t.t] = t.am(0, aI[aG], aH, aG, 0, t.t)
  496.         }
  497.         aH.s = 0;
  498.         aH.clamp();
  499.         if (this.s != z.s) {
  500.             ay.ZERO.subTo(aH, aH)
  501.         }
  502.     }
  503.     function S(aG) {
  504.         var t = this.abs();
  505.         var z = aG.t = 2 * t.t;
  506.         while (--z >= 0) {
  507.             aG[z] = 0
  508.         }
  509.         for (z = 0; z < t.t - 1; ++z) {
  510.             var aH = t.am(z, t[z], aG, 2 * z, 0, 1);
  511.             if ((aG[z + t.t] += t.am(z + 1, 2 * t[z], aG, 2 * z + 1, aH, t.t - z - 1)) >= t.DV) {
  512.                 aG[z + t.t] -= t.DV;
  513.                 aG[z + t.t + 1] = 1
  514.             }
  515.         }
  516.         if (aG.t > 0) {
  517.             aG[aG.t - 1] += t.am(z, t[z], aG, 2 * z, 0, 1)
  518.         }
  519.         aG.s = 0;
  520.         aG.clamp()
  521.     }
  522.     function G(aO, aL, aK) {
  523.         var aU = aO.abs();
  524.         if (aU.t <= 0) {
  525.             return
  526.         }
  527.         var aM = this.abs();
  528.         if (aM.t < aU.t) {
  529.             if (aL != null) {
  530.                 aL.fromInt(0)
  531.             }
  532.             if (aK != null) {
  533.                 this.copyTo(aK)
  534.             }
  535.             return
  536.         }
  537.         if (aK == null) {
  538.             aK = i()
  539.         }
  540.         var aI = i()
  541.           , z = this.s
  542.           , aN = aO.s;
  543.         var aT = this.DB - k(aU[aU.t - 1]);
  544.         if (aT > 0) {
  545.             aU.lShiftTo(aT, aI);
  546.             aM.lShiftTo(aT, aK)
  547.         } else {
  548.             aU.copyTo(aI);
  549.             aM.copyTo(aK)
  550.         }
  551.         var aQ = aI.t;
  552.         var aG = aI[aQ - 1];
  553.         if (aG == 0) {
  554.             return
  555.         }
  556.         var aP = aG * (1 << this.F1) + ((aQ > 1) ? aI[aQ - 2] >> this.F2 : 0);
  557.         var aX = this.FV / aP
  558.           , aW = (1 << this.F1) / aP
  559.           , aV = 1 << this.F2;
  560.         var aS = aK.t
  561.           , aR = aS - aQ
  562.           , aJ = (aL == null) ? i() : aL;
  563.         aI.dlShiftTo(aR, aJ);
  564.         if (aK.compareTo(aJ) >= 0) {
  565.             aK[aK.t++] = 1;
  566.             aK.subTo(aJ, aK)
  567.         }
  568.         ay.ONE.dlShiftTo(aQ, aJ);
  569.         aJ.subTo(aI, aI);
  570.         while (aI.t < aQ) {
  571.             aI[aI.t++] = 0
  572.         }
  573.         while (--aR >= 0) {
  574.             var aH = (aK[--aS] == aG) ? this.DM : Math.floor(aK[aS] * aX + (aK[aS - 1] + aV) * aW);
  575.             if ((aK[aS] += aI.am(0, aH, aK, aR, 0, aQ)) < aH) {
  576.                 aI.dlShiftTo(aR, aJ);
  577.                 aK.subTo(aJ, aK);
  578.                 while (aK[aS] < --aH) {
  579.                     aK.subTo(aJ, aK)
  580.                 }
  581.             }
  582.         }
  583.         if (aL != null) {
  584.             aK.drShiftTo(aQ, aL);
  585.             if (z != aN) {
  586.                 ay.ZERO.subTo(aL, aL)
  587.             }
  588.         }
  589.         aK.t = aQ;
  590.         aK.clamp();
  591.         if (aT > 0) {
  592.             aK.rShiftTo(aT, aK)
  593.         }
  594.         if (z < 0) {
  595.             ay.ZERO.subTo(aK, aK)
  596.         }
  597.     }
  598.     function P(t) {
  599.         var z = i();
  600.         this.abs().divRemTo(t, null, z);
  601.         if (this.s < 0 && z.compareTo(ay.ZERO) > 0) {
  602.             t.subTo(z, z)
  603.         }
  604.         return z
  605.     }
  606.     function M(t) {
  607.         this.m = t
  608.     }
  609.     function X(t) {
  610.         if (t.s < 0 || t.compareTo(this.m) >= 0) {
  611.             return t.mod(this.m)
  612.         } else {
  613.             return t
  614.         }
  615.     }
  616.     function ap(t) {
  617.         return t
  618.     }
  619.     function L(t) {
  620.         t.divRemTo(this.m, null, t)
  621.     }
  622.     function J(t, aG, z) {
  623.         t.multiplyTo(aG, z);
  624.         this.reduce(z)
  625.     }
  626.     function aA(t, z) {
  627.         t.squareTo(z);
  628.         this.reduce(z)
  629.     }
  630.     M.prototype.convert = X;
  631.     M.prototype.revert = ap;
  632.     M.prototype.reduce = L;
  633.     M.prototype.mulTo = J;
  634.     M.prototype.sqrTo = aA;
  635.     function D() {
  636.         if (this.t < 1) {
  637.             return 0
  638.         }
  639.         var t = this[0];
  640.         if ((t & 1) == 0) {
  641.             return 0
  642.         }
  643.         var z = t & 3;
  644.         z = (z * (2 - (t & 15) * z)) & 15;
  645.         z = (z * (2 - (t & 255) * z)) & 255;
  646.         z = (z * (2 - (((t & 65535) * z) & 65535))) & 65535;
  647.         z = (z * (2 - t * z % this.DV)) % this.DV;
  648.         return (z > 0) ? this.DV - z : -z
  649.     }
  650.     function g(t) {
  651.         this.m = t;
  652.         this.mp = t.invDigit();
  653.         this.mpl = this.mp & 32767;
  654.         this.mph = this.mp >> 15;
  655.         this.um = (1 << (t.DB - 15)) - 1;
  656.         this.mt2 = 2 * t.t
  657.     }
  658.     function ao(t) {
  659.         var z = i();
  660.         t.abs().dlShiftTo(this.m.t, z);
  661.         z.divRemTo(this.m, null, z);
  662.         if (t.s < 0 && z.compareTo(ay.ZERO) > 0) {
  663.             this.m.subTo(z, z)
  664.         }
  665.         return z
  666.     }
  667.     function az(t) {
  668.         var z = i();
  669.         t.copyTo(z);
  670.         this.reduce(z);
  671.         return z
  672.     }
  673.     function R(t) {
  674.         while (t.t <= this.mt2) {
  675.             t[t.t++] = 0
  676.         }
  677.         for (var aG = 0; aG < this.m.t; ++aG) {
  678.             var z = t[aG] & 32767;
  679.             var aH = (z * this.mpl + (((z * this.mph + (t[aG] >> 15) * this.mpl) & this.um) << 15)) & t.DM;
  680.             z = aG + this.m.t;
  681.             t[z] += this.m.am(0, aH, t, aG, 0, this.m.t);
  682.             while (t[z] >= t.DV) {
  683.                 t[z] -= t.DV;
  684.                 t[++z]++
  685.             }
  686.         }
  687.         t.clamp();
  688.         t.drShiftTo(this.m.t, t);
  689.         if (t.compareTo(this.m) >= 0) {
  690.             t.subTo(this.m, t)
  691.         }
  692.     }
  693.     function ar(t, z) {
  694.         t.squareTo(z);
  695.         this.reduce(z)
  696.     }
  697.     function B(t, aG, z) {
  698.         t.multiplyTo(aG, z);
  699.         this.reduce(z)
  700.     }
  701.     g.prototype.convert = ao;
  702.     g.prototype.revert = az;
  703.     g.prototype.reduce = R;
  704.     g.prototype.mulTo = B;
  705.     g.prototype.sqrTo = ar;
  706.     function j() {
  707.         return ((this.t > 0) ? (this[0] & 1) : this.s) == 0
  708.     }
  709.     function A(aL, aM) {
  710.         if (aL > 4294967295 || aL < 1) {
  711.             return ay.ONE
  712.         }
  713.         var aK = i()
  714.           , aG = i()
  715.           , aJ = aM.convert(this)
  716.           , aI = k(aL) - 1;
  717.         aJ.copyTo(aK);
  718.         while (--aI >= 0) {
  719.             aM.sqrTo(aK, aG);
  720.             if ((aL & (1 << aI)) > 0) {
  721.                 aM.mulTo(aG, aJ, aK)
  722.             } else {
  723.                 var aH = aK;
  724.                 aK = aG;
  725.                 aG = aH
  726.             }
  727.         }
  728.         return aM.revert(aK)
  729.     }
  730.     function at(aG, t) {
  731.         var aH;
  732.         if (aG < 256 || t.isEven()) {
  733.             aH = new M(t)
  734.         } else {
  735.             aH = new g(t)
  736.         }
  737.         return this.exp(aG, aH)
  738.     }
  739.     ay.prototype.copyTo = ab;
  740.     ay.prototype.fromInt = o;
  741.     ay.prototype.fromString = y;
  742.     ay.prototype.clamp = Q;
  743.     ay.prototype.dlShiftTo = ax;
  744.     ay.prototype.drShiftTo = aa;
  745.     ay.prototype.lShiftTo = u;
  746.     ay.prototype.rShiftTo = m;
  747.     ay.prototype.subTo = af;
  748.     ay.prototype.multiplyTo = F;
  749.     ay.prototype.squareTo = S;
  750.     ay.prototype.divRemTo = G;
  751.     ay.prototype.invDigit = D;
  752.     ay.prototype.isEven = j;
  753.     ay.prototype.exp = A;
  754.     ay.prototype.toString = r;
  755.     ay.prototype.negate = T;
  756.     ay.prototype.abs = aq;
  757.     ay.prototype.compareTo = I;
  758.     ay.prototype.bitLength = w;
  759.     ay.prototype.mod = P;
  760.     ay.prototype.modPowInt = at;
  761.     ay.ZERO = e(0);
  762.     ay.ONE = e(1);
  763.     function h(z, t) {
  764.         return new ay(z,t)
  765.     }
  766.     function am(aG, aH) {
  767.         var t = "";
  768.         var z = 0;
  769.         while (z + aH < aG.length) {
  770.             t += aG.substring(z, z + aH) + "\n";
  771.             z += aH
  772.         }
  773.         return t + aG.substring(z, aG.length)
  774.     }
  775.     function s(t) {
  776.         if (t < 16) {
  777.             return "0" + t.toString(16)
  778.         } else {
  779.             return t.toString(16)
  780.         }
  781.     }
  782.     function ak(aH, aK) {
  783.         if (aK < aH.length + 11) {
  784.             alert("Message too long for RSA");
  785.             return null
  786.         }
  787.         var aJ = new Array();
  788.         var aG = aH.length - 1;
  789.         while (aG >= 0 && aK > 0) {
  790.             var aI = aH.charCodeAt(aG--);
  791.             if (aI < 128) {
  792.                 aJ[--aK] = aI
  793.             } else {
  794.                 if ((aI > 127) && (aI < 2048)) {
  795.                     aJ[--aK] = (aI & 63) | 128;
  796.                     aJ[--aK] = (aI >> 6) | 192
  797.                 } else {
  798.                     aJ[--aK] = (aI & 63) | 128;
  799.                     aJ[--aK] = ((aI >> 6) & 63) | 128;
  800.                     aJ[--aK] = (aI >> 12) | 224
  801.                 }
  802.             }
  803.         }
  804.         aJ[--aK] = 0;
  805.         var z = new ah();
  806.         var t = new Array();
  807.         while (aK > 2) {
  808.             t[0] = 0;
  809.             while (t[0] == 0) {
  810.                 z.nextBytes(t)
  811.             }
  812.             aJ[--aK] = t[0]
  813.         }
  814.         aJ[--aK] = 2;
  815.         aJ[--aK] = 0;
  816.         return new ay(aJ)
  817.     }
  818.     function N() {
  819.         this.n = null;
  820.         this.e = 0;
  821.         this.d = null;
  822.         this.p = null;
  823.         this.q = null;
  824.         this.dmp1 = null;
  825.         this.dmq1 = null;
  826.         this.coeff = null
  827.     }
  828.     function p(z, t) {
  829.         if (z != null && t != null && z.length > 0 && t.length > 0) {
  830.             this.n = h(z, 16);
  831.             this.e = parseInt(t, 16)
  832.         } else {
  833.             alert("Invalid RSA public key")
  834.         }
  835.     }
  836.     function Z(t) {
  837.         return t.modPowInt(this.e, this.n)
  838.     }
  839.     function q(aG) {
  840.         var t = ak(aG, (this.n.bitLength() + 7) >> 3);
  841.         if (t == null) {
  842.             return null
  843.         }
  844.         var aH = this.doPublic(t);
  845.         if (aH == null) {
  846.             return null
  847.         }
  848.         var z = aH.toString(16);
  849.         if ((z.length & 1) == 0) {
  850.             return z
  851.         } else {
  852.             return "0" + z
  853.         }
  854.     }
  855.     N.prototype.doPublic = Z;
  856.     N.prototype.setPublic = p;
  857.     N.prototype.encrypt = q;
  858.     var ad = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  859.     var Y = "=";
  860.     function ai(aG) {
  861.         var z;
  862.         var aH;
  863.         var t = "";
  864.         for (z = 0; z + 3 <= aG.length; z += 3) {
  865.             aH = parseInt(aG.substring(z, z + 3), 16);
  866.             t += ad.charAt(aH >> 6) + ad.charAt(aH & 63)
  867.         }
  868.         if (z + 1 == aG.length) {
  869.             aH = parseInt(aG.substring(z, z + 1), 16);
  870.             t += ad.charAt(aH << 2)
  871.         } else {
  872.             if (z + 2 == aG.length) {
  873.                 aH = parseInt(aG.substring(z, z + 2), 16);
  874.                 t += ad.charAt(aH >> 2) + ad.charAt((aH & 3) << 4)
  875.             }
  876.         }
  877.         while ((t.length & 3) > 0) {
  878.             t += Y
  879.         }
  880.         return t
  881.     }
  882.     function a(aI) {
  883.         var aG = "";
  884.         var aH;
  885.         var t = 0;
  886.         var z;
  887.         for (aH = 0; aH < aI.length; ++aH) {
  888.             if (aI.charAt(aH) == Y) {
  889.                 break
  890.             }
  891.             v = ad.indexOf(aI.charAt(aH));
  892.             if (v < 0) {
  893.                 continue
  894.             }
  895.             if (t == 0) {
  896.                 aG += aF(v >> 2);
  897.                 z = v & 3;
  898.                 t = 1
  899.             } else {
  900.                 if (t == 1) {
  901.                     aG += aF((z << 2) | (v >> 4));
  902.                     z = v & 15;
  903.                     t = 2
  904.                 } else {
  905.                     if (t == 2) {
  906.                         aG += aF(z);
  907.                         aG += aF(v >> 2);
  908.                         z = v & 3;
  909.                         t = 3
  910.                     } else {
  911.                         aG += aF((z << 2) | (v >> 4));
  912.                         aG += aF(v & 15);
  913.                         t = 0
  914.                     }
  915.                 }
  916.             }
  917.         }
  918.         if (t == 1) {
  919.             aG += aF(z << 2)
  920.         }
  921.         return aG
  922.     }
  923.     function W(aH) {
  924.         var aG = a(aH);
  925.         var z;
  926.         var t = new Array();
  927.         for (z = 0; 2 * z < aG.length; ++z) {
  928.             t[z] = parseInt(aG.substring(2 * z, 2 * z + 2), 16)
  929.         }
  930.         return t
  931.     }
  932.     av.encrypt = function(aG, z) {
  933.         var t = new N();
  934.         t.setPublic(a(aG), "10001");
  935.         return ai(t.encrypt(z))
  936.     }
  937. }
  938. )(window);
  939. public_key = 'ANKi9PWuvDOsagwIVvrPx77mXNV0APmjySsYjB1/GtUTY6cyKNRl2RCTt608m9nYk5VeCG2EAZRQmQNQTyfZkw0Uo+MytAkjj17BXOpY4o6+BToi7rRKfTGl6J60/XBZcGSzN1XVZ80ElSjaGE8Ocg8wbPN18tbmsy761zN5SuIl'
  940. password = '123456'
  941. data = window.encrypt(public_key,password)
  942. console.log(data)
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

杀鸡焉用牛刀

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表