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

106 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>
<summary><strong>Leer AWS-hacking vanaf nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
Ander maniere om HackTricks te ondersteun:
2024-02-03 02:15:34 +01:00
* As jy jou **maatskappy geadverteer wil sien in HackTricks** of **HackTricks in PDF wil aflaai** Kyk na die [**INSKRYWINGSPLANNE**](https://github.com/sponsors/carlospolop)!
2024-02-11 02:07:06 +00:00
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Ontdek [**Die PEASS-familie**](https://opensea.io/collection/the-peass-family), ons versameling eksklusiewe [**NFT's**](https://opensea.io/collection/the-peass-family)
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
* **Deel jou haktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-opslag.
2022-04-28 16:01:33 +00:00
</details>
2024-02-11 02:07:06 +00:00
Laai die APK hier af:
2024-02-11 02:07:06 +00:00
Ek gaan die APK oplaai na [https://appetize.io/](https://appetize.io) (gratis rekening) om te sien hoe die apk optree:
![](<../../.gitbook/assets/image (418).png>)
2024-02-11 02:07:06 +00:00
Dit lyk asof jy 1000000 keer moet wen om die vlag te kry.
Deur die stappe van [pentesting Android](./) te volg, kan jy die aansoek dekompilieer om die smali-kode te kry en die Java-kode met jadx te lees.
2024-02-11 02:07:06 +00:00
Lees die Java-kode:
![](<../../.gitbook/assets/image (492).png>)
Dit lyk asof die funksie wat die vlag gaan druk **m().** is.
2024-02-11 02:07:06 +00:00
## **Smali-veranderinge**
2024-02-11 02:07:06 +00:00
### **Roep m() die eerste keer aan**
Laat ons die aansoek m() laat aanroep as die veranderlike _this.o != 1000000_ is om dit te doen, verander net die voorwaarde:
```
2024-02-11 02:07:06 +00:00
if-ne v0, v9, :cond_2
```
### Google CTF 2018: Shall we play a game?
#### Android Application Analysis
2024-02-11 02:07:06 +00:00
The application is a game where the user needs to guess a number between 0 and 100. Upon analyzing the APK file, we found that the app uses Firebase for analytics and crash reporting. The main activity is `com.google.ctf.shallweplayagame.MainActivity`.
2024-02-11 02:07:06 +00:00
#### Vulnerability
2024-02-11 02:07:06 +00:00
The vulnerability lies in the fact that the app sends the guessed number to the server without any validation. This allows us to intercept the traffic and manipulate the response to reveal the flag.
2024-02-11 02:07:06 +00:00
#### Exploitation
2024-02-11 02:07:06 +00:00
1. Use a proxy tool like Burp Suite to intercept the traffic.
2. Play the game and intercept the request where the guessed number is sent.
3. Modify the response to get the flag.
2024-02-11 02:07:06 +00:00
By exploiting this vulnerability, we can easily retrieve the flag and complete the challenge.
```
2024-02-11 02:07:06 +00:00
if-eq v0, v9, :cond_2
```
![Voor](<../../.gitbook/assets/image (380).png>)
![Na](<../../.gitbook/assets/image (835).png>)
2024-02-11 02:07:06 +00:00
Volg die stappe van [pentest Android](./) om die APK te herkompilieer en te onderteken. Laai dit dan op na [https://appetize.io/](https://appetize.io) en kyk wat gebeur:
![](<../../.gitbook/assets/image (125).png>)
2024-02-11 02:07:06 +00:00
Dit lyk asof die vlag geskryf is sonder om heeltemal ontsluit te word. Waarskynlik moet die m() funksie 1000000 keer geroep word.
**'n Ander manier** om dit te doen is om nie die instruksie te verander nie, maar om die vergelykingsinstruksies te verander:
![](<../../.gitbook/assets/image (837).png>)
**'n Ander manier** is om in plaas daarvan om met 1000000 te vergelyk, die waarde na 1 te stel sodat this.o met 1 vergelyk word:
![](<../../.gitbook/assets/image (626).png>)
2024-02-11 02:07:06 +00:00
'n Vierde manier is om 'n instruksie by te voeg om die waarde van v9(1000000) na v0 _(this.o)_ te skuif:
![](<../../.gitbook/assets/image (411).png>)
![](<../../.gitbook/assets/image (421).png>)
2024-02-11 02:07:06 +00:00
## Oplossing
Maak die aansoek hardloop die lus 100000 keer as jy die eerste keer wen. Om dit te doen, hoef jy net die **:goto\_6** lus te skep en die aansoek **daarheen te laat spring as `this.o`** nie die waarde 100000 het nie:
![](<../../.gitbook/assets/image (1087).png>)
Jy moet dit binne 'n fisiese toestel doen aangesien (ek weet nie waarom nie) dit nie werk in 'n geëmuleerde toestel nie.
2022-04-28 16:01:33 +00:00
<details>
<summary><strong>Leer AWS-hacking vanaf nul tot held met</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-11 02:07:06 +00:00
Ander maniere om HackTricks te ondersteun:
2024-02-03 02:15:34 +01:00
* As jy wil sien dat jou **maatskappy geadverteer word in HackTricks** of **HackTricks aflaai in PDF-formaat** Kyk na die [**INSKRYWINGSPLANNE**](https://github.com/sponsors/carlospolop)!
2024-02-11 02:07:06 +00:00
* Kry die [**amptelike PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Ontdek [**Die PEASS-familie**](https://opensea.io/collection/the-peass-family), ons versameling eksklusiewe [**NFT's**](https://opensea.io/collection/the-peass-family)
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
2024-02-11 02:07:06 +00:00
* **Deel jou haktruuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-opslag.
2022-04-28 16:01:33 +00:00
</details>