Skip to content

MASTG-TOOL-0004: adb

adb, shipped with the Android SDK, bridges the gap between your local development environment and a connected Android device. You'll usually leverage it to test apps on the emulator or a connected device via USB or Wi-Fi. Use the adb devices command to list the connected devices and execute it with the -l argument to retrieve more details on them.

$ adb devices -l
List of devices attached
090c285c0b97f748 device usb:1-1 product:razor model:Nexus_7 device:flo
emulator-5554    device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:1

adb provides other useful commands, such as adb shell to start an interactive shell on a target and adb forward to forward traffic on a specific host port to a different port on a connected device.

adb forward tcp:<host port> tcp:<device port>
$ adb -s emulator-5554 shell
root@generic_x86:/ # ls
acct
cache
charger
config
...

You'll come across different use cases on how you can use adb commands when testing later in this book. Note that you must define the serial number of the target device with the -s argument (as shown by the previous code snippet) in case you have multiple devices connected.

Techniques

MASTG-TECH-0031: Debugging MASTG-TECH-0004: Repackaging Apps MASTG-TECH-0003: Obtaining and Extracting Apps MASTG-TECH-0128: Performing a Backup and Restore of App Data MASTG-TECH-0011: Setting Up an Interception Proxy MASTG-TECH-0009: Monitoring System Logs MASTG-TECH-0127: Inspecting an App's Backup Data MASTG-TECH-0001: Accessing the Device Shell MASTG-TECH-0126: Obtaining App Permissions MASTG-TECH-0010: Basic Network Monitoring/Sniffing MASTG-TECH-0002: Host-Device Data Transfer MASTG-TECH-0052: Accessing the Device Shell

Tests

MASTG-TEST-0028: Testing Deep Links MASTG-TEST-0200: Files Written to External Storage MASTG-TEST-0207: Runtime Storage of Unencrypted Data in the App Sandbox

Demos

MASTG-DEMO-0078: App Leaking Sensitive Data via Notifications MASTG-DEMO-0001: File System Snapshots from External Storage MASTG-DEMO-0010: File System Snapshots from Internal Storage