Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The ADB is typical, used to communicate with a smartphone, tablet, smartwatch, set-top box, or any other device that can run the Android operating system. We can do things on an Android device that may not be suitable for everyday use, like, install apps outside of the Play Store, debug apps, access hidden features, and bring up a UNIX shell, etc. For security reasons, Developer Options need to be unlocked and you need to have USB Debugging Mode enabled as well. Not only that, but you also need to authorize USB Debugging access to the specific PC that you’re connected to with a USB cable. It is a client-server program that includes three components −
A client, which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb command.
A daemon, which runs commands on a device. The daemon runs as a background process on each device.
A server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.
How it works
After starting an adb client in the kali Linux terminal, the client first confirms whether there is an adb server process already running. If there isn't, it starts the server process. When the server starts, it binds to local TCP port 5037 and listens for commands sent from adb clients—all adb clients use port 5037 to communicate with the adb server. The server then sets up connections to all running devices. It locates emulators by scanning odd-numbered ports in the range 5555 to 5585, the range used by the first 16 emulators. Where the server finds an adb daemon, it sets up a connection to that port.
Note − To use adb with a device connected over USB, you must enable USB debugging in the device system settings, under Developer options. The Developer options screen is hidden by default. To make it visible, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options at the bottom.
Connection
After enabling the developer option in the android device, connect it to the PC with the USB cable. However, we can make a connection through Wi-Fi too.
Open the terminal in the Kali Linux
Connect to the device by its IP address which is found at Settings > About tablet (or About phone) > Status > IP address
:/> adb connect ‘ip address’
After that, confirm that your host computer is connected to the target device by the following command; it shows the serial number of the connected devices.
:/> adb devices
ADB Commands
The user can perform multiple types of operator once a connection is established to the android device. Here, the list of commands to communicate with device as following
Command | Comments |
---|---|
adb devices | Print the connected devices |
Adb kill-server | Kill the adb Server |
adb root | To get root access |
adb wait-for-devices | Wait for adb devices |
adb shell stop thermal-engine | Stopping system service /system/bin/thermal-engine |
Adb install | Install an application in adb |
adb shell | Initiate a shell |
Sadb shell dumpsys | Shows memory consumption details |
adb shell echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor | Put the cpu1 scaling governor to performance mode |
Adb pull | Copy a file or directory from the device |
Adb push | Copy a file or directory to the device |
Adb forwarding tcp:6100:7100 | Port forwarding |