ADB Commands

AWS Hacking'i öğrenin ve pratik yapın:HackTricks Eğitim AWS Kırmızı Takım Uzmanı (ARTE) GCP Hacking'i öğrenin ve pratik yapın: HackTricks Eğitim GCP Kırmızı Takım Uzmanı (GRTE)

HackTricks'i Destekleyin

Adb genellikle şurada bulunur:

#Windows
C:\Users\<username>\AppData\Local\Android\sdk\platform-tools\adb.exe

#MacOS
/Users/<username>/Library/Android/sdk/platform-tools/adb

Elde edilen bilgi: http://adbshell.com/

Bağlantı

adb devices

Bu, bağlı cihazları listeleyecektir; eğer "yetkisiz" görünüyorsa, bu, mobil cihazınızı açmanız ve bağlantıyı kabul etmeniz gerektiği anlamına gelir.

Bu, cihaza 5555 numaralı portta bir adb sunucusu başlatması gerektiğini belirtir:

adb tcpip 5555

Bu IP'ye ve bu Port'a bağlan:

adb connect <IP>:<PORT>

Eğer aşağıdaki gibi bir hata alırsanız, bir Sanal Android yazılımında (örneğin Genymotion):

adb server version (41) doesn't match this client (36); killing...

Bağlandığınız ADB sunucusunun farklı bir sürümde olduğu için. Yazılımın kullandığı adb ikili dosyasını bulmaya çalışın ( C:\Program Files\Genymobile\Genymotion dizinine gidin ve adb.exe'yi arayın)

Birden fazla cihaz

Makinenize bağlı olan birden fazla cihaz bulduğunuzda, adb komutunu hangi cihazda çalıştırmak istediğinizi belirtmeniz gerekecek.

adb devices
List of devices attached
10.10.10.247:42135	offline
127.0.0.1:5555	device
adb -s 127.0.0.1:5555 shell
x86_64:/ # whoami
root

Port Tunneling

Eğer adb portu yalnızca android cihazda localhost üzerinden erişilebilir ise ama SSH üzerinden erişiminiz varsa, port 5555'i yönlendirebilir ve adb üzerinden bağlanabilirsiniz:

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

Paket Yöneticisi

Kurulum/Kaldırma

adb install [seçenek] <yol>

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] <PACKAGE>

adb uninstall com.test.app

adb uninstall -k com.test.app Keep the data and cache directories around after package removal.

Paketler

Tüm paketleri yazdırır, isteğe bağlı olarak yalnızca <FILTER> metnini içeren paket adlarına sahip olanları.

adb shell pm list packages [options] <FILTER-STR>

adb shell pm list packages <FILTER-STR>

adb shell pm list packages -f <FILTER-STR> #See their associated file.

adb shell pm list packages -d <FILTER-STR> #Filter to only show disabled packages.

adb shell pm list packages -e <FILTER-STR> #Filter to only show enabled packages.

adb shell pm list packages -s <FILTER-STR> #Filter to only show system packages.

adb shell pm list packages -3 <FILTER-STR> #Filter to only show third party packages.

adb shell pm list packages -i <FILTER-STR> #See the installer for the packages.

adb shell pm list packages -u <FILTER-STR> #Also include uninstalled packages.

adb shell pm list packages --user <USER_ID> <FILTER-STR> #The user space to query.

adb shell pm path <PACKAGE>

Verilen APK'nın yolunu yazdırır.

adb shell pm path com.android.phone

adb shell pm clear <PACKAGE>

Bir paketle ilişkili tüm verileri siler.

adb shell pm clear com.test.abc

Dosya Yöneticisi

adb pull <remote> [local]

Belirtilen bir dosyayı bir emülatörden/cihazdan bilgisayarınıza indirin.

adb pull /sdcard/demo.mp4 ./

adb push <local> <remote>

Belirtilen bir dosyayı bilgisayarınızdan bir emülatöre/cihaza yükleyin.

adb push test.apk /sdcard

Screencapture/Screenrecord

adb shell screencap <filename>

Bir cihaz ekranının ekran görüntüsünü almak.

adb shell screencap /sdcard/screen.png

adb shell screenrecord [options] <filename>

Android 4.4 (API seviyesi 19) ve üzeri çalışan cihazların ekranını kaydetme.

adb shell screenrecord /sdcard/demo.mp4
adb shell screenrecord --size <WIDTHxHEIGHT>
adb shell screenrecord --bit-rate <RATE>
adb shell screenrecord --time-limit <TIME> #Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).
adb shell screenrecord --rotate # Rotates 90 degrees
adb shell screenrecord --verbose

( kayıt durdurmak için Ctrl-C tuşuna basın )

Dosyaları (görüntüler ve videolar) _adb pull_ kullanarak indirebilirsiniz.**

Shell

adb shell

Cihazın içinde bir shell alın.

adb shell

adb shell <CMD>

Cihaz içinde bir komut çalıştırın

adb shell ls

pm

Aşağıdaki komutlar bir shell içinde çalıştırılır.

pm list packages #List installed packages
pm path <package name> #Get the path to the apk file of tha package
am start [<options>] #Start an activity. Whiout options you can see the help menu
am startservice [<options>] #Start a service. Whiout options you can see the help menu
am broadcast [<options>] #Send a broadcast. Whiout options you can see the help menu
input [text|keyevent] #Send keystrokes to device

Processes

Eğer uygulamanızın sürecinin PID'sini almak istiyorsanız, şunu çalıştırabilirsiniz:

adb shell ps

Ve uygulamanızı arayın

Ya da şunu yapabilirsiniz

adb shell pidof com.your.application

Ve uygulamanın PID'sini yazdıracaktır

Sistem

adb root

Root izinleriyle adbd daemon'unu yeniden başlatır. Ardından, ADB sunucusuna tekrar bağlanmanız gerekir ve root olacaksınız (varsa).

adb sideload <update.zip>

flashing/restoring Android update.zip paketleri.

Loglar

Logcat

Sadece bir uygulamanın mesajlarını filtrelemek için, uygulamanın PID'sini alın ve logcat çıktısını filtrelemek için grep (linux/macos) veya findstr (windows) kullanın:

adb logcat | grep 4526
adb logcat | findstr 4526

adb logcat [option] [filter-specs]

adb logcat

Notlar: monitörü durdurmak için Ctrl-C tuşuna basın

adb logcat *:V # lowest priority, filter to only show Verbose level

adb logcat *:D # filter to only show Debug level

adb logcat *:I # filter to only show Info level

adb logcat *:W # filter to only show Warning level

adb logcat *:E # filter to only show Error level

adb logcat *:F # filter to only show Fatal level

adb logcat *:S # Silent, highest priority, on which nothing is ever printed

adb logcat -b <Buffer>

adb logcat -b # radio View the buffer that contains radio/telephony related messages.

adb logcat -b # event View the buffer containing events-related messages.

adb logcat -b # main default

adb logcat -c # Clears the entire log and exits.

adb logcat -d # Dumps the log to the screen and exits.

adb logcat -f test.logs # Writes log message output to test.logs .

adb logcat -g # Prints the size of the specified log buffer and exits.

adb logcat -n <count> # Sets the maximum number of rotated logs to <count>.

dumpsys

sistem verilerini dökme

adb shell dumpsys [options]

adb shell dumpsys

adb shell dumpsys meminfo

adb shell dumpsys battery

Notlar: Geliştirici Seçenekleri etkinleştirilmiş bir mobil cihaz, Android 5.0 veya daha yüksek sürümde çalışıyor.

adb shell dumpsys batterystats collects battery data from your device

Notlar: Battery Historian bu verileri HTML görselleştirmesine dönüştürür. ADIM 1 adb shell dumpsys batterystats > batterystats.txt ADIM 2 python historian.py batterystats.txt > batterystats.html

adb shell dumpsys batterystats --reset erases old collection data

adb shell dumpsys activity

Yedekleme

adb'den bir android cihazını yedekleyin.

adb backup [-apk] [-shared] [-system] [-all] -f file.backup
# -apk -- Include APK from Third partie's applications
# -shared -- Include removable storage
# -system -- Include system Applciations
# -all -- Include all the applications

adb shell pm list packages -f -3      #List packages
adb backup -f myapp_backup.ab -apk com.myapp # backup on one device
adb restore myapp_backup.ab                  # restore to the same or any other device

Eğer yedeğin içeriğini incelemek istiyorsanız:

( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 myapp_backup.ab ) |  tar xfvz -

AWS Hacking'i öğrenin ve pratik yapın:HackTricks Eğitim AWS Kırmızı Takım Uzmanı (ARTE) GCP Hacking'i öğrenin ve pratik yapın: HackTricks Eğitim GCP Kırmızı Takım Uzmanı (GRTE)

HackTricks'i Destekleyin

Last updated