adb
Description
Android Debug Bridge (adb) is a command-line tool that allows communication with an Android device or emulator. It is used for installing apps, accessing a device shell, managing files, and debugging during Android penetration testing.
Usage 1: List Connected Devices
Lists all Android devices and emulators currently connected.
Command:
adb devices
Usage 2: Install an APK on a Device
Installs an APK file onto the connected Android device. The -d flag directs the install to a connected USB device.
Command:
adb install -d myapp.apk
Usage 3: Install APK Bypassing Low Target SDK Block
If installation fails with INSTALL_FAILED_DEPRECATED_SDK_VERSION error, use the bypass flag.
Command:
adb install --bypass-low-target-sdk-block -d ..\app.apk
Usage 4: Open an Interactive Shell on the Device
Opens a shell session on the connected Android device.
Command:
adb shell
Once inside the shell, common operations include:
cd /data/data
All apps are installed here.
ls -la
Displays the list of all files with their owned user and group.
Usage 5: Switch to a Specific User
After gaining root via adb shell, switch to a specific app user to view files owned by that user.
Command:
su u0_a60
Usage 6: Select a Specific Emulator
When multiple emulators are running, use the -s option to target a specific one.
Command:
adb -s emulator-5556
Usage 7: Access Shared Storage
Navigate to the shared storage directory accessible by all users.
Command:
cd /sdcard
ls -la
The group sdcard_rw can read and write here, which is assigned to any user.
Notes
- In newer versions of Android, logging in as root user does not guarantee access to all application data due to additional security controls.
- Each app's data directory under
/data/datais owned by a unique user, enforcing sandboxing between applications. - The
INSTALL_FAILED_DEPRECATED_SDK_VERSIONerror occurs when the app targets an SDK version lower than what the device requires (e.g., app targets SDK 21 but device requires at least SDK 23).