x32x01
  • by x32x01 ||
MobSF is an open-source tool developed by Ajin Abraham that is used for automated analysis of an APK. This is a collection of tools that run under one interface, perform their own individual tasks (like Jadx, apktool etc) and display their results under a common interface. These reports can be downloaded in a PDF format too and give out detailed analysis with necessary screenshots as well. You can download MobSF here. In this article, we’ll be walking through the installation phase in Ubuntu OS and guiding you through various options that this tool has to offer.

Table of Content
  • Installation
  • Landing Page
  • Signer Certificate Analysis
  • Application Permissions
  • Browsable Activities & Network Security Analysis
  • Manifest Analysis
  • Code Analysis
  • Related to Malware Analysis
  • Hardcoded secrets
  • Activity Components Present
  • Files Present in APK Packages
  • Dynamic Analyzer
  • Logcat Stream
  • API Monitor
  • Downloading Reports

Let’s begin!

Installation
To install MobSF, create a directory and follow the commands:
Code:
git clone https://github.com/MobSF/Mobile-Security-Framework-MobSF.git
cd Mobile-Security-Framework-MobSF
1.png
We need to install dependencies before we are able to run:
Code:
apt-get install python3-venv
pip3 install -r requirements.txt
2.png
Once done, we can run the setup file to install MobSF and all the components automatically
Code:
./setup.sh
3.png
Now, to run MobSF we execute the run.sh file. As one could interpret from the screenshot below that MobSF would be running on a local server on port 8000.
4.png
Now let’s open the link in the browser and see if MobSF was installed properly or not.
5.png
Landing Page
Now that the MobSF is up and running, we can drag a dummy APK (in this case, I’ll take InjuredAndroid by Kyle Benac ((here)) into the MobSF interface and see what happens. After waiting for a couple of minutes we could see that static analysis of the APK is done. Now here on the landing page, we can see that a severity score is given. The higher this score the more secure app is. Next, hashes, filename and size of the APK are also given. In the third column in the first row, we can also see the package name, main activity, min SDK version and the application version as well. The description of the application is also given.
6.png
After scrolling down a little bit, here’s what all we can see:
  • In small cards, we see different application components
  • Dynamic analysis option that will help MobSF conduct run time analyses
  • Option to view decompiled code. This is the code that is generated by apktool. Generally, the resources file would also be decoded. It is also possible to view smali code. It makes it easier to segregate and view source code in separate java classes using this.
7.png
Signer Certificate Analysis
In the certificate column, we can see the signer certificate where one can find important information about the developer, country, state, type of algo, bit size etc.
8.png
Application Permissions
Further, we can see all the permissions an application has. There are various permissions that are categorized as dangerous or normal. It is important from a security analyst’s point of view to understand which permissions can lead to further damage. For example, if an application has access to external media and stores critical information on the external media it could prove to be dangerous since the files stored on external media are globally readable and writable.
9.png
Browsable Activities & Network Security Analysis
Next, in the browsable activities section, we can see all the activities that have implemented a deep link schema.
In the network security section, one can find some details about network security issues related to the application. These issues can lead to critical attacks like MiTM sometimes. For example, in the screenshot below, one can find that the application isn’t using the SSL pinning mechanism implemented.
10.png
Manifest Analysis
In the next section, MobSF has analysed the manifest file. One can find many folds of information from the android manifest file like which activities are exported, if the app debuggable or not, data schemas etc. For reference look at the screenshot below.
11.png
Code Analysis
One of the most interesting features of the MobSF tool is the code analysis section. In this section, we can see that MobSF has analysed and compared some behaviour of the application based on industry security standard practices like OWASP MSTG and mapped the vulnerabilities with OWASP Top 10. It is interesting to see CWE mentioned and CVSS score being assigned here which might help various analyst scenarios and help the creation of reports way easier.
13.png
Related to Malware Analysis
MobSF also hosts a section where an APKiD analysis is given. APKiD is an open-source tool that is very helpful to identify various packers, compilers, obfuscators etc in android files. It is analogous to PEiD in APK. Here one can see that it has detected an anti-vm code in the APK.
14.png
Something related to malware analysis is the domain malware check feature. Here, MobSF is extracting all the URLs/IP addresses that are hard-coded or being used in the application and shows its malware status as well as uses ip2location to give out its geolocation as well.
15.png
A comprehensive strings analysis is also available. People who are aware of malware analysis know about strings in-depth but for those of you who don’t, strings are ASCII and Unicode-printable sequences of characters embedded within a file. Extracting strings can give clues about the program functionality and indicators associated with a suspect binary. For example, if an APK shows something as an output so that stream would be called and hence shown in the strings. This is not the same as strings.xml file. Many times, a third party IP address with which APK is communicating gets visible here. This is essential from a malware analysis point of view.
16.png
One can also find hardcoded emails in MobSF. This is all done using the decompiled source code. Often a pentester can find critical email IDs that were being used as a credential on a third party site, say, to access the database.
17.png
Just like emails, URLs are often found hardcoded as well. One can find juicy URLs that are being used sometimes. Oftentimes analysts find malicious URLs being accessed as well or even a C&C server.
18.png
Hardcoded secrets
Oftentimes developers have this habit of storing critical keys like AWS ID and credentials in strings.xml and use an object as a reference in java activity. But doing this doesn’t help in any which way since strings.xml can be decoded easily.
19.png
Activity Components Present
A list of all the activities present can also be scrolled using MobSF. This gives an insight into the skeleton of the android APK. Also sometimes jadx replaces the real names of the class with some random letter if the developer has applied obfuscation, MobSF can associate its real name too (doesn’t happen all the time or in cases of strong obfuscation).
20.png
Quite similarly an analyst can also traverse services, broadcast, providers and content receivers along with all the files present in the APK archive to create a map of all the resources present in the application.
21.png
Dynamic Analyzer
For dynamic analysis, we’d need to fire up android VM in genymotion first. Here I’ve created an android VM on version 7.1
22.png
When you press the dynamic analyser option present on the top navigation pane, MobSF will automatically attach itself to VM running if MobSF and genymotion are running on the same base machine. However, if MobSF is in another virtual machine, you might have to attach MobSF agent to genymotion’s VM’s remote IP and port. Once it is attached, we see the following screen.
23.png
Under the analyzer status bar we can see various default frida scripts available that would check various basic vulnerabilities like SSL Pinning bypass and Root detection checks. There are other auxiliary scripts as well that lets an analyst enumerate various classes and also capture string comparisons in real time (again helpful for malware analysts point of view). Then simply click on start instrumentation and the selected scripts will be attached to the application automatically. Hence, if I have selected SSL Pinning bypass script and traffic is getting captured (visible in log or API monitor later) that would mean SSL Pinning has got bypassed.
24.png
Now further, to analyse activities for vulnerabilities one can see two buttons on the top for both exported and non exported activities
25.png
Similarly, if one doesn’t have to make do with pre-configured Frida scripts, it is also possible that Frida script be pasted in the text box on the right. There is also a dropdown box that would load those scripts. You can also edit the same.
26.png
Logcat Stream
Logcat can also be viewed in MobSF’s native environment. There’s a button at the top menu that lets one view this.
27.png
API Monitor
Just like logcat monitors device logs, APIs can also be monitored. APKs use various APIs in real-time to perform various functions, for example, the Base64 library.
28.png
Hence, if a function is using this API and decrypting a value we can see that value here and decode that. For example, down below you can see the return value of once such function in Base64.
29.png
Downloading Reports
Once you have done the analysis, it is possible to download the report by sliding the menu bar slider on the left-hand side and click generate the report.
30.png
You might notice some errors while generating reports. To resolve this, you can follow the below command and install wkhtmltopdf module:
Code:
apt-get install wkhtmltopdf
31.png
Now, once again if you click on a recent scan bar, you’ll see static and dynamic report generation options.
32.png
The report looks something like this:
33.png
Conclusion
MobSF is a great tool for the conduction of automated analysis on android APKs. It doesn’t cover analysis of all the vulnerabilities and many tests can only be conducted manually but it is a nifty little tool that helps analysts up to a great extent. Thanks for reading.
 

Similar Threads

x32x01
Replies
0
Views
117
x32x01
x32x01
x32x01
Replies
0
Views
135
x32x01
x32x01
x32x01
Replies
0
Views
132
x32x01
x32x01
x32x01
Replies
0
Views
141
x32x01
x32x01
x32x01
Replies
0
Views
166
x32x01
x32x01
TAGs: Tags
automated analysis mobsf

Register & Login Faster

Forgot your password?

Latest Resources

Forum Statistics

Threads
517
Messages
518
Members
45
Latest Member
Tacola
Back
Top