{% hint style="success" %}
Impara e pratica AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Impara e pratica GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Supporta HackTricks
* Controlla i [**piani di abbonamento**](https://github.com/sponsors/carlospolop)!
* **Unisciti al** 💬 [**gruppo Discord**](https://discord.gg/hRep4RUj7f) o al [**gruppo telegram**](https://t.me/peass) o **seguici** su **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Condividi trucchi di hacking inviando PR ai** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos su github.
{% endhint %}
**Adb si trova solitamente in:**
```bash
#Windows
C:\Users\\AppData\Local\Android\sdk\platform-tools\adb.exe
#MacOS
/Users//Library/Android/sdk/platform-tools/adb
```
**Informazioni ottenute da:** [**http://adbshell.com/**](http://adbshell.com)
# Connessione
```
adb devices
```
Questo elencherà i dispositivi connessi; se appare "_**non autorizzato**_", significa che devi **sbloccare** il tuo **mobile** e **accettare** la connessione.
Questo indica al dispositivo che deve avviare un server adb sulla porta 5555:
```
adb tcpip 5555
```
Collegati a quell'IP e a quella Porta:
```
adb connect :
```
Se ricevi un errore come il seguente in un software Android virtuale (come Genymotion):
```
adb server version (41) doesn't match this client (36); killing...
```
È perché stai cercando di connetterti a un server ADB con una versione diversa. Prova a trovare il binario adb che il software sta utilizzando (vai su `C:\Program Files\Genymobile\Genymotion` e cerca adb.exe)
## Diversi dispositivi
Ogni volta che trovi **diversi dispositivi collegati al tuo computer** dovrai **specificare in quale** vuoi eseguire il comando adb.
```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
Nel caso in cui la **porta** **adb** sia **accessibile** solo da **localhost** nel dispositivo android ma **hai accesso tramite SSH**, puoi **inoltrare la porta 5555** e connetterti tramite 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
## Installa/Rimuovi
### adb install \[opzione] \
```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 disinstalla \[opzioni] \
```bash
adb uninstall com.test.app
adb uninstall -k com.test.app Keep the data and cache directories around after package removal.
```
## Pacchetti
Stampa tutti i pacchetti, opzionalmente solo quelli il cui nome del pacchetto contiene il testo 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 \
Stampa il percorso dell'APK del dato .
```bash
adb shell pm path com.android.phone
```
### adb shell pm clear \
Elimina tutti i dati associati a un pacchetto.
```bash
adb shell pm clear com.test.abc
```
# File Manager
### adb pull \ \[local]
Scarica un file specificato da un emulatore/dispositivo al tuo computer.
```bash
adb pull /sdcard/demo.mp4 ./
```
### adb push \ \
Carica un file specificato dal tuo computer a un emulatore/dispositivo.
```bash
adb push test.apk /sdcard
```
# Screencapture/Screenrecord
### adb shell screencap \
Catturare uno screenshot del display di un dispositivo.
```bash
adb shell screencap /sdcard/screen.png
```
### adb shell screenrecord \[options] \
Registrazione del display dei dispositivi che eseguono Android 4.4 (API level 19) e versioni superiori.
```bash
adb shell screenrecord /sdcard/demo.mp4
adb shell screenrecord --size
adb shell screenrecord --bit-rate
adb shell screenrecord --time-limit