高二新学期の班牌研究日志 Ep.1

  1. 反编译班牌家长端 App 得到 Http 中加密参数的获取方法
  2. 模拟客户端向服务器发送请求并被接受
  3. 获取Token, 注册账号接口完成
  4. 暴力破解所有班级邀请码(多线程), 共计 5541 个班级

待办: 完成其他接口(e.g., 发送消息, 绑定学生)的 Python API.

逆向 Token 过程:

  1. 使用 jadx 逆向班牌 APP.

  2. 全局搜索 token, 发现如下代码.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    TreeMap treeMap3 = new TreeMap();
    treeMap3.put("systemid", "parent");
    String str7 = Constants.PARAM_ACCESS_TOKEN;
    treeMap3.put("grant_type", "password");
    treeMap3.put("username", string);
    treeMap3.put("inch_timestamp", valueOf);
    StringBuilder sb = new StringBuilder();
    sb.append((String) treeMap3.get("inch_timestamp"));
    Request request2 = request;
    sb.append(f.b(8));
    treeMap3.put("nonce", sb.toString());
    StringBuffer stringBuffer2 = new StringBuffer();
    for (String str8 : treeMap3.keySet()) {
    stringBuffer2.append(str8);
    stringBuffer2.append("=");
    stringBuffer2.append((String) treeMap3.get(str8));
    stringBuffer2.append(a.f1270b);
    }
    stringBuffer2.append("aef2890665d884a3080971b4eca594d7");

    相关方法太多了不一一列出, 但可以发现思路大致就是将所有 Http 请求的参数放入 TreeMap 中, 然后再拼接成字符串取 MD5. 查询 Java 官方文档发现 TreeMap 是基于红黑树实现, iterator 默认按照键的自然顺序排序.

    写成 Python 代码如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    # 经反编译得到的 inch_sign 生成方法
    temp = dict()
    temp['access_token'] = self.token
    try:
    for i in params:
    temp[i] = params[i]
    except Exception as e:
    pass
    temp['inch_timestamp'] = int(round(time.time() * 1000))
    temp['nonce'] = str(temp['inch_timestamp']) + str((random.random() + random.randint(1,9)) * 100000000)[:8]

    temp2 = ''
    for i in sorted(temp.keys()):
    temp2 += str(i) + "=" + str(temp[i]) + "&"
    temp2 += "aef2890665d884a3080971b4eca594d7"

    sign = hashlib.md5(temp2.encode("utf-8")).hexdigest().upper()

打赏支持
“请我吃糖果~o(*^ω^*)o”
高二新学期の班牌研究日志 Ep.1
https://blog.lyc8503.site/post/incich-second-1/
作者
lyc8503
发布于
2019年9月8日
许可协议