The Android Manifest is an XML file which contains important metadata about the Android app. This includes the package name, activity names, main activity (the entry point to the app), Android version support, hardware features support, permissions, and other configurations.
Decompiled APK
apktool d apkname.apk
┌─[sheinn101@parrot]─[~/ctf/android]
└──╼ [??]$ apktool d injuredAndroid.apk
I: Using Apktool 2.5.0-dirty on injuredAndroid.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/sheinn101/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
┌─[sheinn101@parrot]─[~/ctf/android/injuredAndroid]
└──╼ [??]$ ls
AndroidManifest.xml apktool.yml assets kotlin lib original res smali unknown
┌─[sheinn101@parrot]─[~/ctf/android/injuredAndroid]
└──╼ [??]$
Find Hardcoded Strings
Often hardcoded strings can be found in resources/strings.xml and also in activity source code.Sometimes you may find client credentials, urls exposed, apikeys, firebase url, etc...
Exported Activity
An exported activity is the one that can be accessed by external components or apps. We can say that exported activities are like Public functions in Java, any other parent class or even package can call them. Let's say you are on your home screen and now you want to start the Twitter app so you’ll click on the app icon to invoke its launcher activity but technically you were already in some activity(home page) and then you started another activity(launching the Twitter app). Now if the launcher activity of the Twitter app isn’t exported(not public) then no one will be able to invoke the activity and the app won’t start. That is why there has to at least one activity exported so other components of android can start it.That can also be XSS attack.
Find android:exported=true in AndroidManifest.xml
Let's find ,we can access that activity anywhere from the phone (could be from different application).
To exploit this, enter adb shell and type this am start [activity name]
Don't forget to add forward slash in front of activity name /.b25lActivity
It will automatically pop up that activity in our phone.
In real world or bug bounty hunting , you need to make sure that activity has any sensitive data or can allow us some UI (like admin panel) which we don't have access to it.
When you find a firebase url , keep that in mind , may be there is some area are not protected. You can check with .json like this.
Dynamic Analysis
Disable SSL Pinning
Patching Apk using Objection
We can use objection for automatically patch the application to bypass SSL Pinning.
Installation : pip3 install objection
┌─[sheinn101@parrot]─[~/ctf/android]
└──╼ [??]$ objection patchapk --source injuredAndroid.apk
No architecture specified. Determining it using `adb`...
Detected target device architecture as: arm64-v8a
Using latest Github gadget version: 15.1.10
Patcher will be using Gadget version: 15.1.10
Detected apktool version as: 2.5.0-dirty
Running apktool empty-framework-dir...
I: Removing 1.apk framework file...
Unpacking injuredAndroid.apk
App already has android.permission.INTERNET
Target class not specified, searching for launchable activity instead...
Reading smali from: /tmp/tmpeohig7rk.apktemp/smali/b3nac/injuredandroid/MainActivity.smali
Injecting loadLibrary call at line: 10
Attempting to fix the constructors .locals count
Current locals value is 0, updating to 1:
Writing patched smali back to: /tmp/tmpeohig7rk.apktemp/smali/b3nac/injuredandroid/MainActivity.smali
Copying Frida gadget to libs path...
Rebuilding the APK with the frida-gadget loaded...
Rebuilding the APK may have failed. Read the following output to determine if apktool actually had an error:
Built new APK with injected loadLibrary and frida-gadget
Performing zipalign
Zipalign completed
Signing new APK.
Signed the new APK
Copying final apk from /tmp/tmpeohig7rk.apktemp.aligned.objection.apk to injuredAndroid.objection.apk in current directory...
Cleaning up temp files...
Sometime this method does not work properly. You can do manually to patch.
Manual Patching
Patch the apk with apktool
apktool -d apkname.apk and download frida-gadget.so from github.