Starting the adb server in GNOME Terminal, which then enumerates the devices. After that, a shell is opened on the device being debugged to run the uname command.
The Android Debug Bridge (commonly abbreviated as adb) is a programming tool used for the debugging of Android-based devices. The daemon on the Android device connects with the server on the host PC over USB or TCP, which connects to the client that is used by the end-user over TCP. Made available as open-source software under the Apache License by Google since 2007, its features include a shell and the possibility to make backups. The adb software is available for Windows, Linux and macOS. It has been misused by botnets and other malware, for which mitigations were developed such as RSA authentication and device whitelisting.
Some graphical interfaces have been made available. The graphical Android Device Monitor in Android Studio can be used for retrieving information from an Android device.[6]
Android's method to install APK files on a device has been used as a way to sideload unofficial apps onto Windows Subsystem for Android[7] and Chrome OS's Android virtual machine.[8]
Shizuku allows an Android phone to connect to its own ADB when connected to a wireless network. The application is available for free on the Google Play Store.[9]
Development history
The Android Software Development Kit (SDK) was first released in 2007.[10] Since 2017, Google made it possible to download adb separately from the Android SDK.[11]
In 2015, Microsoft released an Android emulator that can connect to the adb client.[12] In 2016 for Android Studio 2.0 a 5x performance improvement was made for installing apps and pushing files through adb.[13] For easier usage of Android Things, a wrapper was made in 2017 around manual adb commands.[14] For Android 11 in 2020, Google added adb incremental installations.[15] In 2020, Wi-Fi adb was integrated into Android Studio for macOS.[16] In 2021 for Android 12, the adb backup command was limited so that backing up user data from apps is opt-in using a per-app manifesto configuration[17] after being deprecated in Android 10 along with adb restore.[18]Fuchsia will be backwards-compatible with adb. It will be replaced with fx and ffx.[19]
Setup
For enabling USB debugging on the Android device, it needs to be enabled in the "developer settings" window
After the device is connected to the host computer, the user needs to verify the RSA key fingerprint of the host computer
Host computer
For Windows, the Android SDK contains the adb.exe binary that can be extracted and installed.[20] How-To Geek recommends adding the folder containing the binaries to the PATH environment variable.[21]
On Ubuntu, adb can be installed with the android-tools-adb package.[22] For Debian, it has been recommended to also install the android-sdk-platform-tools-common package next to the adb package, which installs the udev rules which makes it possible to run the tool without root permissions.[23] For macOS and other Linux distributions, the platform tools can be downloaded and the PATH variable can be modified in bashrc.[24]
Android device
In Android 4.2.2 or later (API level 17), a dialog is shown with an RSA fingerprint that the user needs to accept. This protects against computers exploiting the debugging mechanism without consent of the device user.[25] Starting in Android 4.2, the developer settings are hidden by default. Pressing seven times on the build number in the about menu makes them visible to the user. After that, the USB debugging option can be enabled.[26] Some Android vendors have different procedures to enable it. For example, Huawei requires entering a pincode before adb can be enabled.
If the touchscreen of an Android device is broken, it can be possible to connect a mouse to the device using USB On-The-Go and enable USB debugging.[27][28]
Architecture
The adb protocol can be transported over USB or over Wi-Fi through TCP. It uses a client-server architecture. There are two different protocols in use. The first is between the client and the server and the second is between the server and the daemon. The adb daemon is implemented in C and located in the Android user space. The daemon is facilitated by the Android USB framework, UsbDeviceManager and UsbDebuggingManager.[5]
Client ↔ server protocol
The communication mode between the client and server is a TCP socket. The server listens on a port, to which the client has to send a request. The request contains a 4-byte initial field in ASCII and a payload. The payload starts with the word host, to indicate it should be sent to the server. The server can then reply with OKAY or FAIL to indicate the status, combined with an optional payload and length.[5]
Server ↔ daemon protocol
The messages sent from the server consist of a 24-byte long header, with the following fields:[5]
Magic value, calculated through command XOR 0xFFFFFFFF
Security
Up to Android 2.2, Android was vulnerable to the RageAgainstTheCageexploit. The adb daemon did not check for the return value of the setuidsystem call when dropping privileges. The exploit forks processes until it fails due to the exhaustion of process identifiers. When the daemon crashes and restarts, it cannot start a new process with dropped privileges and keeps running as root. Then adb provided a root shell.[29] In 2017, a security vulnerability was disclosed that exploited ADB to take over the onboard modem. The attack required adb to be already enabled and authorized, although some workarounds were available.[30]
Various families of malware such as ADB.Miner, Ares, IPStorm, Fbot and Trinity have scanned the internet for public availability of the adb interface and installed malware on those devices.[31] adb can also be used to remove malware, by booting into safe mode and running the adb uninstall command.[32]