{% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %} **Adb is usually located in:** ```bash #Windows C:\Users\\AppData\Local\Android\sdk\platform-tools\adb.exe #MacOS /Users//Library/Android/sdk/platform-tools/adb ``` **Information obtained from:** [**http://adbshell.com/**](http://adbshell.com) # Connection ``` adb devices ``` This will list the connected devices; if "_**unathorised**_" appears, this means that you have to **unblock** your **mobile** and **accept** the connection. This indicates to the device that it has to start and adb server in port 5555: ``` adb tcpip 5555 ``` Connect to that IP and that Port: ``` adb connect : ``` If you get an error like the following in a Virtual Android software (like Genymotion): ``` adb server version (41) doesn't match this client (36); killing... ``` It's because you are trying to connect to an ADB server with a different version. Just try to find the adb binary the software is using (go to `C:\Program Files\Genymobile\Genymotion` and search for adb.exe) ## Several devices Whenever you find **several devices connected to your machine** you will need to **specify in which one** you want to run the adb command. ```bash adb devices List of devices attached 10.10.10.247:42135 offline 127.0.0.1:5555 device ``` ```bash adb -s 127.0.0.1:5555 shell x86_64:/ # whoami root ``` ## Port Tunneling In case the **adb** **port** is only **accessible** from **localhost** in the android device but **you have access via SSH**, you can **forward the port 5555** and connect via adb: ```bash ssh -i ssh_key username@10.10.10.10 -L 5555:127.0.0.1:5555 -p 2222 adb connect 127.0.0.1:5555 ``` # Packet Manager ## Install/Uninstall ### adb install \[option] \ ```bash adb install test.apk adb install -l test.apk # forward lock application adb install -r test.apk # replace existing application adb install -t test.apk # allow test packages adb install -s test.apk # install application on sdcard adb install -d test.apk # allow version code downgrade adb install -p test.apk # partial application install ``` ### adb uninstall \[options] \ ```bash adb uninstall com.test.app adb uninstall -k com.test.app Keep the data and cache directories around after package removal. ``` ## Packages Prints all packages, optionally only those whose package name contains the text in \. ### adb shell pm list packages \[options] \ ```bash adb shell pm list packages adb shell pm list packages -f #See their associated file. adb shell pm list packages -d #Filter to only show disabled packages. adb shell pm list packages -e #Filter to only show enabled packages. adb shell pm list packages -s #Filter to only show system packages. adb shell pm list packages -3 #Filter to only show third party packages. adb shell pm list packages -i #See the installer for the packages. adb shell pm list packages -u #Also include uninstalled packages. adb shell pm list packages --user #The user space to query. ``` ### adb shell pm path \ Print the path to the APK of the given . ```bash adb shell pm path com.android.phone ``` ### adb shell pm clear \ Delete all data associated with a package. ```bash adb shell pm clear com.test.abc ``` # File Manager ### adb pull \ \[local] Download a specified file from an emulator/device to your computer. ```bash adb pull /sdcard/demo.mp4 ./ ``` ### adb push \ \ Upload a specified file from your computer to an emulator/device. ```bash adb push test.apk /sdcard ``` # Screencapture/Screenrecord ### adb shell screencap \ Taking a screenshot of a device display. ```bash adb shell screencap /sdcard/screen.png ``` ### adb shell screenrecord \[options] \ Recording the display of devices running Android 4.4 (API level 19) and higher. ```bash adb shell screenrecord /sdcard/demo.mp4 adb shell screenrecord --size adb shell screenrecord --bit-rate adb shell screenrecord --time-limit