Dynamic Analysis

In the docs, MAHH = Mobile Application Hacker’s Handbook

OWASP Mobile Application Security Checklist

Tools

Drozer

Commands

Drozer commands

PID Cat

Tool showing log entries for a specific application package when debug=true in the application.

Inspeckage

Information gathering

  • Requested Permissions;

  • App Permissions;

  • Shared Libraries;

  • Exported and Non-exported Activities, Content Providers,Broadcast Receivers and Services;

  • Check if the app is debuggable or not;

  • Version, UID and GIDs;

Hooks With the hooks, we can see what the application is doing in real time:

  • Shared Preferences (log and file);

  • Serialization;

  • Crypto;

  • Hashes;

  • SQLite;

  • HTTP (an HTTP proxy tool is still the best alternative);

  • File System;

  • Miscellaneous (Clipboard, URL.Parse());

  • WebView;

  • IPC.

Manual

Exported Activities / Service

One time, I used an exported activity as a very good way to bypass the MFA on an app ☺️

In AndroidManifest.xml, check for exported activities :

Exploit Service (1)

When a service is exported without any permission restriction, any application can bind to the service and access the function implemented in the service.

Exploit Service (2)

  1. Get Services

  1. Exploiting handleMessage() function in sieve (Code analysis of AuthService services)

  • In above request, PIN 1337 can be bruteforced.

  • Refer to Page 211 of MAHH.

  1. Exploiting CryptoService to encrypt a message

The parameters passed in --msg are extra parameters. Analyze code and use the parameters mentioned there, and add extra till 3 parameters are completed. --msg expects three parameters.

Vulnerable Content Provider

A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network.

SQLi's

  1. SQLi on Content provider connected to DB using projection parameter

  1. Automating SQLi on Content Providers

  1. Used to start a localhost server to show content providers and run sqlmap like tools

  1. Automating SQLi scan on all content providers on the device

Traversals

  1. Reading external files using Content Providers

  1. Directory Traversal to read /databases in sieve

  1. Automating Traversals

Insecure Logging

Sensitive information, (usernames, passwords, and other user data), is stored or printed in an insecure manner. This means that this information is easily accessible to anyone with access to the logs, which could potentially be a malicious actor who gains access to the device.

Input Validation Issues

Input data from users, such as login credentials, user input, and other user-generated data, is not properly validated before being used by the application. Check for :

  • SQLi

  • XSS

  • Code Injection

  • BOF

  • File Inclusion

  • etc.

Access Control Issues

Access controls, such as authentication and authorization mechanisms, are not properly implemented or enforced. This can lead to unauthorized access to sensitive information, data theft, and other security breaches.

Try to access "sensitive" activities from outside the app :

What is it ?

Deep links are basically hyperlinks that allow users to directly open specific views inside an android application. Examine the AndroidManifest.xml file and search for android:scheme attributes inside <data> tags to find the deep link defined.

WebView Attacks

WebView is a view that allows an application to load web pages within it. Internally it uses web rendering engines such as Webkit. The Webkit rendering engine was used prior to Android version 4.4 to load these web pages. On the latest versions (after 4.4) of Android, it is done using Chromium. When an application uses a WebView, it is run within the context of the application, which has loaded the WebView. To load external web pages from the Internet, the application requires INTERNET permission in its AndroidManifest.xml file:

  • Accessing sensitive local resources through file scheme When an Android application uses a WebView with user controlled input values to load web pages, it is possible that users can also read files from the device in the context of the target application.

Insecure Broadcast Receiver

BroadcastReceiver is an android component that listens to system-wide broadcast events or intents. Examples of these broadcasts are when your phone’s battery is running low then a broadcast indicating the low battery condition is sent. Some apps could be configured to listen for this broadcast and lower its power consumption and maybe lower the brightness on your screen, etc…

How to Exploit

  1. Examine AndroidManifest.xml

    1. Check for <receiver> tags

  2. Check in the code where the broadcast receiver is, for the onReceivefunction and see how it handles broadcasts it receives.

  3. Try to exploit it by sending customized notification

Exploit Example

  1. Fetch Broadcast Receivers

  1. If an app expects a broadcast receiver to catch an intent and then show authenticated activities, generation of that broadcast is only possible after login. But after code review, an attacker can manually send that intent using drozer. Sample broadcast receiver:

(Page 217 - MAHH)

  1. Intent Sniffing/Catching intents using broadcast receivers which were meant for other Broadcast Receivers

(name of action sending the broadcast)

Weak Cryptography

Use frida to hook some encryption methods and obtain sensitive information like Encryption key, IV Encryption Algorithm, etc…

Object Deserialization

Taking data structured in some format, and rebuilding it into an object.

  • Explanations : https://justahmed.github.io/android/Allsafe-Walkthrough-Part-1/#14-object-serialization

Insecure Providers

The goal is to assess the implementation and see if you can leak both info from the database and sensitive files accessed by the File Provider.

  1. Check AndroidManifest.xml and search for <provider> tags

    1. For this provider :

It is exported, so easier. Query it :

Last updated

Was this helpful?