|
| 1 | +--- |
| 2 | +author: Devilsharu |
| 3 | +layout: post |
| 4 | +date: 2024-05-15 22:37:01 +0200 |
| 5 | +tags: reverse android |
| 6 | +title: "Uncrackable2" |
| 7 | +excerpt_separator: <!--more--> |
| 8 | +--- |
| 9 | + |
| 10 | +This android challenge is the second one of a series of challenges offered by *OWASP Mobile Application Security*. |
| 11 | + |
| 12 | +**Make sure to check the writeup for the first one here, as some of its elements will be referred to and will lack of details in the current writeup : [Uncrackable1](https://basilics.github.io/2024/05/15/Uncrackable1.html)** |
| 13 | + |
| 14 | +<!--more--> |
| 15 | + |
| 16 | + |
| 17 | +## Understanding the app |
| 18 | + |
| 19 | +This app is pretty much like the first one. |
| 20 | + |
| 21 | +The same text field is awaiting for our secret string behind an anti-root wall. |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +Let's dissect the app under Jadx : |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +Once again, MainActivity is the entrypoint. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +We still have an anti-root detection that's done in `onCreate` and `MainActivity.a`. We will try to bypass it with the same method as for the first app. |
| 38 | + |
| 39 | +There also is the `verify` method that probably checks the user input. |
| 40 | + |
| 41 | +There still are a few differences here : |
| 42 | + |
| 43 | +* The native library `libfoo` is loaded. |
| 44 | +* The native function `init` is called at the beginning of `onCreate` |
| 45 | + |
| 46 | +## Finding the secret string |
| 47 | + |
| 48 | +This time, an instance of `CodeCheck` is created as `m` |
| 49 | + |
| 50 | +The verify function calls `m.a` with the user input as argument. |
| 51 | + |
| 52 | +Let's see the `CodeCheck` class : |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +The `a` method calls the native function `bar`. |
| 57 | + |
| 58 | +### Diving into the native library |
| 59 | + |
| 60 | +After unzipping the apk and opening the `libfoo` library with `ida`, we can try to find some information about `bar`. |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +This function, most importantly, stores the string `Thanks for all the fish` into a variable that is then compared to the the returned value of another function. |
| 65 | + |
| 66 | +As we are ~~lazy~~ efficient people, let's assume that is the secret string. |
| 67 | + |
| 68 | + |
| 69 | +## Let's thank for all the fish |
| 70 | + |
| 71 | +In order to bypass the anti-root detector, we can use frida with the same script as in the first app. |
| 72 | + |
| 73 | +``` |
| 74 | +Java.perform(function() { |
| 75 | + const badMethod = Java.use("sg.vantagepoint.uncrackable1.MainActivity").a.overload("java.lang.String"); |
| 76 | + badMethod.implementation = function(str){ |
| 77 | + console.log("Bypassing MainActivity.a"); |
| 78 | + return; |
| 79 | + //return badMethod.call(this,str); |
| 80 | + } |
| 81 | +}); |
| 82 | +``` |
| 83 | + |
| 84 | +And then after launching frida |
| 85 | + |
| 86 | +``` |
| 87 | +┌──(devilsharu㉿Kali)-[~/Documents/OWASP-Mobile] |
| 88 | +└─$ frida -U -f owasp.mstg.uncrackable2 -l uncrack2.js |
| 89 | +``` |
| 90 | + |
| 91 | +Now, we can thank for all the fish ! |
| 92 | + |
| 93 | + |
| 94 | + |
0 commit comments