Syntax: java -jar apktool_x.x.x.jar d <.apk file path> -s
d - Tells the tool to decode the APK.
-s - This prevents the disassembly of the dex file and keeps the classes.dex file in the output folder.
APKTool is extremly useful, when you don't have access to the original source code, such as during a "Black-Box" security assessment.
Using APKTool we easily reverse the APK to examine the final AndroidManifest.xml file.
The dex2jar tool is an open-source project for working with .dex and .class files.
For our purposes, we will use it to convert the classes.dex file to a .jar file.
The process of converting from a .dex to a .jar file is important because it allows the use of conventional Java decompiler tools to obtain a code similar to original source code written by the developer.
Dex2jar Cmd's
Windows: d2j-dex2jar.bat <.apk file path/classes.dex path> -o <outputfile.jar>
Linux/MAC: ./d2j-dex2jar.sh <../apk file path/classes.dex path> -o <outputfile.jar>
Note:
Windows:
Linux/Mac:
JD-GUI
JD-GUI is a simple tool capable of decompiling Java .jar files and allows us to browse through the source code of the .class files contained within.
Alternative Tools : Procyon & Fernflower
JD-GUI
Original Code
Decompiled Code
HelloWorld SourceCode
Original Code
Decompiled Code
Ref in R.Class
Proguard
What is Gradle?
Proguard Enabled
Proguard Not Implemented
Static Code Analysis
Tools used for Static Code Analysis:
https://github.com/MobSF/Mobile-Security-Framework-MobSF
2.Qark (Quick Android Review Kit)
https://github.com/linkedin/qark
Static Code Analysis Demo
Option: File > Import Appliance > Browse and select the Null Humla.ova file
Step 1. Start the virtual machine and initiate the MobSF server using the following command;
#cd /home/mobilesec/MobSF/
#python manage.py runserver
Step 2. Access the MobSF Framework using the URL;
http://localhost:8000
Step 3. Upload any .apk file to initiate the scan from the following path;
/home/Documents/Android Humla/APK Files
MobSF
Step 1. Initiate the qark using the following command;
#cd /home/mobilesec/qark-master/qark
#python qarkMain.py
Step 2. Select option 1;
Step 3. select the path to the .apk file
/home/Documents/Android Humla/APK Files/1.Diva APk/Diva.apk
Step 4. select option 1 - to generate a custom APK for exploitation & Option 2 to exit and generate the scan report.
Step 5. View the scan report from the below shown path;
1) MobSF - Dynamic Analyzer
2) Droid Box
https://code.google.com/archive/p/droidbox/
3) NowSecure Mobile Appsec Toolkit