ADB

Commandes ADB pour le pentest Android : transfert de fichiers, accès shell, analyse d'applications, et plus encore. ADB commands for Android pentesting — file transfer, shell access, app analysis, and more.

↗ https://developer.android.com/tools/adb

Overview

ADB is the command-line interface for communicating with Android devices and emulators. It’s essential for every stage of Android pentesting.

Device Management

adb devices                          # List connected devices/emulators
adb -s <serial> shell                # Connect to specific device
adb root                             # Restart adbd as root (if permitted)
adb remount                          # Remount /system as writable
adb reboot                           # Reboot device

Shell Access

adb shell                            # Interactive shell
adb shell <command>                  # Single command execution
adb shell pm list packages           # List installed packages
adb shell pm list packages -3        # Third-party apps only
adb shell dumpsys package <pkg>      # Package info

File Transfer

adb push local_file /sdcard/         # Copy file to device
adb pull /data/data/com.app/db.sqlite ./  # Pull file from device

APK Extraction

Get APK path

adb shell pm path com.target.app

→ Output: package:/data/app/com.target.app-1/base.apk

adb pull /data/app/com.target.app-1/base.apk ./

Logcat — Runtime Logs

adb logcat                           # All logs
adb logcat -s "MyApp"                # Filter by tag
adb logcat | grep -i "password\|token\|secret"  # Grep for secrets

Application Data (Requires Root)

Browse app’s private data directory

adb shell ls /data/data/com.target.app/
# Common sensitive locations
adb pull /data/data/com.target.app/databases/
adb pull /data/data/com.target.app/shared_prefs/

Network

Forward device port to host (for Frida, etc.)

adb forward tcp:27042 tcp:27042

Reverse port forward (device connects to host service)

adb reverse tcp:8080 tcp:8080

Vue d’ensemble

ADB est l’interface en ligne de commande pour communiquer avec les appareils et émulateurs Android. Il est indispensable à chaque étape du pentest Android.

Gestion des appareils

adb devices                          # Lister les appareils/émulateurs connectés
adb -s <serial> shell                # Se connecter à un appareil spécifique
adb root                             # Relancer adbd en root (si autorisé)
adb remount                          # Remonter /system en écriture
adb reboot                           # Redémarrer l'appareil

Accès shell

adb shell                            # Shell interactif
adb shell <command>                  # Exécution d'une seule commande
adb shell pm list packages           # Lister les paquets installés
adb shell pm list packages -3        # Applications tierces uniquement
adb shell dumpsys package <pkg>      # Informations sur un paquet

Transfert de fichiers

adb push local_file /sdcard/         # Copier un fichier vers l'appareil
adb pull /data/data/com.app/db.sqlite ./  # Récupérer un fichier depuis l'appareil

Extraction d’APK

# Récupérer le chemin de l'APK
adb shell pm path com.target.app
# → Sortie : package:/data/app/com.target.app-1/base.apk

adb pull /data/app/com.target.app-1/base.apk ./

Logcat : journaux d’exécution

adb logcat                           # Tous les journaux
adb logcat -s "MyApp"                # Filtrer par tag
adb logcat | grep -i "password\|token\|secret"  # Chercher des secrets

Données de l’application (nécessite le root)

# Parcourir le répertoire de données privées de l'application
adb shell ls /data/data/com.target.app/

# Emplacements sensibles courants
adb pull /data/data/com.target.app/databases/
adb pull /data/data/com.target.app/shared_prefs/

Réseau

# Rediriger un port de l'appareil vers l'hôte (pour Frida, etc.)
adb forward tcp:27042 tcp:27042

# Redirection de port inverse (l'appareil se connecte à un service de l'hôte)
adb reverse tcp:8080 tcp:8080