re学习笔记(96)攻防世界 - mobile区 - app3

re学习笔记(96)攻防世界 - mobile区 - app3,第1张

re学习笔记(96)攻防世界 - mobile区 - app3

.ab格式,下载工具
nelenkov/android-backup-extractor: Android backup extractor (github.com)

进行解包

java -jar abe.jar unpack app.ab app.tar
tar -xvf app.tar

解压后里面有base.apk,通过GDA打开
MainActivity中点击按钮后指挥启动另一个AnotherActivity

而AnotherActivity中并没有什么有用的信息

可见关键在于在onCreate就执行的a方法
a方法中有一个a类,37行new了a类,38行调用了a类的a方法得到一个字符串
在39行也是调用了a类的a方法,将得到的字符串传入了getWritableDatabase()方法。

public Database getWritableDatabase(String password) {
 return wrap(delegate.getWritableDatabase(password));
}

可以知道这个参数是一个password的用途

而a.a()中又调用了b.b()

b.b()中是进行SHA-1加密后又对字节数组进行了 *** 作

由于是直接拿a.a()的结果当作password,所以可以直接hook该方法得到结果。
为了学习还是研究一下具体的算法

首先String str = uoa.a("Stranger","123456");
然后该重载返回的是两个参数的前四位拼接起来,也就是"Stra1234"
之后调用的uoa.a()的参数是str + uoa.b(str, "123456")
uoa.b调用了b.a(str)也就是md5加密,再对字符数组 *** 作;得到的结果与str相加即为uoa.a()的参数
uoa.a()为b.b(str + b.a(str)+"yaphetshan")
使用java跑出密码,gda解析有问题,使用jeb解析的代码可以直接运行

public class TestMain {
    public static final String a(String arg9) {
        int v0 = 0;
        char[] v2 = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
        try {
            byte[] v1 = arg9.getBytes();
            MessageDigest v3 = MessageDigest.getInstance("MD5");
            v3.update(v1);
            byte[] v3_1 = v3.digest();
            char[] v5 = new char[v3_1.length * 2];
            int v1_1 = 0;
            while(v0 < v3_1.length) {
                int v6 = v3_1[v0];
                int v7 = v1_1 + 1;
                v5[v1_1] = v2[v6 >>> 4 & 15];
                v1_1 = v7 + 1;
                v5[v7] = v2[v6 & 15];
                ++v0;
            }

            return new String(v5);
        }
        catch(Exception v0_1) {
            return null;
        }
    }

    public static final String b(String arg9) {
        int v0 = 0;
        char[] v2 = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
        try {
            byte[] v1 = arg9.getBytes();
            MessageDigest v3 = MessageDigest.getInstance("SHA-1");
            v3.update(v1);
            byte[] v3_1 = v3.digest();
            char[] v5 = new char[v3_1.length * 2];
            int v1_1 = 0;
            while(v0 < v3_1.length) {
                int v6 = v3_1[v0];
                int v7 = v1_1 + 1;
                v5[v1_1] = v2[v6 >>> 4 & 15];
                v1_1 = v7 + 1;
                v5[v7] = v2[v6 & 15];
                ++v0;
            }

            return new String(v5);
        }
        catch(Exception v0_1) {
            return null;
        }
    }

    public static void main(String[] args) {
        String str = "Stra1234";
        System.out.println(b((str+a(str)+"yaphetshan")).substring(0, 7));
    }

}

得到结果ae56f99
之后我们打开附带的数据库文件
加密的sqlite,我这里选择的使用sqlitebrowser来打开,然后输入密码来打开数据库
发现有两张表

查看TencentMicrMsg表,发现

得到数据VGN0ZntIM2xsMF9Eb19ZMHVfTG92M19UZW5jM250IX0=
很明显被base编码了,尝试base64解码
得到Tctf{H3ll0_Do_Y0u_Lov3_Tenc3nt!}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5703534.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存