☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥
- Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
- Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
- Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
- **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
- **Share your hacking tricks by submitting PRs to the [hacktricks repo](https://github.com/carlospolop/hacktricks) and [hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)**.
**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] \
```
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] \
```
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] \
```
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 .
```
adb shell pm path com.android.phone
```
### adb shell pm clear \
Delete all data associated with a package.
```
adb shell pm clear com.test.abc
```
# File Manager
### adb pull \ \[local]
Download a specified file from an emulator/device to your computer.
```
adb pull /sdcard/demo.mp4 ./
```
### adb push \ \
Upload a specified file from your computer to an emulator/device.
```
adb push test.apk /sdcard
```
# Screencapture/Screenrecord
### adb shell screencap \
Taking a screenshot of a device display.
```
adb shell screencap /sdcard/screen.png
```
### adb shell screenrecord \[options] \
Recording the display of devices running Android 4.4 (API level 19) and higher.
```
adb shell screenrecord /sdcard/demo.mp4
adb shell screenrecord --size
adb shell screenrecord --bit-rate
adb shell screenrecord --time-limit