文章来由
心血来潮突然想逆向一下某小程序,于是便有了这篇文章
逆向工具
wxappUnpacker
用来解压和欢迎小程序
pycharm
编写python代码
原理
用android版本登录后打开小程序,然后通过手机把源码传到电脑,导入到开发者工具,然后对源码进行调试即可,一般来说,小程序端的加密会比其他客户端简单很多
关键代码
加密代码
var e = require("../@babel/runtime/helpers/interopRequireDefault"), i = e(require("../@babel/runtime/helpers/typeof")), o = e(require("../service/baseService/login.js")), t = e(require("./../store/store.js")), n = require("./promise/es6-promise.min.js"), a = require("./crypto.js"), r = require("../config/config.js"), s = require("./storage"), d = function(e) {
return new n(function(o, n) {
if (!e) return "";
e.data || (e.data = {});
var d = r.api.code + "" + r.api.version, u = r.api.key, l = r.api.replaceSpecial, p = "object" === (0,
i.default)(e.data) ? JSON.stringify(e.data) : e.data, c = a.aes.en(p, u, l), f = [ "cid=".concat(d), "q=".concat(c) ], g = t.default.data.configure.uid || s.getStore("uid");
g && g.length > 0 && f.push("uid=".concat(g)), o({
cid: d,
q: c,
sign: a.md5(f.sort().join(";") + u),
uid: g
});
});
};
解密代码
success: function(n) {
e.options && !1 === e.options.loading || wx.hideLoading();
var d = null;
if (n.data && "string" == typeof n.data && (d = a.aes.de(n.data, r.api.key, r.api.replaceSpecial),
d = JSON.parse(d)), r.api.debug && console.log("请求参数:", e, "返回结果", d), d && (t.default.data.configure.uid = d.uid,
s.setStore("uid", d.uid)), 5 !== d.code) if ("BASE101" !== d.BASE101) if (7 !== d.code) 1 === d.code ? i && i(d) : wx.showToast({
title: d.msg,
icon: "none",
duration: 2e3
}); else if (e.options && !0 === e.options.needOriginResult) i(d); else {