Lect_2 - Deekshith19/Android_Security GitHub Wiki

Android Debug Bridge (adb)

It is a versatile command-line tool that lets you communicate with a device.The adb command facilitates a variety of device actions, such as installing and debugging apps. adb provides access to a Unix shell that you can use to run a variety of commands on a device.

  1. Client: Sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb command.
  2. Daemon (adbd): Runs commands on a device. The daemon runs as a background process on each device. 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.
  3. Server: Manages communication between the client and the daemon. The server runs as a background process on your development machine. The default port number on which the adb server runs is 5037.

adb is included in the Android SDK Platform Tools package, which is installed at ${ANDROID_HOME}/platform-tools/

After the PATH environment variable is set appropriately, we verify the program execution by typing adb in the terminal

image

Android Virtual Device (AVD) is started by typing the following command-

emulator -list-avds

image

emulator -avd Pixel_3a_API_34 -gpu off

image

Basic ADB Commands

adb devices

image

 adb-s emulator-5554 shell

image

Basic commands-

image

pm (Package Manager) is an utility program for retrieving various kinds of information related to theapplication packages that are currently installed on the device.

pm list packages

image

pm list packages | grep youtube

image

pm list packages has various options to configure the output.-3 option is used to filter and display only show third party packages.-s option is used to filter and display only system packages

pm list packages -3

image

To check the Process ID (PID) of the currently running applications, we use the ps-A command.

ps -A | grep youtube

image

pm path is used to get the path of the installed APK file.

pm  path com.google.android.youtube

image

then Exit

adb pull /product/app/YouTube/YouTube.apk

image

dir

image

echo "This is some file" > somefile.txt
adb push somefile.txt /sdcard/

image

somefile got txt.

image