样本
某医药app, 难度 ** 两颗星 适合新手练习研究
- 版本:202010026
登陆
随便输一个错误的账号密码: 17283828172 密码 123456789
:method: POST
:path: /user/login?name=17323481511&pwd=25f9e794323b453885f5181f1b624d0b&rgid=A2wfNHM-ClERyMu_hyI4lsFDtd99rPZmsasc-hkl3wS&model=OnePlus-GM1900&first_installation=1605591697&channel=yaozh_web&timeStamp=1605591921&randStr=oWs93HdddyRjQ8LwucC&signature=683A4362f83DA50Dsdf62C5C693415FAE2C91&client=Android&version=3.9.0.0
返回数据
"SURTB0VWG1tqakgRUwkABkQMUAJTB1odRF1BVkcCQ9uGwNLphtOB7NSa\/NaszkYe"
页面显示:
{"code":11018,"msg":"账号不存在"}
name
用户名明文pwd
密码 明文+md5kkkkkrgid
手机idmodel
手机型号first_installation
时间戳channel
固定timeStamp
时间戳randStr
16位随机字符串client
固定version
固定signature
通过 timeStamp 与 randStr 计算而来
randStr
结论 16 位随机字符串
- 代码 android.util.SHA
public static String getRandomString() {
PatchProxyResult proxy = PatchProxy.proxy(new Object[0], (Object) null, changeQuickRedirect, true, 5136, new Class[0], String.class);
if (proxy.isSupported) {
return (String) proxy.result;
}
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 16; i++) {
int number = random.nextInt(3);
if (number == 0) {
sb.append((char) ((int) Math.round((Math.random() * 25.0d) + 65.0d)));
} else if (number == 1) {
sb.append((char) ((int) Math.round((Math.random() * 25.0d) + 97.0d)));
} else if (number == 2) {
sb.append(new Random().nextInt(10));
}
}
return sb.toString();
}
signature
params.put(SocialOperation.GAME_SIGNATURE, singStr);
而 SocialOperation.GAME_SIGNATURE
就是字符串 signature
明显就是 通过 timeStamp + randStr 两个参数的值组合起来计算得来的
流程如下
然后通过跟踪得到结果如下:
timeStamp
+randStr
+ 字符串newdb
(如:1605596173Ml8OMpx63e7exvZfnewdb)- 上面得到的值在 sha1 计算得到结果
- 最后上面得到的值在 md5 计算得到最终结果
登陆成功,并返回加密文本了
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-mJP2A2t4-1608254036587)(https://static.zhangkunzhi.com/2020/12/18/16082531926828.jpg?x-oss-process=image/resize,h_400)]
接下来解析返回内容了
这个app我看了下,都是用的同一种方法进行解密的,所以搞定一处其他的如法炮制就行了
我们收到的数据: "SURTB0VWG1tqakgRUwkABkQMUAJTB1odRF1BVkcCQ9uGwNLphtOB7NSa/NaszkYe"
解密完后是:{"code":11018,"msg":"账号不存在"}
经过观察,所有返回数据都是加密的,应该都是同一个解密接口,仔细看找到了:
base.mvp.BasePresenter.addSubscription
看到他用了 Retrofit,看来他们用的 Retrofit http 请求框架, 而 Retrofit 自带了加解密
用法参考文献 看看怎么使用他就知道怎么逆向他了
搜索示例加密关键代码定位:
定位加密函数位置,并跟进
android hooking watch class retrofit.ApiClient$MyGsonResponseBodyConverter
看来基本上定位到了
这是一个自写的解密算法,我们直接 java 调用即可
解密效果如下:
给上 java 解析加密字段代码
package com.example.test;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.lang.String;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import android.util.Base64;
import android.os.Build;
import android.text.TextUtils;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class MainT {
public static void main(String[] args) {
String res = test();
System.out.println("结果" + res);
}
public static String test(){
String txt = "SURTB0VWG1tqakgRUwkABkQMUAJTB1odRF1BVkcCQ9uGwNLphtOB7NSa/NaszkYe";
byte[] bSalts = md5("app2020").getBytes();
byte[] bCiphers = Base64.decode(txt.getBytes(), 0);
ByteBuffer buffer = ByteBuffer.allocate(bCiphers.length);
int idx = 0;
for (byte b : bCiphers) {
if (idx == bSalts.length) {
idx = 0;
}
buffer.put((byte) (bSalts[idx] ^ b));
idx++;
}
return new String(buffer.array());
}
public static String md5(String string) {
try {
String result = "";
for (byte b : MessageDigest.getInstance("MD5").digest(string.getBytes())) {
String temp = Integer.toHexString(b & 255);
if (temp.length() == 1) {
temp = "0" + temp;
}
result = result + temp;
}
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
}
}
}
代码
样本的详细代码和登陆代码就不发出来了,有兴趣的可以私聊博主索取
QQ:362416272
VX: yykkjj0011