Introduction
ADB (Android Debug Bridge) is a command-line tool included in Android SDK Platform-Tools. It allows a workstation to communicate with an Android device or emulator for installing applications, collecting logs, transferring files, opening a shell, and Android security testing.
Official documentation:
1. Install ADB
ADB is included in the Android SDK Platform-Tools package.
Windows
Download SDK Platform-Tools for Windows, extract it, for example:
C:\platform-tools\Open PowerShell:
cd C:\platform-tools
.\adb.exe versionOptionally add C:\platform-tools to the Windows PATH, then:
adb versionSome Android devices may require an appropriate OEM USB driver.
Linux
Download and extract Platform-Tools:
unzip platform-tools-latest-linux.zip
cd platform-tools
./adb versionOptionally make ADB available globally:
sudo cp adb /usr/local/bin/
adb versionOn Ubuntu, USB permissions may require:
sudo usermod -aG plugdev $LOGNAME
sudo apt-get install android-sdk-platform-tools-commonLog out and back in after changing group membership.
macOS
Download and extract the macOS Platform-Tools package:
unzip platform-tools-latest-darwin.zip
cd platform-tools
./adb versionTo add it to your PATH:
echo 'export PATH="$PATH:$HOME/platform-tools"' >> ~/.zshrc
source ~/.zshrcThen:
adb version2. Enable USB Debugging
On Android:
Settings → About phone → Build number
Tap Build number several times until Developer Options are enabled.
Then:
Settings → Developer options → USB debugging → ON
Connect the device to the computer and accept the USB debugging authorization prompt.
3. Check the Device
adb devicesExample:
List of devices attached
R58M1234567 deviceIf the status is:
unauthorizedunlock the phone and accept the authorization prompt.
4. Start and Stop the ADB Server
adb start-serveradb kill-serverRestart:
adb kill-server
adb start-server5. Basic Device Information
Android version:
adb shell getprop ro.build.version.releaseSDK version:
adb shell getprop ro.build.version.sdkDevice model:
adb shell getprop ro.product.modelManufacturer:
adb shell getprop ro.product.manufacturerAll properties:
adb shell getprop6. Open an Android Shell
adb shellThen:
pwd
ls
cd /sdcardExit:
exitRun one command without opening an interactive shell:
adb shell ls /sdcard7. Install an APK
adb install app.apkReinstall while keeping application data:
adb install -r app.apkInstall a test APK:
adb install -t app.apk8. Uninstall an Application
List packages:
adb shell pm list packagesUninstall:
adb uninstall com.example.app9. List Installed Applications
All packages:
adb shell pm list packagesThird-party applications:
adb shell pm list packages -3Linux/macOS search:
adb shell pm list packages | grep exampleWindows search:
adb shell pm list packages | findstr example10. Inspect an Application
adb shell dumpsys package com.example.appThis can provide information about an installed package, including activities, permissions, services, and receivers.
11. Pull Files From Android
adb pull /sdcard/test.txt .Example:
adb pull /sdcard/DCIM/photo.jpg .12. Push Files to Android
adb push test.txt /sdcard/Example:
adb push app.apk /sdcard/Download/13. View Android Logs
Live logs:
adb logcatSave logs:
adb logcat > logcat.txtClear existing logs:
adb logcat -cFor security testing, logcat can help investigate crashes, exceptions, debugging information, authentication flows, and runtime behavior.
14. Take a Screenshot
Directly save a screenshot to the computer:
adb exec-out screencap -p > screenshot.pngOr save it on the device:
adb shell screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png15. Record the Screen
Start recording:
adb shell screenrecord /sdcard/demo.mp4Stop with:
Ctrl+CPull the video:
adb pull /sdcard/demo.mp416. Launch an Application Activity
If the package and activity are known:
adb shell am start -n com.example.app/.MainActivity17. Wireless ADB
Android 11 and newer support Wireless Debugging.
On the device:
Developer options → Wireless debugging → Pair device with pairing code
Pair:
adb pair <IP>:<PAIRING_PORT>Then connect:
adb connect <IP>:<ADB_PORT>Check:
adb devices18. Useful Commands for Android Security Testing
adb devicesadb shelladb shell pm list packages -3adb shell dumpsys package com.example.appadb shell dumpsys activityadb shell getpropadb logcatadb install app.apkadb uninstall com.example.appadb pull <remote-file> <local-path>adb push <local-file> <remote-path>adb shell am start -n com.example.app/.MainActivityADB Quick Reference
| Task | Command | |---|---| | Check ADB | adb version | | List devices | adb devices | | Start server | adb start-server | | Stop server | adb kill-server | | Open shell | adb shell | | Device model | adb shell getprop ro.product.model | | Android version | adb shell getprop ro.build.version.release | | SDK version | adb shell getprop ro.build.version.sdk | | List packages | adb shell pm list packages | | Third-party packages | adb shell pm list packages -3 | | Install APK | adb install app.apk | | Reinstall APK | adb install -r app.apk | | Uninstall APK | adb uninstall package.name | | Package information | adb shell dumpsys package package.name | | Logs | adb logcat | | Pull file | adb pull remote local | | Push file | adb push local remote | | Screenshot | adb exec-out screencap -p > screen.png | | Screen recording | adb shell screenrecord /sdcard/demo.mp4 | | Execute shell command | adb shell <command> | | Wireless pairing | adb pair IP:PORT | | Wireless connection | adb connect IP:PORT |
ADB in an Android Security Testing Workflow
Android Device / Emulator
│
│ ADB
▼
Workstation
│
├── Install APK
├── Inspect package information
├── Collect logcat
├── Interact with application
├── Pull / push test files
└── Launch application componentsADB is one of the fundamental tools used when working with Android applications. It provides the communication layer between the testing workstation and an Android device or emulator.
Note: Perform security testing only on applications and devices you own or are explicitly authorized to test.