hacktricks/mobile-pentesting/android-app-pentesting/google-ctf-2018-shall-we-play-a-game.md
2023-08-03 19:12:22 +00:00

6.7 KiB
Raw Blame History

Google CTF 2018 - 我们来玩个游戏吧?

☁️ HackTricks 云 ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥

在这里下载 APK

我将上传 APK 到 https://appetize.io/(免费账户)来查看 APK 的行为:

看起来你需要赢得 1000000 次才能获得 flag。

按照 pentesting Android 的步骤,你可以反编译应用程序以获取 smali 代码,并使用 jadx 读取 Java 代码。

阅读 Java 代码:

看起来打印 flag 的函数是 m()

Smali 更改

第一次调用 m()

让应用程序在变量 this.o != 1000000 时调用 m(),只需更改条件:

if-ne v0, v9, :cond_2

/hive/hacktricks/mobile-pentesting/android-app-pentesting/google-ctf-2018-shall-we-play-a-game.md

Google CTF 2018 - Shall we play a game?

Challenge Description

This challenge is an Android application that simulates a game. The goal is to find a vulnerability in the app and exploit it to gain access to the flag.

Initial Analysis

To start the analysis, we can decompile the APK file using tools like JADX or apktool. Once decompiled, we can analyze the source code to identify any potential vulnerabilities.

Reverse Engineering

Upon analyzing the source code, we find that the app uses a custom encryption algorithm to encrypt the flag. The algorithm takes the flag as input and performs a series of mathematical operations to encrypt it. To reverse engineer the algorithm, we can analyze the code and understand the mathematical operations being performed.

Vulnerability Identification

After reverse engineering the encryption algorithm, we identify a vulnerability in the way the encryption key is generated. The key is derived from a hardcoded string, which makes it predictable and easy to guess. This vulnerability allows an attacker to easily decrypt the flag without knowing the encryption algorithm.

Exploitation

To exploit the vulnerability, we can write a script that generates the encryption key based on the hardcoded string. Once we have the key, we can decrypt the flag and obtain the secret information.

Conclusion

This challenge demonstrates the importance of secure encryption algorithms and key generation. Hardcoding encryption keys can lead to vulnerabilities that can be easily exploited by attackers. It is crucial to use strong and unpredictable keys to ensure the security of sensitive information.

if-eq v0, v9, :cond_2

Before

After

按照pentest Android的步骤重新编译和签名APK。然后将其上传到https://appetize.io/,看看会发生什么:

看起来旗帜在没有完全解密的情况下被写入。可能应该调用m()函数1000000次。

另一种方法是不改变指令,而是改变比较的指令:

另一种方法是将比较值设置为1这样this.o将与1进行比较

第四种方法是添加一条指令将v91000000的值移动到v0this.o

解决方案

当你第一次赢得比赛时让应用程序运行循环100000次。为此您只需要创建**goto_6循环,并使应用程序在_this.o**不等于100000时跳转到那里

您需要在物理设备上执行此操作,因为(我不知道为什么)在模拟设备上无法正常工作。

☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥