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 version

Optionally add C:\platform-tools to the Windows PATH, then:

adb version

Some 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 version

Optionally make ADB available globally:

sudo cp adb /usr/local/bin/
adb version

On Ubuntu, USB permissions may require:

sudo usermod -aG plugdev $LOGNAME
sudo apt-get install android-sdk-platform-tools-common

Log 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 version

To add it to your PATH:

echo 'export PATH="$PATH:$HOME/platform-tools"' >> ~/.zshrc
source ~/.zshrc

Then:

adb version

2. 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 devices

Example:

List of devices attached
R58M1234567    device

If the status is:

unauthorized

unlock the phone and accept the authorization prompt.

4. Start and Stop the ADB Server

adb start-server
adb kill-server

Restart:

adb kill-server
adb start-server

5. Basic Device Information

Android version:

adb shell getprop ro.build.version.release

SDK version:

adb shell getprop ro.build.version.sdk

Device model:

adb shell getprop ro.product.model

Manufacturer:

adb shell getprop ro.product.manufacturer

All properties:

adb shell getprop

6. Open an Android Shell

adb shell

Then:

pwd
ls
cd /sdcard

Exit:

exit

Run one command without opening an interactive shell:

adb shell ls /sdcard

7. Install an APK

adb install app.apk

Reinstall while keeping application data:

adb install -r app.apk

Install a test APK:

adb install -t app.apk

8. Uninstall an Application

List packages:

adb shell pm list packages

Uninstall:

adb uninstall com.example.app

9. List Installed Applications

All packages:

adb shell pm list packages

Third-party applications:

adb shell pm list packages -3

Linux/macOS search:

adb shell pm list packages | grep example

Windows search:

adb shell pm list packages | findstr example

10. Inspect an Application

adb shell dumpsys package com.example.app

This 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 logcat

Save logs:

adb logcat > logcat.txt

Clear existing logs:

adb logcat -c

For 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.png

Or save it on the device:

adb shell screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png

15. Record the Screen

Start recording:

adb shell screenrecord /sdcard/demo.mp4

Stop with:

Ctrl+C

Pull the video:

adb pull /sdcard/demo.mp4

16. Launch an Application Activity

If the package and activity are known:

adb shell am start -n com.example.app/.MainActivity

17. 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 devices

18. Useful Commands for Android Security Testing

adb devices
adb shell
adb shell pm list packages -3
adb shell dumpsys package com.example.app
adb shell dumpsys activity
adb shell getprop
adb logcat
adb install app.apk
adb uninstall com.example.app
adb pull <remote-file> <local-path>
adb push <local-file> <remote-path>
adb shell am start -n com.example.app/.MainActivity

ADB 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 components

ADB 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.