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 port5037
# 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 tooData 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
π The Android Manifest is the main source of information, includes package name, permissions, app components, etc.
Tools:
tcpdump
netcat
Wireshark
Traffic Sniffing - tcpdump / Wireshark
BurpSuite
Export cert from BurpSuite in DER format (or download the cert from the
http://burpsuitepage after setting the Proxy on the device)
Set Proxy on device WiFi Network
Host with BurpSuite must be on the same WiFi network
ZapProxy
π Setting up ZAP for Android
Bypassing the Network Security Configuration
π MagiskTrustUserCerts
This module will automatically add all user-installed CA certificates to the list of the system trusted CAs (reboot is necessary)
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.
Frida: Use the frida-multiple-unpinning script
Objection (rooted device): Use the android sslpinning disable command
Xposed: Install the TrustMeAlready or SSLUnpinning module.
Custom Certificate Pinning
e.g.App uses BKS (BouncyCastle) truststore
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?