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

90 lines
5.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
<details>
2023-04-25 18:35:28 +00:00
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
2022-04-28 16:01:33 +00:00
2022-09-30 10:27:15 +00:00
* Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2023-04-25 18:35:28 +00:00
* **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2022-12-24 19:19:02 +00:00
* **Share your hacking tricks by submitting PRs to the** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **and** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud).
2022-04-28 16:01:33 +00:00
</details>
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:
2022-12-24 19:34:46 +00:00
![](<../../.gitbook/assets/image (46).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:
2022-12-24 19:34:46 +00:00
![](<../../.gitbook/assets/image (47).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
```
2022-12-24 19:34:46 +00:00
![Before](<../../.gitbook/assets/image (48).png>)
2022-12-24 19:34:46 +00:00
![After](<../../.gitbook/assets/image (49).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:
2022-12-24 19:34:46 +00:00
![](<../../.gitbook/assets/image (50).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:
![](<../../.gitbook/assets/image (55).png>)
**Another way** is instead of comparing with 1000000, set the value to 1 so this.o is compared with 1:
2022-09-30 10:43:59 +00:00
![](<../../.gitbook/assets/image (57).png>)
A forth way is to add an instruction to move to value of v9(1000000) to v0 _(this.o)_:
2022-09-30 10:43:59 +00:00
![](<../../.gitbook/assets/image (58).png>)
2022-09-30 10:43:59 +00:00
![](<../../.gitbook/assets/image (52).png>)
2022-09-30 10:27:15 +00:00
## Solution
2022-09-30 10:27:15 +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 **junp there if \_this.o**\_\*\* does not value 100000\*\*:
![](<../../.gitbook/assets/image (59).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
<details>
2023-04-25 18:35:28 +00:00
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
2022-04-28 16:01:33 +00:00
2022-09-30 10:27:15 +00:00
* Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2023-04-25 18:35:28 +00:00
* **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2022-12-24 19:19:02 +00:00
* **Share your hacking tricks by submitting PRs to the** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **and** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud).
2022-04-28 16:01:33 +00:00
</details>