LoopAndLoop【安卓逆向】

LoopAndLoop(阿里CTF)

  • 首先是通用步骤

    解压附件后发现是APK文件,打开jeb进行反编译,反编译结果如下:

    可以看到程序自定了几个check函数,并且调用了自定义库"lhm"。其中chec函数是native层的原生函数(函数名前面的声明中有native),所以接下来需要分析库文件lhm.so。

  • 分析动态链接库文件

    用IDA打开lhm.so文件(在/lib/armeabi目录下),打开字符串窗口(shift+f12),找到MainActivity文件,点进去之后再点击蓝色向上的箭头,进入目标函数。

    目标函数的内容如下:

    GetMethodID():获取java方法的ID

    CallIntMethod():调用 Java 对象的返回值为 int的方法

    可以看到,该函数的功能就是根据a4(参数4)的值调用checkx函数对输入数字进行处理。每次调用checkx函数,a4的值都要减1。

  • 代码逆向

    根据上述分析,可以得到逆向代码如下:

    python 复制代码
    def check1(arg1,arg2):
        t = arg1
        for i in range(1, 100):
            t -= i
        return t
    
    def check2(arg1,arg2):
        t = arg1
        if arg2%2 == 0:
            for i in range(1, 1000):
                t -= i
            return t
        else:
            for i in range(1, 1000):
                t += i
            return t
    
    def check3(arg1,arg2):
        t = arg1
        for i in range(1,10000):
            t -= i
        return t
    
    input_num = 0x6D6F1462
    
    for i in range(2, 100):
        if 2*i%3 == 0:
            input_num = check1(input_num, i-1)
        elif 2*i%3 == 1:
            input_num = check2(input_num, i-1)
        else:
            input_num = check3(input_num, i-1)
    print(input_num)

    运行后,得到密码:236492408,在app中输入密码即可得到flag:

相关推荐
hengdonghui6 小时前
Writeup 4 2020 - 之江杯 - 异常的流量分析
wireshark·ctf·流量分析
hengdonghui12 小时前
Writeup 4 津门杯 2021 Web hate_php
php·web·ctf·通配符
hengdonghui16 小时前
Writeup 4 红帽杯 2021 Web Find_It
web·ctf·备份文件泄露
hengdonghui1 天前
Writeup 4 强网杯 2019 强网先锋打野
ctf·misc·zsteg
hengdonghui2 天前
Writeup 4 NUAA 2017 robots
android·ctf·re
hengdonghui2 天前
Writeup 4 CSS CTF Semester 2 2026 - Lamp Drill
ctf·re
hengdonghui2 天前
Writeup 4 CSS CTF Semester 2 2026 Cryptography Chrono I
ctf·维吉尼亚密码·crypto
hengdonghui3 天前
Writeup 4 CSS CTF Semester 2 2026 - Dead Faction Servers
ctf·osint
hengdonghui4 天前
Writeup 4 2020 - 之江杯 - 工控现场的恶意扫描
wireshark·ctf·流量分析
hengdonghui4 天前
Writeup 4 2020 - 之江杯 - 异常的工程文件
ctf·工控