Android Debug Bridge
   HOME

TheInfoList



OR:

The Android Debug Bridge (commonly abbreviated as adb) is a
programming tool A programming tool or software development tool is a computer program that software developers use to create, debug, maintain, or otherwise support other programs and applications. The term usually refers to relatively simple programs, that can b ...
used for the
debugging In computer programming and software development, debugging is the process of finding and resolving '' bugs'' (defects or problems that prevent correct operation) within computer programs, software, or systems. Debugging tactics can involve in ...
of
Android Android may refer to: Science and technology * Android (robot), a humanoid robot or synthetic organism designed to imitate a human * Android (operating system), Google's mobile operating system ** Bugdroid, a Google mascot sometimes referred to ...
-based devices. The
daemon Daimon or Daemon (Ancient Greek: , "god", "godlike", "power", "fate") originally referred to a lesser deity or guiding spirit such as the daimons of ancient Greek religion and mythology and of later Hellenistic religion and philosophy. The word ...
on the Android device connects with the server on the host PC over
USB Universal Serial Bus (USB) is an industry standard that establishes specifications for cables, connectors and protocols for connection, communication and power supply (interfacing) between computers, peripherals and other computers. A broad v ...
or
TCP TCP may refer to: Science and technology * Transformer coupled plasma * Tool Center Point, see Robot end effector Computing * Transmission Control Protocol, a fundamental Internet standard * Telephony control protocol, a Bluetooth communication s ...
, which connects to the client that is used by the end-user over TCP. Made available as
open-source software Open-source software (OSS) is computer software that is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute the software and its source code to anyone and for any purpose. Op ...
under the Apache License by
Google Google LLC () is an American multinational technology company focusing on search engine technology, online advertising, cloud computing, computer software, quantum computing, e-commerce, artificial intelligence, and consumer electronics. ...
since 2007, features include a shell and the possibility to make backups. The adb software is compatible with
Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
,
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
and
macOS macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
. It has been misused by
botnet A botnet is a group of Internet-connected devices, each of which runs one or more bots. Botnets can be used to perform Distributed Denial-of-Service (DDoS) attacks, steal data, send spam, and allow the attacker to access the device and its conn ...
s and other
malicious software Malware (a portmanteau for ''malicious software'') is any software intentionally designed to cause disruption to a computer, server, client, or computer network, leak private information, gain unauthorized access to information or systems, depri ...
, for which mitigations were developed such as RSA authentication and device
whitelisting A whitelist, allowlist, or passlist is a mechanism which explicitly allows some identified entities to access a particular privilege, service, mobility, or recognition i.e. it is a list of things allowed when everything is denied by default. It is ...
.


Features

Features of adb include copying files from the host computer, installing apps, viewing logcat output, getting a
Unix shell A Unix shell is a command-line Interpreter (computing), interpreter or shell (computing), shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting langua ...
, and rebooting into
Qualcomm EDL mode The Qualcomm Emergency Download mode, commonly known as Qualcomm EDL mode and officially known as Qualcomm HS-USB QD-Loader 9008 is a feature implemented in the boot ROM of a system on a chip by Qualcomm which can be used to recover bricked smartph ...
. For example, Android
applications Application may refer to: Mathematics and computing * Application software, computer software designed to help the user to perform specific tasks ** Application layer, an abstraction layer that specifies protocols and interface methods used in a c ...
can be saved by the command
backup In information technology, a backup, or data backup is a copy of computer data taken and stored elsewhere so that it may be used to restore the original after a data loss event. The verb form, referring to the process of doing so, is "back up", w ...
to a file. It also includes support for the
Java Debug Wire Protocol In computing, the Java Debug Wire Protocol (JDWP) is a communication protocol which is part of the Java Platform Debugger Architecture. It is used for communication between a debugger and the Java Virtual Machine, which it debugs. It allows to debu ...
. Some graphical interfaces have been made available. The graphical Android Device Monitor in
Android Studio Android Studio is the official integrated development environment (IDE) for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development. It is available for download on Windows ...
can be used for retrieving information from an Android device.


Development history

The Android Software Development Kit (SDK) was first released in 2007. Since 2017, Google made it possible to download adb separately from the Android SDK. In 2015, Microsoft released an Android emulator that can connect to the adb client. In 2016 for
Android Studio Android Studio is the official integrated development environment (IDE) for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development. It is available for download on Windows ...
2.0 a 5x performance improvement was made for installing apps and pushing files through adb. For easier usage of
Android Things Android Things is a deprecated Android-based embedded operating system platform by Google, announced at Google I/O 2015, and launched in 2018. Android Things Dashboard shutdown began on January 5, 2021. After January 5, 2022, Android Things Dash ...
, a wrapper was made in 2017 around manual adb commands. For Android 11 in 2020, Google added adb incremental installations. In 2020, Wi-Fi adb was integrated into Android Studio for macOS. In 2021 for
Android 12 Android 12 is the twelfth major release and 19th version of Android, the mobile operating system developed by the Open Handset Alliance led by Google. The first beta was released on May 18, 2021. Android 12 was released publicly on October 4 ...
, the adb backup command was limited so that backing up user data from apps is opt-in using a per-app manifesto configuration.
Fuchsia ''Fuchsia'' () is a genus of flowering plants that consists mostly of shrubs or small trees. The first to be scientifically described, '' Fuchsia triphylla'', was discovered on the Caribbean island of Hispaniola (Haiti and the Dominican Republi ...
will be backwards-compatible with adb. It will be replaced with fx and ffx.


Setup


Host computer

For Windows, the Android SDK contains the adb.exe binary that can be extracted and installed. How-To Geek recommends adding the folder containing the binaries to the
PATH A path is a route for physical travel – see Trail. Path or PATH may also refer to: Physical paths of different types * Bicycle path * Bridle path, used by people on horseback * Course (navigation), the intended path of a vehicle * Desire p ...
environment variable. On
Ubuntu Ubuntu ( ) is a Linux distribution based on Debian and composed mostly of free and open-source software. Ubuntu is officially released in three editions: ''Desktop'', ''Server'', and ''Core'' for Internet of things devices and robots. All the ...
, adb can be installed with the android-tools-adb package. For
Debian Debian (), also known as Debian GNU/Linux, is a Linux distribution composed of free and open-source software, developed by the community-supported Debian Project, which was established by Ian Murdock on August 16, 1993. The first version of D ...
, it has been recommended to also install the android-sdk-platform-tools-common package next to the adb package, which installs the
udev udev (userspace ) is a device manager for the Linux kernel. As the successor of devfsd and hotplug, udev primarily manages device nodes in the directory. At the same time, udev also handles all user space events raised when hardware devices ar ...
rules which makes it possible to run the tool without root permissions. For macOS and other Linux distributions, the platform tools can be downloaded and the PATH variable can be modified in bashrc.


Android device

In
Android 4.2.2 Android Jelly Bean, or Android 4.1 is the codename given to the tenth version of the Android (operating system), Android mobile operating system developed by Google, spanning three major point releases (versions 4.1 through 4.3.1). Among the dev ...
or later ( API level 17), a dialog is shown with an RSA
fingerprint A fingerprint is an impression left by the friction ridges of a human finger. The recovery of partial fingerprints from a crime scene is an important method of forensic science. Moisture and grease on a finger result in fingerprints on surfac ...
that the user needs to accept. This protects against computers exploiting the debugging mechanism without consent of the device user. 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. Some Android vendors have different procedures to enable it. For example, Huawei requires entering a pincode before adb can be enabled. If the
touchscreen A touchscreen or touch screen is the assembly of both an input ('touch panel') and output ('display') device. The touch panel is normally layered on the top of an electronic visual display of an information processing system. The display is often ...
of an Android device is broken, it can be possible to connect a mouse to the device using
USB On-The-Go USB On-The-Go (USB OTG or just OTG) is a specification first used in late 2001 that allows USB devices, such as Tablet computer, tablets or smartphones, to act as a host, allowing other USB devices, such as USB flash drives, digital cameras, co ...
and enable USB debugging.


Architecture

The adb protocol can be transported over USB or over
Wi-Fi Wi-Fi () is a family of wireless network protocols, based on the IEEE 802.11 family of standards, which are commonly used for local area networking of devices and Internet access, allowing nearby digital devices to exchange data by radio wave ...
through
TCP TCP may refer to: Science and technology * Transformer coupled plasma * Tool Center Point, see Robot end effector Computing * Transmission Control Protocol, a fundamental Internet standard * Telephony control protocol, a Bluetooth communication s ...
. 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.


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.


Server ↔ daemon protocol

The messages sent from the server consist of a 24-byte long header, with the following fields: * Command * First argument * Second argument * Length of the payload, 0 or higher *
CRC32 A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to digital data. Blocks of data entering these systems get a short ''check value'' attached, based on t ...
of the data payload * Magic value, calculated through command XOR 0xFFFFFFFF


Security

Up to
Android 2.2 Android Froyo is the sixth version of Android and is a codename of the Android mobile operating system developed by Google, spanning versions between 2.2 and 2.2.3. Those versions are no longer supported. It was unveiled on May 20, 2010, duri ...
, Android was vulnerable to the ''RageAgainstTheCage''
exploit Exploit means to take advantage of something (a person, situation, etc.) for one's own end, especially unethically or unjustifiably. Exploit can mean: *Exploitation of natural resources *Exploit (computer security) * Video game exploit *Exploitat ...
. The adb
daemon Daimon or Daemon (Ancient Greek: , "god", "godlike", "power", "fate") originally referred to a lesser deity or guiding spirit such as the daimons of ancient Greek religion and mythology and of later Hellenistic religion and philosophy. The word ...
did not check for the return value of the
setuid The Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Rit ...
system call In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
when
dropping privileges In computer programming and computer security, privilege separation is one software-based technique for implementing the principle of least privilege. With privilege separation, a program is divided into parts which are limited to the specific pr ...
. The exploit
forks In cutlery or kitchenware, a fork (from la, furca 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tines with which one can spear foods ei ...
processes until it fails due to the exhaustion of
process identifier In computing, the process identifier (a.k.a. process ID or PID) is a number used by most operating system kernels—such as those of Unix, macOS and Windows—to uniquely identify an active process. This number may be used as a parameter in various ...
s. 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. In 2017, a security vulnerability was disclosed that exploited ADB to take over the onboard
modem A modulator-demodulator or modem is a computer hardware device that converts data from a digital format into a format suitable for an analog transmission medium such as telephone or radio. A modem transmits data by Modulation#Digital modulati ...
. The attack required adb to be already enabled and authorized, although some workarounds were available. 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. adb can also be used to remove
malware Malware (a portmanteau for ''malicious software'') is any software intentionally designed to cause disruption to a computer, server, client, or computer network, leak private information, gain unauthorized access to information or systems, depri ...
, by booting into safe mode and running the adb uninstall command.


See also

*
Android recovery mode The Android recovery mode is a mode of Android used for installing updates. It consists of a Linux kernel with ramdisk on a separate partition from the main Android system. Recovery mode can be useful when a phone is stuck in a bootloop or wh ...
*
Fastboot Fastboot is a protocol and a tool of the same name. It is included with the Android SDK package used primarily to modify the flash filesystem via a USB connection from a host computer. It requires that the device be started in Fastboot mode. If ...


References


External links


Android Debug Bridge - Android Developers


LineageOS LineageOS is an Android-based operating system for smartphones, tablet computers, and set-top boxes, with mostly free and open-source software. It is the successor to CyanogenMod, from which it was forked in December 2016, when Cyanogen Inc. a ...

Android Debug Bridge
Arch Linux Arch Linux () is an independently developed, x86-64 general-purpose Linux distribution that strives to provide the latest stable versions of most software by following a Rolling release, rolling-release model. The default installation is a minim ...
wiki * adb,
Gentoo Linux Gentoo Linux (pronounced ) is a Linux distribution built using the Portage package management system. Unlike a binary software distribution, the source code is compiled locally according to the user's preferences and is often optimized for the ...
wiki
Android Debug Bridge, Droid Wiki
{{Android Android (operating system) Debugging Communications protocols Android (operating system) development software