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

96 lines
4.2 KiB
Markdown
Raw Normal View History

2022-09-30 10:27:15 +00:00
# Google CTF 2018 - Shall We Play a Game?
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<details>
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<summary>Support HackTricks</summary>
2024-02-03 01:15:34 +00:00
2024-07-19 09:08:05 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-07-19 09:08:05 +00:00
{% endhint %}
2022-04-28 16:01:33 +00:00
Download the APK here:
I am going to upload the APK to [https://appetize.io/](https://appetize.io) (free account) to see how the apk is behaving:
2024-05-05 17:56:05 +00:00
![](<../../.gitbook/assets/image (421).png>)
Looks like you need to win 1000000 times to get the flag.
Following the steps from [pentesting Android](./) you can decompile the application to get the smali code and read the Java code using jadx.
Reading the java code:
2024-05-05 17:56:05 +00:00
![](<../../.gitbook/assets/image (495).png>)
2022-04-05 22:24:52 +00:00
It looks like the function that is going print the flag is **m().**
2022-09-30 10:27:15 +00:00
## **Smali changes**
2022-09-30 10:27:15 +00:00
### **Call m() the first time**
Lets make the application call m() if the variable _this.o != 1000000_ to do so, just cange the condition:
```
if-ne v0, v9, :cond_2
```
to:
```
if-eq v0, v9, :cond_2
```
2024-05-05 17:56:05 +00:00
![Before](<../../.gitbook/assets/image (383).png>)
2024-05-05 17:56:05 +00:00
![After](<../../.gitbook/assets/image (838).png>)
Follow the steps of [pentest Android](./) to recompile and sign the APK. Then, upload it to [https://appetize.io/](https://appetize.io) and lets see what happens:
2024-05-05 17:56:05 +00:00
![](<../../.gitbook/assets/image (128).png>)
Looks like the flag is written without being completely decrypted. Probably the m() function should be called 1000000 times.
**Other way** to do this is to not change the instrucction but change the compared instructions:
2024-05-05 17:56:05 +00:00
![](<../../.gitbook/assets/image (840).png>)
**Another way** is instead of comparing with 1000000, set the value to 1 so this.o is compared with 1:
2024-05-05 17:56:05 +00:00
![](<../../.gitbook/assets/image (629).png>)
A forth way is to add an instruction to move to value of v9(1000000) to v0 _(this.o)_:
2024-05-05 17:56:05 +00:00
![](<../../.gitbook/assets/image (414).png>)
2024-05-05 17:56:05 +00:00
![](<../../.gitbook/assets/image (424).png>)
2022-09-30 10:27:15 +00:00
## Solution
2024-04-06 16:25:58 +00:00
Make the application run the loop 100000 times when you win the first time. To do so, you only need to create the **:goto\_6** loop and make the application **jump there if `this.o`** does not value 100000:
2024-05-05 17:56:05 +00:00
![](<../../.gitbook/assets/image (1090).png>)
You need to do this inside a physical device as (I don't know why) this doesn't work in an emulated device.
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<details>
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<summary>Support HackTricks</summary>
2024-02-03 01:15:34 +00:00
2024-07-19 09:08:05 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-07-19 09:08:05 +00:00
{% endhint %}