当前位置:   article > 正文

京东h5st逆向 h5st代码之拓展_h5st 4.3

h5st 4.3

知识点

node安装模块
crypto-js JavaScript 中的加密库 则更偏向于消息摘要算法、对称加密和简单的哈希函数,支持 AES、DES、SHA-1、HMAC 等诸多算法,适用于对客户端本地存储的数据进行加密、散列或签名处理等场景
axios 一旦安装成功,我们就可以在代码中使用Axios来发送HTTP请求了。首先,我们需要在代码中导入Axios模块
adler-32 校验和 算法
npm install axios 案例

废话不多说直接上代码

const CryptoJS = require("crypto-js");
const axios = require("axios");
const ADLER32 = require("adler-32");

class h5st {
  constructor(cookieStr, userAgent, config, url) {
    this.cookieStr = cookieStr;
    this.userAgent = userAgent;

    if (url) {
      try {
        this.url = url;
        this.origin = new URL(url).origin;
      } catch(e) {
        console.log('url传递错误')
      }
    }

    this.map = new Map();

    this.settings = {
      debug: !1,
      preRequest: !1,
      timeout: 2,
    };
    var Q_ = {
      DYNAMIC_TOKEN: "WQ_dy_tk_s_file",
      DYNAMIC_ALGORITHM: "WQ_dy_algo_s_file",
      VK: "WQ_vk1_file",
      FLAG: "WQ_f_v_file",
    };
    this.gb = { UNSIGNABLE_PARAMS: 1, APPID_ABSENT: 2, TOKEN_EMPTY: 3, GENERATE_SIGNATURE_FAILED: 4, UNHANDLED_ERROR: -1 };

    this._storagetokenKey = Q_.DYNAMIC_TOKEN;
    this._storageAlgnKey = Q_.DYNAMIC_ALGORITHM;
    this._storageFormatVersionKey = Q_.FLAG;
    this._version = "4.2";
    this._storageFpKey = Q_.VK;
    this._token = "";
    this._defaultToken = "";
    this._isNormal = !1;
    this._appId = "";
    this._defaultAlgorithm = {
      local_key_1: CryptoJS.MD5,
      local_key_2: CryptoJS.SHA256,
      local_key_3: CryptoJS.HmacSHA256,
    };
    this.algos = {
      MD5: CryptoJS.MD5,
      SHA256: CryptoJS.SHA256,
      SHA512: CryptoJS.SHA512,
      HmacSHA256: CryptoJS.HmacSHA256,
      HmacSHA512: CryptoJS.HmacSHA512,
      HmacMD5: CryptoJS.HmacMD5,
    };
    this._formatVersion = 4.2;
    this._fingerprint = "";
    config = Object.assign({}, this.settings, config);
    this.__iniConfig(config);
  }

  S_(t) {
    function w_(t, r) {
      r = r || 0;
      for (var n = t.length - r, e = new Array(n); n--; ) e[n] = t[n + r];
      return e;
    }

    if (t) {
      var n = "[sign] ",
        o = new Array(arguments.length > 1 ? arguments.length - 1 : 0),
        i = 1;
      for (var i = 1; i < arguments.length; i++) {
        o[i - 1] = arguments[i];
      }
      var a = w_(o);
      console.log([n].concat(a));
    }
  }
  x_(params) {
    // console.log(JSON.stringify(params));
  }

  async __iniConfig(t) {
    var i = t.appId,
      a = t.preRequest,
      u = t.debug,
      c = t.timeout,
      f = t.onSign,
      s = t.onRequestToken,
      v = t.onRequestTokenRemotely;
    (!("string" == typeof t.appId) || !t.appId) && console.error("settings.appId must be a non-empty string");
    this._appId = i || "";
    if (this._appId) {
      this._storagetokenKey = "".concat(this._storagetokenKey, "_").concat(this._appId);
      this._storageAlgnKey = "".concat(this._storageAlgnKey, "_").concat(this._appId);
      this._storageFormatVersionKey = "".concat(this._storageFormatVersionKey, "_").concat(this._appId);
      this._storageFpKey = "".concat(this._storageFpKey, "_").concat(this._appId);
    }
    this._timeout = Number(c);
    this._debug = Boolean(u);
    this._onSign = "function" == typeof f ? f : this.x_;
    this._onRequestToken = "function" == typeof s ? s : this.x_;
    this._onRequestTokenRemotely = "function" == typeof v ? v : this.x_;
    this.S_(this._debug, "create instance with appId=".concat(this._appId));
    this.S_(this._debug, "create instance with timeout=".concat(this._timeout));
    if (a) await this.__requestDeps();
  }

  __genDefaultKey(t, r, n, e) {
    function C_(t) {
      return (t + "===".slice((t.length + 3) % 4)).replace(/-/g, "+").replace(/_/g, "/");
    }

    var z = this,
      D = "",
      B = "9>5*t5";
    var L = "".concat(t).concat(r).concat(n).concat(e).concat(B),
      M = CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(C_(this.__parseToken(t, 16, 28))));
    var E = M.match(/^[123]([x+][123])+/);
    if (E) {
      var k = E[0].split(""),
        T = this._defaultAlgorithm,
        P = "";
      k.forEach(function (r) {
        var e = ["+", "x"];
        if (isNaN(r)) e.indexOf(r) >= 0 && (P = r);
        else {
          var u = "".concat("local_key_").concat(r);
          if (T[u])
            switch (P) {
              case "+":
                D = "".concat(D).concat(z.__algorithm(u, L, t));
                break;
              case "x":
                D = z.__algorithm(u, D, t);
                break;
              default:
                D = z.__algorithm(u, L, t);
            }
        }
      });
    }
    this.S_(this._debug, "__genDefaultKey input=" + L + ",express=" + M + ",key=" + D);
    return D;
  }

  __algorithm(t, r, n) {
    var o = this._defaultAlgorithm[t];
    return t === "local_key_3" ? o(r, n).toString(CryptoJS.enc.Hex) : o(r).toString(CryptoJS.enc.Hex);
  }

  __parseToken(t, r, n) {
    return t ? t.slice(r, n) : "";
  }

  __parseAlgorithm(t, r) {
    if (t && r) {
      this._token = t || "";
      this.__genKey = (r && new Function("return ".concat(r))()) || null;
      var a = this._token && this.__genKey;
      this._isNormal = a;
      return a;
    }
    return !1;
  }

  __genSignParams(t, r, n, e) {
    return [
      "".concat(n),
      "".concat(this._fingerprint),
      "".concat(this._appId),
      "".concat(this._isNormal ? this._token : this._defaultToken),
      "".concat(t),
      "".concat(this._version),
      "".concat(r),
      "".concat(e),
    ].join(";");
  }

  __genSign(t, r) {
    var l = r
      .map(function (t) {
        return t.key + ":" + t.value;
      })
      .join("&");
    var h = CryptoJS.SHA256(t + l + t).toString(CryptoJS.enc.Hex);
    this.S_(this._debug, "__genSign, paramsStr:".concat(l, ", signedStr:").concat(h));
    return h;
  }

  async __requestDeps() {
    function Xb() {
      var U = "6d0jhqw3pa";
      var nt = Vb(U, 4);
      var rt = Jb();
      var Q = tw(U, nt);
      var tt =
        Qb({ size: rt, num: Q }) +
        nt +
        Qb({
          size: 11 - rt,
          num: Q,
        }) +
        rt;
      var Z = tt.split("");
      var X = Z.slice(0, 14);
      var J = Z.slice(14);
      var V = [];
      for (; X.length > 0; ) V.push((35 - parseInt(X.pop(), 36)).toString(36));
      V = V.concat(J);
      var Y = V.join("");
      return Y;
    }
    function Vb(t, r) {
      var b,
        C = [],
        A = t.length,
        S = (function (t, r) {
          var lt;
          if (typeof Ld === "undefined" || t[Symbol.iterator] == null) {
            if (Array.isArray(t) || (lt = Yb(t)) || (r && t && typeof t.length === "number")) {
              lt && (t = lt);
              var dt = 0;
              return {
                s: function () {},
                n: function () {
                  if (dt >= t.length) {
                    return {
                      done: !0,
                    };
                  }
                  return {
                    done: !1,
                    value: t[dt++],
                  };
                },
                e: function (t) {
                  throw t;
                },
                f: function () {},
              };
            }
            throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
          }
          var st,
            vt = !0,
            ht = !1;
          return {
            s: function () {
              lt = t[Symbol.iterator]();
            },
            n: function () {
              var r = lt.next();
              return (vt = r.done), r;
            },
            e: function (t) {
              (ht = !0), (st = t);
            },
            f: function () {
              try {
                !vt && lt.return != null && lt.return();
              } finally {
                if (ht) throw st;
              }
            },
          };
        })(t);
      try {
        for (S.s(); !(b = S.n()).done; ) {
          var z = b.value;
          if (Math.random() * A < r && (C.push(z), --r == 0)) break;
          A--;
        }
      } catch (t) {
        S.e(t);
      } finally {
        S.f();
      }
      for (var D = "", B = 0; B < C.length; B++) {
        var j = (Math.random() * (C.length - B)) | 0;
        (D += C[j]), (C[j] = C[C.length - B - 1]);
      }
      return D;
    }
    function Yb(t, r) {
      if (!t) return;
      if (typeof t === "string") return Ub(t, r);
      var D = t.slice(8, -1);
      D === "Object" && t.constructor && (D = t.constructor.name);
      if (D === "Map" || D === "Set") return Array.from(t);
      if ("Arguments" === D || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/["test"](D)) return Ub(t, r);
    }
    function Ub(t, r) {
      (r == null || r > t.length) && (r = t.length);
      for (var h = 0, l = new Array(r); h < r; h++) l[h] = t[h];
      return l;
    }
    function Jb() {
      return (Math.random() * 10) | 0;
    }
    function tw(t, r) {
      for (var d = 0; d < r.length; d++) {
        var x = t.indexOf(r[d]);
        x !== -1 && (t = t.replace(r[d], ""));
      }
      return t;
    }
    function Qb(t) {
      var _ = t.size,
        g = t.num;
      for (var y = ""; _--; ) y += g[(Math.random() * g.length) | 0];
      return y;
    }

    var storageFormatVersion = this.getSync(this._storageFormatVersionKey);
    this.S_(this._debug, "__requestDeps, storageFormatVersion:" + storageFormatVersion + ", _formatVersion:" + this._formatVersion);
    if (!storageFormatVersion || storageFormatVersion !== this._formatVersion) {
      this.removeSync(this._storageFpKey);
      this.removeSync(this._storagetokenKey);
      this.removeSync(this._storageAlgnKey);
      this.setSync(this._storageFormatVersionKey, this._formatVersion, { expire: 365 * (3600 * 24) });
    }
    this._fingerprint = this.getSync(this._storageFpKey);
    if (this._fingerprint) {
      this.S_(this._debug, "__requestDeps use cache fp, fp:" + this._fingerprint);
    } else {
      this._fingerprint = Xb();
      this.setSync(this._storageFpKey, this._fingerprint, { expire: 3600 * 24 * 365 });
      this.S_(this._debug, "__requestDeps use new fp, fp:" + this._fingerprint);
    }
    var token = CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(this.getSync(this._storagetokenKey) || ""));
    var algorithm = CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(this.getSync(this._storageAlgnKey) || ""));
    if (this.__parseAlgorithm(token, algorithm)) {
      var response = {
        code: 0,
        message: "use normalToken",
      };
      this._onRequestToken(response);
      this.S_(this._debug, "__requestDeps, use cache token, token:" + this._token);
      return;
    }
    var response = {
      code: 1,
      message: "use defaultToken",
    };
    this._onRequestToken(response);
    this.S_(this._debug, "__requestDeps, start __requestAlgorithm, fp:" + this._fingerprint);
    try {
      await this.__requestAlgorithm();
    } catch (error) {
      this.S_(this._debug, "__requestDeps request token failed, error: " + error);
    }
    this.S_(this._debug, "__requestDeps, end __requestAlgorithm, fp:".concat(this._fingerprint));
  }

  async __requestAlgorithm() {
    var Dt = this.Cw(0);
    Dt.ai = this._appId;
    Dt.fp = this._fingerprint;
    var Bt = JSON.stringify(Dt, null, 2);
    this.S_(this._debug, "__requestAlgorithm envCollect=".concat(Bt));
    var jt = CryptoJS.AES.encrypt(Bt, CryptoJS.enc.Utf8.parse("wm0!@w-s#ll1flo("), {
      iv: CryptoJS.enc.Utf8.parse("0102030405060708"),
    });
    var fr = {
      fingerprint: this._fingerprint,
      appId: this._appId,
      version: this._version,
      timeout: this._timeout,
      env: jt.ciphertext.toString(),
      debug: this._debug,
    };
    var result = await this.im(fr, this._onRequestTokenRemotely);

    var h = result.algo,
      l = result.token,
      p = result.fp;
    var v = this.__parseAlgorithm(l, h);
    if (!v) return;
    var d = this.getSync(this._storageFpKey, 1);
    if (!p || (d && p === d)) {
      var w = this.__parseToken(l, 13, 15);
      var A = parseInt(w, 16);
      var C = 60 * A * 60;
      this.setSync(this._storagetokenKey, CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(l)), { expire: C });
      this.setSync(this._storageAlgnKey, CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(h)), { expire: C });
      this.S_(this._debug, "__requestAlgorithm request success!, token:".concat(l));
    } else {
      this.S_(this._debug, "__requestAlgorithm request success!,  but not save token:".concat(l, ", storageFp:").concat(d, ", fp:").concat(p));
    }
    return;
  }

  async im(t, r) {
    try {
      var { data, status } = await axios({
        url: "https://cactus.jd.com/request_algo",
        method: "post",
        data: {
          version: t.version,
          fp: t.fingerprint,
          appId: t.appId,
          timestamp: Date.now(),
          platform: "web",
          expandParams: t.env,
          fv: "h5_npm_v4.2.0",
        },
        headers: {
          "Content-Type": "application/json;charset=utf-8",
          Origin: "https://cactus.jd.com",
          Host: "cactus.jd.com",
          accept: "*/*",
          "User-Agent": this.userAgent,
        },
      });
      var a = {
        code: status,
        message: "",
      };
      r && r(a);
      if (status == 200 && data && data.data && data.data.result) {
        var f = data.data.result,
          s = f.algo,
          v = f.tk,
          h = f.fp;
        if (s && v) {
          var l = {
            algo: s,
            token: v,
            fp: h,
          };
          return l;
        } else {
          console.log("data.result format error.");
        }
      } else {
        console.log("request params error.");
      }
    } catch (e) {
      var b = e.code,
        w = e.message;
      r &&
        r({
          code: b,
          message: w,
        });
      console.log("request error, ".concat(b, ", ").concat(w));
    }
    return {};
  }

  __checkParams(t) {
    function jm(t) {
      return "[object Object]" === Object.prototype.toString.call(t);
    }
    function Lm(t) {
      return !!jm(t) && !Object.keys(t).length;
    }
    function b_(t) {
      var _m = ["h5st", "_stk", "_ste"];
      for (var r = Object.keys(t), n = 0; n < r.length; n++) {
        var e = r[n];
        if (_m.indexOf(e) >= 0) {
          return !0;
        }
      }
      return !1;
    }

    var b = null;
    if (!this._appId) {
      b = {
        code: this.gb.APPID_ABSENT,
        message: "appId is required",
      };
    }
    if (!jm(t)) {
      b = {
        code: this.gb.UNSIGNABLE_PARAMS,
        message: "params is not a plain object",
      };
    }
    if (Lm(t)) {
      b = {
        code: this.gb.UNSIGNABLE_PARAMS,
        message: "params is empty",
      };
    }
    if (b_(t)) {
      b = {
        code: this.gb.UNSIGNABLE_PARAMS,
        message: "params contains reserved param name.",
      };
    }
    if (b) return this._onSign(b), null;
    var g = Object.keys(t)
      .sort()
      .map(function (r) {
        return {
          key: r,
          value: t[r],
        };
      })
      .filter(function (t) {
        let type = typeof t.value;
        return ("number" == type && !isNaN(t.value)) || "string" == type || "boolean" == type;
      });
    if (g.length === 0) {
      var _ = {
        code: this.gb.UNSIGNABLE_PARAMS,
        message: 'params is empty after excluding "unsafe" params',
      };
      this._onSign(_);
      return null;
    }
    return g;
  }

  __makeSign(t, r) {
    function xb() {
      var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : Date.now(),
        e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "yyyy-MM-dd",
        n = new Date(t),
        r = e,
        o = {
          "M+": n.getMonth() + 1,
          "d+": n.getDate(),
          "D+": n.getDate(),
          "h+": n.getHours(),
          "H+": n.getHours(),
          "m+": n.getMinutes(),
          "s+": n.getSeconds(),
          "w+": n.getDay(),
          "q+": Math.floor((n.getMonth() + 3) / 3),
          "S+": n.getMilliseconds(),
        };
      return (
        /(y+)/i.test(r) && (r = r.replace(RegExp.$1, "".concat(n.getFullYear()).substr(4 - RegExp.$1.length))),
        Object.keys(o).forEach(function (t) {
          if (new RegExp("(".concat(t, ")")).test(r)) {
            var e = "S+" === t ? "000" : "00";
            r = r.replace(RegExp.$1, 1 == RegExp.$1.length ? o[t] : "".concat(e).concat(o[t]).substr("".concat(o[t]).length));
          }
        }),
        r
      );
    }
    function uw(t) {
      var ht = {
        magic: "tk",
        version: "02",
        platform: "w",
        expires: "41",
        producer: "l",
        expr: gw(),
        cipher: fw(t),
      };
      ht.adler32 = cw(ht.magic + ht.version + ht.platform + ht.expires + ht.producer + ht.expr + ht.cipher);
      return ht.magic + ht.version + ht.platform + ht.adler32 + ht.expires + ht.producer + ht.expr + ht.cipher;
    }
    function gw() {
      var G = {
        size: 32,
        dictType: "max",
        customDict: null,
      };
      var N = d_(G);
      var R = ["1", "2", "3"];
      var Y = ["+", "x"];
      var F = 2 + Math.floor(Math.random() * 4);
      var K = "";
      for (var W = 0; W < F; W++) (K += R[Math.floor(3 * Math.random())]), W < F - 1 && (K += Y[Math.floor(2 * Math.random())]);
      K.length < 9 && (K += N.substr(0, 9 - K.length));
      var H = CryptoJS.enc.Utf8.parse(K);
      var q = CryptoJS.enc.Base64.stringify(H);
      return A_(q);
    }
    function d_() {
      var t,
        r = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
        n = r.size,
        e = void 0 === n ? 10 : n,
        o = r.dictType,
        i = void 0 === o ? "number" : o,
        a = r.customDict,
        u = "";
      if (a && "string" == typeof a) t = a;
      else
        switch (i) {
          case "alphabet":
            t = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            break;
          case "max":
            t = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
            break;
          case "number":
          default:
            t = "0123456789";
        }
      for (; e--; ) u += t[(Math.random() * t.length) | 0];
      return u;
    }
    function A_(t) {
      return t.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
    }
    function fw(t) {
      d_({
        size: 32,
        dictType: "max",
        customDict: null,
      });
      var J = "";
      var Z = Date.now();
      var V = "z7";
      var $ = "qem7+)g%Dhw5";
      var Q = sw(t, Z, V, $);
      J += lw(Q);
      J += lw(V);
      J += lw($);
      J += xw(Z);
      J += lw(t);
      var X = CryptoJS.enc.Hex.parse(J);
      var tt = CryptoJS.AES.encrypt(X, CryptoJS.enc.Utf8.parse("x6e@RoHi$Fgy7!5k"), { iv: CryptoJS.enc.Utf8.parse("0102030405060708") });
      return A_(CryptoJS.enc.Base64.stringify(tt.ciphertext));
    }
    function sw(t, r, n, e) {
      var nt = new Uint8Array(16);
      nt.forEach(function (r, n, e) {
        e[n] = t.charCodeAt(n);
      });
      var et = pw(r),
        ot = new Uint8Array(2);
      ot.forEach(function (t, r, e) {
        e[r] = n.charCodeAt(r);
      });
      var at = new Uint8Array(12);
      at.forEach(function (t, r, n) {
        n[r] = e.charCodeAt(r);
      });
      var ut = new Uint8Array(38);
      ut.set(ot), ut.set(at, 2), ut.set(et, 14), ut.set(nt, 22);
      var ct = adler32.buf(ut);
      var st = "00000000" + (ct = ct >>> 0).toString(16);
      return st["substr"](st.length - 8);
    }
    function pw(t) {
      var C = (function () {
          var n = new ArrayBuffer(2);
          return new DataView(n).setInt16(0, 256, !0), new Int16Array(n)[0] === 256;
        })(),
        A = Math.floor(t / Math.pow(2, 32)),
        S = t % Math.pow(2, 32),
        z = new ArrayBuffer(8),
        D = new DataView(z);
      return C ? (D.setUint32(0, S, C), D.setUint32(4, A, C)) : (D.setUint32(0, A, C), D.setUint32(4, S, C)), new Uint8Array(z);
    }
    function xw(t) {
      return vw(pw(t));
    }
    function lw(t) {
      var h = new Uint8Array(t.length);
      h.forEach(function (r, n, e) {
        e[n] = t.charCodeAt(n);
      });
      return vw(h);
    }
    function vw(t) {
      return t
        .map(function (t) {
          return "00" + (t & 255).toString(16).slice(-2);
        })
        .join("");
    }
    function cw(t) {
      var h = ADLER32.str(t);
      h >>>= 0;
      var y = "00000000" + h.toString(16);
      return y["substr"](y.length - 8);
    }

    var f = "";
    var b = Date.now();
    var s = xb(b, "yyyyMMddhhmmssSSS");
    var v = s + "74";
    if (this._isNormal) {
      f = this.__genKey(this._token, this._fingerprint, v, this._appId, this.algos).toString() || "";
    } else {
      this._defaultToken = uw(this._fingerprint);
      f = this.__genDefaultKey(this._defaultToken, this._fingerprint, v, this._appId);
    }
    var h = {};
    if (f) {
      var l = this.__genSign(f, t);
      var p = t
        .map(function (t) {
          return t.key;
        })
        .join(",");
      var d = this.__genSignParams(l, b, s, r);
      var x = {
        key: f,
        signStr: l,
        _stk: p,
        _ste: 1,
        h5st: d,
      };

      this.S_(this._debug, "__makeSign, result:" + JSON.stringify(x, null, 2));
      var h = {
        _stk: p,
        _ste: 1,
        h5st: d,
      };
      var g = {
        code: 0,
        message: "success",
      };
      this._onSign(g);
      return h;
    }
    if (this._token || this._defaultToken) {
      var _ = {
        code: this.gb.GENERATE_SIGNATURE_FAILED,
        message: "generate key failed",
      };
      this._onSign(_);
    } else {
      var m = {
        code: this.gb.TOKEN_EMPTY,
        message: "token is empty",
      };
      this._onSign(m);
    }
  }

  __collect() {
    var T = this.Cw(1);
    T.fp = this._fingerprint;
    var P = JSON.stringify(T, null, 2);
    this.S_(this._debug, "__collect envCollect=".concat(P));
    var I = CryptoJS.AES.encrypt(P, CryptoJS.enc.Utf8.parse("DNiHi703B0&17hh1"), {
      iv: CryptoJS.enc.Utf8.parse("0102030405060708"),
    });
    return I.ciphertext.toString();
  }

  async sign(t) {
    try {
      var e = Date.now();
      var o = this.__checkParams(t);
      if (o == null) {
        return t;
      }
      await this.__requestDeps();
      var collectedData = this.__collect();
      var a = this.__makeSign(o, collectedData);
      this.S_(this._debug, "sign elapsed time!".concat(Date.now() - e, "ms"));
      return Object.assign({}, t, a);
    } catch (e) {
      var J = {
        code: this.gb.UNHANDLED_ERROR,
        message: "unknown error",
      };
      this._onSign(J);
      return t;
    }
  }

  getSync(e) {
    return this.map.get(e);
  }

  removeSync(e) {
    this.map.delete(e);
  }

  setSync(k, v) {
    this.map.set(k, v);
  }

  Cw(o) {
    var temp = this;

    function mw(t) {
      if (temp.cookieStr) {
        var r = new RegExp("(^| )" + t + "(?:=([^;]*))?(;|$)"),
          n = temp.cookieStr.match(r);
        if (!n || !n[2]) return "";
        var e = n[2];
        try {
          return /(%[0-9A-F]{2}){2,}/.test(e) ? decodeURIComponent(e) : unescape(e);
        } catch (t) {
          return unescape(e);
        }
      }
    }
    function d_() {
      var t,
        r = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
        n = r.size,
        e = void 0 === n ? 10 : n,
        o = r.dictType,
        i = void 0 === o ? "number" : o,
        a = r.customDict,
        u = "";
      if (a && "string" == typeof a) t = a;
      else
        switch (i) {
          case "alphabet":
            t = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            break;
          case "max":
            t = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
            break;
          case "number":
          default:
            t = "0123456789";
        }
      for (; e--; ) u += t[(Math.random() * t.length) | 0];
      return u;
    }

    var ft = ["pp", "sua", "random", "referer", "v", "extend"];
    var ct = {};
    var st = function (key, func) {
      try {
        if ((o === 1 && ft.includes(key)) || o === 0) {
          ct[key] = func();
        }
      } catch (e) {
        console.log(e);
      }
    };

    st("wc", function (t) {
      //   return /Chrome/.test(window.navigator.userAgent) && !window.chrome ? 1 : 0;
      return 0;
    });
    st("wd", function (t) {
      //   return navigator.webdriver ? 1 : 0;
      return 0;
    });
    st("l", function (t) {
      //   return navigator.language;
      return "zh-CN";
    });
    st("ls", function (t) {
      //   return navigator.languages.join(",");
      return "zh-CN,zh";
    });
    st("ml", function (t) {
      //   return navigator.mimeTypes.length;
      return 0;
    });
    st("pl", function (t) {
      //   return navigator.plugins.length;
      return 0;
    });
    st("av", function (t) {
      //   return navigator.appVersion;
      let av = temp.userAgent.match(/(?<=\/)[0-9]\.0[^'"\n]+/g);
      return av.length > 0 ? av[0] : "";
    });
    st("ua", function (t) {
      //   return window.navigator.userAgent;
      return temp.userAgent;
    });
    st("sua", function (t) {
      var regex = new RegExp("Mozilla/5.0 \\((.*?)\\)");
      //   var matches = window.navigator.userAgent.match(regex);
      var matches = temp.userAgent.match(regex);
      return matches && matches[1] ? matches[1] : "";
    });
    st("pp", function (t) {
      var u = {};
      var i = mw("pwdt_id");
      var c = mw("pin");
      var a = mw("pt_pin");
      i && (u.p1 = i);
      c && (u.p2 = c);
      a && (u.p3 = a);
      return u;
    });
    st("extend", function () {
      // var e = navigator.permissions.query({
      //     name: "notifications"
      // })
      // var Y = 0;
      // ("cdc_adoQpoasnfa76pfcZLmcfl_Array" in window || "cdc_adoQpoasnfa76pfcZLmcfl_Promise" in window || "cdc_adoQpoasnfa76pfcZLmcfl_Symbol" in window) && (Y |= 1);
      // ("$chrome_asyncScriptInfo" in window.document || "$cdc_asdjflasutopfhvcZLmcfl_" in window.document) && (Y |= 2);
      // var n = {
      //     pm: Notification.permission === "denied" && e.state === "prompt" ? 1 : 0,
      //     wd: window.navigator.webdriver ? 1 : 0,
      //     l: !navigator.languages || navigator.languages.length === 0 ? 1 : 0,
      //     ls: navigator.plugins.length,
      //     bu1: rm,
      //     wk: Y
      // }
      // return n;
      return { bu1: "0.1.9", l: 0, ls: 0, wd: 0, wk: 0 };
    });
    st("pp1", function (t) {
      var c = mw("pwdt_id");
      var u = mw("pin");
      var a = mw("pt_pin");
      if (!c && !u && !a) {
        var i = temp.cookieStr;
        if (i) return i;
      }
      return "";
    });
    st("pm", function () {
      //   var result = navigator.permissions.query({ name: "notifications" });
      //   return { ps: result.state, np: Notification.permission };
      return {
        ps: "prompt",
        np: "default",
      };
    });
    st("w", function (t) {
      //   return window.screen.width;
      return 1536;
    });
    st("h", function (t) {
      //   return window.screen.height;
      return 864;
    });
    st("ow", function (t) {
      //   return window.outerWidth;
      return 1536;
    });
    st("oh", function (t) {
      //   return window.outerHeight;
      return 864;
    });
    st("url", function (t) {
      //   return location.href;
      return temp.url;
    });
    st("og", function (t) {
      //   return location.origin;
      return temp.origin;
    });
    st("pf", function (t) {
      //   return window.platform;
      return undefined;
    });
    st("pr", function (t) {
      //   return window.devicePixelRatio;
      return 1.25;
    });
    st("re", function (t) {
      //   return document.referrer;
      return "";
    });
    st("random", function (t) {
      return d_({ size: 10, dictType: "max", customDict: null });
    });
    st("referer", function (t) {
      //   var i = new RegExp("[^?]*"),
      //     u = document.referrer.match(i);
      //   if (!u || !u[0]) return "";
      //   return u[0];
      return "";
    });
    st("v", function (t) {
      return "h5_npm_v4.2.0";
    });
    return ct;
  }
}

async function main() {
  var cookieStr = "",
    userAgent =
      "";
  var h5stObj = new h5st(cookieStr, userAgent, {
    debug: false,
    preRequest: false,
    timeout: 2,
    appId: "ea491", 
    onSign: function onSign(e) {
      e.code;
    },
    onRequestTokenRemotely: function onRequestTokenRemotely(e) {
      e.code, e.message;
    },
    onRequestToken: function onRequestToken(e) {
      e.code, e.message;
    },
  });

  var a = await h5stObj.sign({
    functionId: "whx_getShopHomeFloorInfo",
    appid: "shop_m_jd_com",
    clientVersion: "12.0.0",
    client: "wh5",
    body: CryptoJS.SHA256(JSON.stringify({ shopId: "1000002481", source: "m-shop" })).toString(),
  });

  console.log(a);
  //
  // var params = `functionId=whx_getShopHomeFloorInfo&body=${encodeURIComponent(JSON.stringify({ shopId: "1000002481", source: "m-shop" }))}&appid=shop_m_jd_com&client=wh5&clientVersion=12.0.0&h5st=${
  //   a.h5st || ""
  // }`;

   var params = `pc-item-soa&functionId=pc_detailpage_wareBusiness&client=pc&clientVersion=1.0.0&t=1698813236207&body=${encodeURIComponent(JSON.stringify({"skuId":100064564679,"cat":"1319,11842,14936","area":"12_904_907_50559","shopId":"1000008122","venderId":1000008122,"paramJson":"{'platform2':1,'specialAttrStr':'p0ppppppppp2ppppppppppppppp','skuMarkStr':'00'}","num":1,"bbTraffic":""}))}&h5st=${
    a.h5st || ""
  }`;
  console.log( params);

cookie = 'shshshfpa=4b770525-82d6-9dc2-191f-49213e2808af-1693276292; shshshfpx=4b770525-82d6-9dc2-191f-49213e2808af-1693276292; pinId=LxgJESmodokf_AhbrnKClw; pin=jinshiyuan1123; unick=jinshiyuan1123; _tp=qTmSS0pjZ%2BpSltacjzri4w%3D%3D; _pst=jinshiyuan1123; __jdv=76161171|direct|-|none|-|1697592319693; mba_muid=16934744924511616091388; user-key=11a484e2-f35f-4a4f-9827-c95f59dd47eb; __jdu=16983895067841432816868; TrackID=1HFZlWtgARPlbI1mTVFpwZ3u_SB09-1Q_bI6WyUS8IpkISJ6MmmNv6LbsWxET-X7MWNjLiNaACNKV-1Vht0fWcs89QNcw4qXk4Rqhs0xYx08; thor=EEFDDDF33A2E1B1574F38D3AEF89005246E4DF7F7341012C233F05A1CE1050707F2B2C7784309754BA0DF8532A4DF03135775FD5699D900B1443BD2FB2076E4CE284DDE4DF56071F679BE3AC90F368F539C29EBBA1F6CAEB5149648AA360E7948AB67D04395B9891D618EC1E696E8BC2635F84B0B83609EB90421520EB98293C7DF602769976770087AF3D1CBA2510AB; flash=2_7fZdpf_i3XDxiQCGotfuowSRGt_716ZFdTPZqfOjcmExH9AiqitrXU-JV6KP5hIbOio7x8_X8iS7NHJGVpeQRnyZjGY7IVA643W1OyW4DRq*; areaId=12; ipLoc-djd=12-904-907-50559; joyya=1698717531.1698727780.24.0oyeyhv; 3AB9D23F7A4B3C9B=7XKWKVW52FZTKEZTBRHLN5KSUEOMU4POIZAQBRA6ZODCWLPXFZ3VTUJEEWD6VNMV5C6RX3F4J4JIIGCLO65JD33MS4; 3AB9D23F7A4B3CSS=jdd037XKWKVW52FZTKEZTBRHLN5KSUEOMU4POIZAQBRA6ZODCWLPXFZ3VTUJEEWD6VNMV5C6RX3F4J4JIIGCLO65JD33MS4AAAAMLRDXCJ6YAAAAAD7HKTBXNJK6MCMX; __jda=122270672.16983895067841432816868.1698389507.1698735389.1698809391.6; __jdc=122270672; shshshfpb=AAjAp7oiLEncFJYLWncIZH0khPigIrxaTJ2KSSQAAAAA'
  const { data, status } = await axios({
    method: "get",
    url: `https:/api.m.jd.com/?appid=${params}`,
    headers: {
      "origin": "https://item.jd.com",
      "cookie":cookie,
      "x-referer-page":"https://item.jd.com/100064564679.html",
      "User-Agent": userAgent,
    },
  });
  console.log(data);
  console.log(status);
}

main();

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613
  • 614
  • 615
  • 616
  • 617
  • 618
  • 619
  • 620
  • 621
  • 622
  • 623
  • 624
  • 625
  • 626
  • 627
  • 628
  • 629
  • 630
  • 631
  • 632
  • 633
  • 634
  • 635
  • 636
  • 637
  • 638
  • 639
  • 640
  • 641
  • 642
  • 643
  • 644
  • 645
  • 646
  • 647
  • 648
  • 649
  • 650
  • 651
  • 652
  • 653
  • 654
  • 655
  • 656
  • 657
  • 658
  • 659
  • 660
  • 661
  • 662
  • 663
  • 664
  • 665
  • 666
  • 667
  • 668
  • 669
  • 670
  • 671
  • 672
  • 673
  • 674
  • 675
  • 676
  • 677
  • 678
  • 679
  • 680
  • 681
  • 682
  • 683
  • 684
  • 685
  • 686
  • 687
  • 688
  • 689
  • 690
  • 691
  • 692
  • 693
  • 694
  • 695
  • 696
  • 697
  • 698
  • 699
  • 700
  • 701
  • 702
  • 703
  • 704
  • 705
  • 706
  • 707
  • 708
  • 709
  • 710
  • 711
  • 712
  • 713
  • 714
  • 715
  • 716
  • 717
  • 718
  • 719
  • 720
  • 721
  • 722
  • 723
  • 724
  • 725
  • 726
  • 727
  • 728
  • 729
  • 730
  • 731
  • 732
  • 733
  • 734
  • 735
  • 736
  • 737
  • 738
  • 739
  • 740
  • 741
  • 742
  • 743
  • 744
  • 745
  • 746
  • 747
  • 748
  • 749
  • 750
  • 751
  • 752
  • 753
  • 754
  • 755
  • 756
  • 757
  • 758
  • 759
  • 760
  • 761
  • 762
  • 763
  • 764
  • 765
  • 766
  • 767
  • 768
  • 769
  • 770
  • 771
  • 772
  • 773
  • 774
  • 775
  • 776
  • 777
  • 778
  • 779
  • 780
  • 781
  • 782
  • 783
  • 784
  • 785
  • 786
  • 787
  • 788
  • 789
  • 790
  • 791
  • 792
  • 793
  • 794
  • 795
  • 796
  • 797
  • 798
  • 799
  • 800
  • 801
  • 802
  • 803
  • 804
  • 805
  • 806
  • 807
  • 808
  • 809
  • 810
  • 811
  • 812
  • 813
  • 814
  • 815
  • 816
  • 817
  • 818
  • 819
  • 820
  • 821
  • 822
  • 823
  • 824
  • 825
  • 826
  • 827
  • 828
  • 829
  • 830
  • 831
  • 832
  • 833
  • 834
  • 835
  • 836
  • 837
  • 838
  • 839
  • 840
  • 841
  • 842
  • 843
  • 844
  • 845
  • 846
  • 847
  • 848
  • 849
  • 850
  • 851
  • 852
  • 853
  • 854
  • 855
  • 856
  • 857
  • 858
  • 859
  • 860
  • 861
  • 862
  • 863
  • 864
  • 865
  • 866
  • 867
  • 868
  • 869
  • 870
  • 871
  • 872
  • 873
  • 874
  • 875
  • 876
  • 877
  • 878
  • 879
  • 880
  • 881
  • 882
  • 883
  • 884
  • 885
  • 886
  • 887
  • 888
  • 889
  • 890
  • 891
  • 892
  • 893
  • 894
  • 895
  • 896
  • 897
  • 898
  • 899
  • 900
  • 901
  • 902
  • 903
  • 904
  • 905
  • 906
  • 907
  • 908
  • 909
  • 910
  • 911
  • 912
  • 913
  • 914
  • 915
  • 916
  • 917
  • 918
  • 919
  • 920
  • 921
  • 922
  • 923
  • 924
  • 925
  • 926
  • 927
  • 928
  • 929
  • 930
  • 931
  • 932
  • 933
  • 934
  • 935
  • 936
  • 937
  • 938
  • 939
  • 940
  • 941
  • 942
  • 943
  • 944
  • 945
  • 946
  • 947
  • 948
  • 949
  • 950
  • 951
  • 952
  • 953
  • 954
  • 955
  • 956
  • 957
  • 958
  • 959
  • 960
  • 961
  • 962
  • 963
  • 964
  • 965
  • 966
  • 967
  • 968
  • 969
  • 970
  • 971
  • 972
  • 973
  • 974
  • 975
  • 976
  • 977
  • 978
  • 979
  • 980
  • 981
  • 982
  • 983
  • 984
  • 985
  • 986
  • 987
  • 988
  • 989
  • 990
  • 991
  • 992
  • 993
  • 994
  • 995
  • 996
  • 997
  • 998
  • 999
  • 1000
  • 1001
  • 1002
  • 1003
  • 1004
  • 1005
  • 1006
  • 1007
  • 1008
  • 1009
  • 1010
  • 1011
  • 1012
  • 1013
  • 1014
  • 1015
  • 1016
  • 1017
  • 1018
  • 1019
  • 1020
  • 1021
  • 1022
  • 1023
  • 1024
  • 1025
  • 1026
  • 1027
  • 1028
  • 1029

node h5st.js
效果图
在这里插入图片描述

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

闽ICP备14008679号