Android UnCrackable Level 1

alt text

The crack will be performed on a Kali Linux machine.

The installation process for each tool will not be shown, but every step to create the environment will be documented.

To install the .apk, an emulator is required. Create an emulator using the following command:

avdmanager create avd -n Android26 -k "system-images;android-26;default;x86_64" -c 10M

Verify that the device has been installed correctly:

avdmanager list avd

alt text

Start the emulator as follows:

emulator -avd Android26

alt text

Use the following command to list connected devices. Note the device name.

adb devices

alt text

Download UnCrackable-Level1.apk and install it on the emulator. Then open the app.

adb -s emulator-5554 install UnCrackable-Level1.apk

alt text

alt text

The application detects that the device is rooted and immediately closes.

alt text

To bypass this, we need to investigate the app to find the anti-root check.

Android APK Studio will be used for static analysis, although other tools like jadx or apktool can do the same job.

Open Android APK Studio and click “File” -> “Open” -> “APK”, then select UnCrackable-Level1.apk.

alt text

Select the “Decompile java?” checkbox and click “Decompile”.

alt text

I will modify the app to bypass the root detection. Add the attribute android:debuggable="true" in AndroidManifest.xml to allow debugging.

alt text

Navigate to the MainActivity.java file, which is the app’s entry point, and analyze it.

alt text

As shown, a function is triggered when c.a(), c.b(), or c.c() return true. In that case, the app detects root.

alt text

Open class c to study the anti-root protection.

alt text

There we can see:

  • a: detects su in the system path.

  • b: searches for keys containing test-keys.

  • c: searches for programs typically found in emulator environments.

alt text

Back in MainActivity.java, after root is detected, the function a is called. That function displays a message and exits the application. This is exactly what we want to remove.

alt text

Open the .smali file that contains the exit function. In this case it is MainActivity$1.smali.

alt text

Analyzing the code, we can see a call to System.exit. Comment out this line to prevent the application from closing after root is detected.

alt text

In the bottom-left corner, click the hammer icon to build the project.

alt text

Type --force and click “OK”.

alt text

Then click “Project” -> “Sign / export”.

alt text

A key is required to sign the APK. Create a new key pair by clicking “Generate”.

alt text

Enter the following information and click “Generate”:

  • Keystore Path: debug.keystore.

  • Keystore Password: android.

  • Alias: androiddebugkey.

  • Alias Password: android.

alt text

alt text

After the keys are generated, click “Sign”.

alt text

Check the console at the bottom to ensure the process completed successfully with exit code 0.

alt text

If you try to install the recompiled app now, you may see an error because the signature differs from the original.

adb -s emulator-5554 install UnCrackable-Level1.apk

alt text

To avoid this, uninstall the original app and then install the modified one.

alt text

alt text

alt text

adb -s emulator-5554 install UnCrackable-Level1.apk

alt text

Open the app and observe that several error messages appear, but the application no longer exits due to the changes made.

alt text

alt text

alt text

alt text

There is a form requesting a secret string. Try using “secret” and click “Verify” to see what happens.

alt text

alt text

A deeper analysis of the code is required to understand what secret is expected and how to obtain it.

Return to MainActivity.java in APK Studio and check that a.a is validating our secret.

alt text

This function is located in the same folder as MainActivity.java.

alt text

The function uses a hexadecimal key and a Base64 string to verify the secret with AES. The secret is not in plain text, but we have both the Base64 string and the AES decryption key.

alt text

Open CyberChef (https://cyberchef.org), paste the Base64 string, decode it from Base64, and then decrypt it with AES using the hexadecimal key. The secret will be revealed.

alt text

Enter the secret into the app and verify.

alt text

alt text