Android Debug Shell (ADB)
What You Will Learn
- What ADB is and how to use it to interact with Android devices
- How to install, pull, and inspect APKs using ADB
- How to view logs from a running application
- How to merge and sign split APKs
What Is It?
ADB (Android Debug Bridge) is a command-line tool that lets you communicate with a connected Android device. It is part of the Android SDK and is essential for Android security research and mobile penetration testing.
ADB allows you to:
- Install and remove apps
- Run shell commands on the device
- Transfer files to and from the device
- View application logs
- Pull APKs for static analysis
Hands-On
Basic ADB Commands
adb devices # list connected devices
adb connect <IP>:<port> # connect to a device over Wi-Fi
adb shell # open an interactive shell on the device
adb install <path.apk> # install an APK on the device
adb shell pm list packages # list all installed packages
adb shell pm list packages -3 # list only third-party packages
Inspect an App’s Package
# Get detailed information about a package (permissions, activities)
adb shell dumpsys package <package_name>
# Start an activity
adb shell am start <package_name>/<activity_name>
Pull an APK from the Device
Determine the package name of the app:
adb shell pm list packages
List only third-party packages:
adb shell pm list packages -3
Get the full path of the APK file:
adb shell pm path com.example.someapp
Pull the APK file from the device to your machine:
adb pull /data/app/com.example.someapp-2.apk
View Application Logs
adb logcat "MainActivity:V *:S" -v brief
This filters logcat output to only show verbose logs from MainActivity and silences everything else.
Merge Split APKs
Modern apps are often distributed as split APKs (multiple .apk files). To merge them into a single APK:
java -jar APKEditor-1.4.5.jar m -i <directory>
Re-sign an APK
After modifying an APK, it must be re-signed before installation:
java -jar uber-apk-signer-1.2.1.jar --allowResign -a <modified.apk>