MASTG Techniques

πŸ“Œ These study notes serve as a concise reference, capturing the essential insights, guidelines, and best practices for securing mobile applications, based on the OWASP MASTG (Mobile Application Security Testing) Standard - Techniques.


🌐 Resources πŸ”—


Android

Device Remote Shell

  • Enable Developer Mode and USB debugging on the device

adb (Android Debug Bridge) - listen port 5037

# USB
adb devices -l
adb shell
adb -s <device_ID> shell
su

# WiFi (same network)
# Set a listener on the device (via USB)
adb tcpip 5555
# Disconnect USB and run from host pc (same network)
adb connect <device_IP>
adb devices
adb shell

# SSH
# On device > Setup Termux (default port 8022)
sshd
# On Host pc
ssh -p 8022 <device_IP>

# "SSH for Magisk" Module can be used too

Data transfer

  • using Android Studio device file explorer

  • using adb

objection - runtime mobile exploration toolkit for security testing on non-rooted devices. Injects the Frida gadget into an application by repackaging it, disable SSL pinning methods, access app storage, execute custom Frida scripts, list activities/services/broadcast receivers, start activities, ecc

  • On rooted device with frida-server configured, Objection can connect directly to it without app repackage.

  • Interact with it via Objection REPL

  • The ability to perform advanced dynamic analysis on non-jailbroken devices is one of the features that makes Objection incredibly useful.

  • using Termux remote access (e.g. SFTP)

Obtaining and Extracting Apps

  • Non-official websites/third party stores like APKMirror, APKPure. Pay attention to the APK that may contain malware!!!

  • Extract the App Package from the Device

Repack & Install App

  • Install apps via adb

App Information Gathering

πŸ”— Reference Training Apps

apktool

πŸ“Œ The Android Manifest is the main source of information, includes package name, permissions, app components, etc.

logcat

Tools:

  • tcpdump

  • netcat

  • Wireshark

  • Traffic Sniffing - tcpdump / Wireshark

OWASP ZAP

Burp Suite

BurpSuite

  • Export cert from BurpSuite in DER format (or download the cert from the http://burpsuite page after setting the Proxy on the device)

ZapProxy

πŸ”— Setting up ZAP for Android

Bypassing the Network Security Configuration

Manual

  • Not always working

πŸ“Œ Starting with Android 7.0 (API level 24), the Android OS will no longer trust user CA certificates by default, unless specified in the application

Obstacles

  • Security controls such as root detection, certificate pinning

  • Client isolation in wireless networks

  • Non-proxy-aware apps: e.g. Xamarin, or the app verifies if proxy is set and doesn't allow any traffic if it is set

  • Proxy detection - bypass using Frida script

Static

Intercepting certificate is not accepted as a valid certificate if the app is implementing SSL Pinning.

Custom Certificate Pinning

Dynamic

More convenient and faster to perform.

Find the correct method to hook by searching for strings and licences files, identifying the used library. Examine the source code (SMALI code) to find methods suited for dynamic instrumentation.

  • Hook each method with Frida and print the arguments. Find the one that prints out a domain name and a cert hash. Modify the arguments to circumvent the implemented pinning.

[...]


Last updated

Was this helpful?