To modify the Indian government app mAadhaar so it runs on a rooted device.
This will give us practice using apktool and Jadx.
This tutorial follows a tweetstream by @fs0c131y.
Use Nox, not Bluestacks, because you need to be root.
If you are doing this project after Jan. 2019, the app may have been updated. If you want the APK file I used, you can get it here.
Launch Kali. Connect it to your Genymotion device with adb. Copy the APK file into Kali.
The installation succeeds, as shown below.
On your Genymotion device, launch the mAadhaar app.
A message appears on your phone telling you that you cannot use this app, as shown below.
You can use 64-bit Windows or Kali Linux to run Jadx. Choose one of them and follow the instructions below.
Launch your Windows machine. (Jadx is Java-based, so it should run on other platforms also, but I wrote these instructions using Windows.) Copy the in.gov.uidai.mAadhaarPlus_2018-09-26.apk file into your Windows machine.
First open Control Panal and uninstall all old Java versions.
Download "Windows Offline (64-bit)" version and install it. as shown below.
Download jadx-gui, as shown below.
In Jadx, open the in.gov.uidai.mAadhaarPlus_2018-09-26.apk file.
In the left pane, at the bottom expand Resources.
The contents appear on the right side, as shown below.
as outlined in green in the imager below.
According to the official Android documentation , the first method called when an activity is launched is the "onCreate" method, as shown at the top of the diagram below.
In the left pane, in the top section, expand these items, as shown below.
Click SplashScreenActivity, as shown below.
In the right pane, scroll down to the OnCreate() method.
Notice the two code sections outlined in green in the image below.
The first section is Integrity Verfication, using methods named f.a and f.b to detect app modification.
The second section uses a method named b to detect rooted devices.
We want to disable both these operations.
In the left pane, scroll up and navigate to that module. Here you can find the a() method, as shown below.
This module compares a SHA-256 hash with a hard-coded value to see if the app has been modified.
You need version "v2.3.3-dirty", as shown below. Version 2.3.4 does NOT work.
And instead of using "apktool" in the commands below, use "java -jar apktool_2.3.3.jar".
Copy the in.gov.uidai.mAadhaarPlus_2018-09-26.apk file into Kali.
First we need to find the code to modify.
The main smali file path appears, highlighted in the image below.
Press Q to exit "less".
Scroll down and find the code shown below.
This code calls the f->a and f->b methods, highlighted in yellow in the image below.
If the app is modified, the code sets the parameter "p1" to zero, as highlighted in light gray in the image below.
Change the 0x0 value to 0x1, outlined in green in the image below.
This modification allows us to change the app without being detected.
Scroll down a few lines and find the code shown below.
This code calls a scottyab RootBeer function to detect a rooted phone. If the phone is rooted, it kills the app.
To prevent that, add # characters to comment out the nine lines colored blue in the image below.
Now the app will run on a rooted phone.
The file builds without errors, as shown below.
Android won't run unsigned apps, so we need a signing certificate.
A prompt asks for a "keystore password". Enter password twice.
Then a series of question asks for your name, etc. You can press Enter for each question except the last one, which you must answer yes to, as shown below.
Enter the password of password when you are prompted to.
The app is signed, as shown below.
On your Genymotion virtual Android device, open Settings and tap these items.
It asks whether it can make phone calls. Click ALLOW.
In the "mAadhaar Consent" page, click OK.
In the "Usage Guidelines" page, at the top left, click the leftware-pointing arrow.
You see the app's starting screen, as shown below.
Make sure you can see the start screen, as shown above.
Save the image with the filename "YOUR NAME Proj 14", replacing "YOUR NAME" with your real name.
How to remove the root detection and the anti tampering mechanism from the mAadhaar app by @fs0c131y.