2024-07-19 05:25:54 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > [**HackTricks Training AWS Red Team Expert (ARTE)** ](https://training.hacktricks.xyz/courses/arte )< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > \
Learn & practice GCP Hacking: < img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > [**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line"> ](https://training.hacktricks.xyz/courses/grte )
2022-04-28 16:01:33 +00:00
2024-07-19 05:25:54 +00:00
< details >
2022-04-28 16:01:33 +00:00
2024-07-19 05:25:54 +00:00
< summary > Wsparcie HackTricks< / summary >
2022-04-28 16:01:33 +00:00
2024-07-19 05:25:54 +00:00
* Sprawdź [**plany subskrypcyjne** ](https://github.com/sponsors/carlospolop )!
* **Dołącz do** 💬 [**grupy Discord** ](https://discord.gg/hRep4RUj7f ) lub [**grupy telegramowej** ](https://t.me/peass ) lub **śledź** nas na **Twitterze** 🐦 [**@hacktricks\_live** ](https://twitter.com/hacktricks\_live )**.**
* **Dziel się trikami hackingowymi, przesyłając PR-y do** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) i [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) repozytoriów github.
2022-04-28 16:01:33 +00:00
< / details >
2024-07-19 05:25:54 +00:00
{% endhint %}
2022-04-28 16:01:33 +00:00
2024-02-11 01:46:25 +00:00
**Adb zazwyczaj znajduje się w:**
2021-04-22 13:58:44 +00:00
```bash
#Windows
C:\Users\<username>\AppData\Local\Android\sdk\platform-tools\adb.exe
#MacOS
/Users/< username > /Library/Android/sdk/platform-tools/adb
```
2024-02-11 01:46:25 +00:00
**Informacje uzyskane z:** [**http://adbshell.com/** ](http://adbshell.com )
2021-04-22 13:58:44 +00:00
2024-02-11 01:46:25 +00:00
# Połączenie
2021-10-18 11:21:18 +00:00
```
2020-07-15 15:43:14 +00:00
adb devices
```
2024-07-19 05:25:54 +00:00
To będzie lista podłączonych urządzeń; jeśli "_**nieautoryzowane**_" się pojawi, oznacza to, że musisz **odblokować** swój **telefon** i **zaakceptować** połączenie.
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
To wskazuje urządzeniu, że musi uruchomić serwer adb na porcie 5555:
2021-10-18 11:21:18 +00:00
```
2020-07-15 15:43:14 +00:00
adb tcpip 5555
```
2024-07-19 05:25:54 +00:00
Połącz się z tym adresem IP i tym portem:
2021-10-18 11:21:18 +00:00
```
2020-07-15 15:43:14 +00:00
adb connect < IP > :< PORT >
```
2024-07-19 05:25:54 +00:00
Jeśli otrzymasz błąd podobny do poniższego w wirtualnym oprogramowaniu Android (takim jak Genymotion):
2021-10-18 11:21:18 +00:00
```
2020-07-15 15:43:14 +00:00
adb server version (41) doesn't match this client (36); killing...
```
2024-07-19 05:25:54 +00:00
To dlatego, że próbujesz połączyć się z serwerem ADB o innej wersji. Po prostu spróbuj znaleźć binarkę adb, której używa oprogramowanie (przejdź do `C:\Program Files\Genymobile\Genymotion` i wyszukaj adb.exe)
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
## Kilka urządzeń
2021-07-04 09:43:18 +00:00
2024-07-19 05:25:54 +00:00
Kiedy znajdziesz **kilka urządzeń podłączonych do twojego komputera** , będziesz musiał **określić, na którym** chcesz uruchomić polecenie adb.
2021-07-04 09:43:18 +00:00
```bash
adb devices
List of devices attached
10.10.10.247:42135 offline
127.0.0.1:5555 device
```
```bash
2024-02-11 01:46:25 +00:00
adb -s 127.0.0.1:5555 shell
x86_64:/ # whoami
2021-07-04 09:43:18 +00:00
root
```
2024-07-19 05:25:54 +00:00
## Port Tunneling
2021-07-04 09:43:18 +00:00
2024-07-19 05:25:54 +00:00
W przypadku, gdy **port** **adb** jest dostępny tylko z **localhost** na urządzeniu z androidem, ale **masz dostęp przez SSH** , możesz **przekierować port 5555** i połączyć się przez adb:
2021-07-04 09:43:18 +00:00
```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
```
2024-07-19 05:25:54 +00:00
# Menedżer Pakietów
2021-07-04 09:43:18 +00:00
2024-07-19 05:25:54 +00:00
## Instalacja/Deinstalacja
2020-07-15 15:43:14 +00:00
2024-02-11 01:46:25 +00:00
### adb install \[opcja] \<ścieżka>
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb install test.apk
2024-02-08 04:06:37 +01:00
adb install -l test.apk # forward lock application
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb install -r test.apk # replace existing application
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb install -t test.apk # allow test packages
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb install -s test.apk # install application on sdcard
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb install -d test.apk # allow version code downgrade
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb install -p test.apk # partial application install
2020-07-15 15:43:14 +00:00
```
2024-07-19 05:25:54 +00:00
### adb uninstall \[options] \<PACKAGE>
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb uninstall com.test.app
adb uninstall -k com.test.app Keep the data and cache directories around after package removal.
```
2024-02-11 01:46:25 +00:00
## Pakiety
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
Wyświetla wszystkie pakiety, opcjonalnie tylko te, których nazwa pakietu zawiera tekst w \<FILTER>.
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
### adb shell pm list packages \[options] \<FILTER-STR>
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
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.
```
2024-07-19 05:25:54 +00:00
### adb shell pm path \<PACKAGE>
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
Wyświetla ścieżkę do APK podanego .
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell pm path com.android.phone
```
2022-05-01 13:41:36 +01:00
### adb shell pm clear \<PACKAGE>
2020-07-15 15:43:14 +00:00
2024-02-11 01:46:25 +00:00
Usuń wszystkie dane związane z pakietem.
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell pm clear com.test.abc
```
2024-07-19 05:25:54 +00:00
# File Manager
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
### adb pull \<remote> \[local]
2020-07-15 15:43:14 +00:00
2024-02-11 01:46:25 +00:00
Pobierz określony plik z emulatora/urządzenia na swój komputer.
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb pull /sdcard/demo.mp4 ./
```
2024-07-19 05:25:54 +00:00
### adb push \<local> \<remote>
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
Prześlij określony plik z komputera do emulatora/urządzenia.
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb push test.apk /sdcard
```
2024-07-19 05:25:54 +00:00
# Screencapture/Screenrecord
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
### adb shell screencap \<filename>
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
Robienie zrzutu ekranu wyświetlacza urządzenia.
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell screencap /sdcard/screen.png
```
2024-07-19 05:25:54 +00:00
### adb shell screenrecord \[options] \<filename>
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
Nagrywanie wyświetlacza urządzeń działających na Androidzie 4.4 (poziom API 19) i wyższych.
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
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
```
2021-10-18 11:21:18 +00:00
(press Ctrl-C to stop recording)
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
**Możesz pobrać pliki (obrazy i filmy) używając **_**adb pull**_
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
# Shell
2020-07-15 15:43:14 +00:00
2022-05-01 13:41:36 +01:00
### adb shell
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
Uzyskaj dostęp do powłoki wewnątrz urządzenia
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell
```
2022-05-01 13:41:36 +01:00
### adb shell \<CMD>
2020-07-15 15:43:14 +00:00
2024-02-11 01:46:25 +00:00
Wykonaj polecenie wewnątrz urządzenia
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell ls
```
2022-05-01 13:41:36 +01:00
## pm
2021-04-22 13:58:44 +00:00
2024-07-19 05:25:54 +00:00
Następujące polecenia są wykonywane w obrębie powłoki
2021-04-22 13:58:44 +00:00
```bash
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
```
2024-02-11 01:46:25 +00:00
# Procesy
2021-04-22 13:58:44 +00:00
2024-07-19 05:25:54 +00:00
Jeśli chcesz uzyskać PID procesu swojej aplikacji, możesz wykonać:
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell ps
```
2024-02-11 01:46:25 +00:00
I wyszukaj swoją aplikację
2020-07-15 15:43:14 +00:00
2024-02-11 01:46:25 +00:00
Lub możesz zrobić
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell pidof com.your.application
```
2024-02-11 01:46:25 +00:00
I wydrukuje PID aplikacji
2020-07-15 15:43:14 +00:00
2022-05-01 13:41:36 +01:00
# System
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb root
```
2024-07-19 05:25:54 +00:00
Restartuje demona adbd z uprawnieniami roota. Następnie musisz ponownie połączyć się z serwerem ADB i będziesz rootem (jeśli dostępny).
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb sideload < update.zip >
```
2024-07-19 05:25:54 +00:00
flashing/restoring Android update.zip packages.
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
# Logs
2020-07-15 15:43:14 +00:00
2022-05-01 13:41:36 +01:00
## Logcat
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
Aby **filtrować wiadomości tylko jednej aplikacji** , uzyskaj PID aplikacji i użyj grep (linux/macos) lub findstr (windows), aby filtrować wyjście logcat:
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb logcat | grep 4526
adb logcat | findstr 4526
```
2024-07-19 05:25:54 +00:00
### adb logcat \[option] \[filter-specs]
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb logcat
```
2024-07-19 05:25:54 +00:00
Notes: naciśnij Ctrl-C, aby zatrzymać monitor
2024-02-08 04:06:37 +01:00
```bash
adb logcat *:V # lowest priority, filter to only show Verbose level
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat *:D # filter to only show Debug level
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat *:I # filter to only show Info level
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat *:W # filter to only show Warning level
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat *:E # filter to only show Error level
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat *:F # filter to only show Fatal level
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat *:S # Silent, highest priority, on which nothing is ever printed
2020-07-15 15:43:14 +00:00
```
2024-07-19 05:25:54 +00:00
### adb logcat -b \<Buffer>
2024-02-08 04:06:37 +01:00
```bash
adb logcat -b # radio View the buffer that contains radio/telephony related messages.
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat -b # event View the buffer containing events-related messages.
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat -b # main default
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat -c # Clears the entire log and exits.
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat -d # Dumps the log to the screen and exits.
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat -f test.logs # Writes log message output to test.logs .
2020-07-15 15:43:14 +00:00
2024-02-08 04:06:37 +01:00
adb logcat -g # Prints the size of the specified log buffer and exits.
2020-07-15 15:43:14 +00:00
2024-02-11 01:46:25 +00:00
adb logcat -n < count > # Sets the maximum number of rotated logs to < count > .
2020-07-15 15:43:14 +00:00
```
2022-05-01 13:41:36 +01:00
## dumpsys
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
zrzut danych systemowych
2020-07-15 15:43:14 +00:00
2024-07-19 05:25:54 +00:00
### adb shell dumpsys \[options]
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell dumpsys
adb shell dumpsys meminfo
adb shell dumpsys battery
```
2024-07-19 05:25:54 +00:00
Notes: Urządzenie mobilne z włączonymi Opcjami dewelopera działające na Androidzie 5.0 lub wyższym.
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell dumpsys batterystats collects battery data from your device
```
2024-07-19 05:25:54 +00:00
Notatki: [Battery Historian ](https://github.com/google/battery-historian ) przekształca te dane w wizualizację HTML. **KROK 1** _adb shell dumpsys batterystats > batterystats.txt_ **KROK 2** _python historian.py batterystats.txt > batterystats.html_
2024-02-08 04:06:37 +01:00
```bash
2020-07-15 15:43:14 +00:00
adb shell dumpsys batterystats --reset erases old collection data
```
adb shell dumpsys activity
2022-05-01 13:41:36 +01:00
# Backup
2020-07-15 15:43:14 +00:00
2024-02-11 01:46:25 +00:00
Zrób kopię zapasową urządzenia z systemem Android za pomocą adb.
2020-07-15 15:43:14 +00:00
```bash
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
2021-02-17 12:02:24 +00:00
adb shell pm list packages -f -3 #List packages
2021-02-17 12:07:55 +00:00
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
```
2024-02-11 01:46:25 +00:00
Jeśli chcesz sprawdzić zawartość kopii zapasowej:
2021-02-17 12:07:55 +00:00
```bash
( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 myapp_backup.ab ) | tar xfvz -
2020-07-15 15:43:14 +00:00
```
2024-07-19 05:25:54 +00:00
{% hint style="success" %}
Ucz się i ćwicz Hacking AWS:< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > [**HackTricks Training AWS Red Team Expert (ARTE)** ](https://training.hacktricks.xyz/courses/arte )< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > \
Ucz się i ćwicz Hacking GCP: < img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > [**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line"> ](https://training.hacktricks.xyz/courses/grte )
2022-04-28 16:01:33 +00:00
2024-07-19 05:25:54 +00:00
< details >
2022-04-28 16:01:33 +00:00
2024-07-19 05:25:54 +00:00
< summary > Wsparcie dla HackTricks< / summary >
2022-04-28 16:01:33 +00:00
2024-07-19 05:25:54 +00:00
* Sprawdź [**plany subskrypcyjne** ](https://github.com/sponsors/carlospolop )!
* **Dołącz do** 💬 [**grupy Discord** ](https://discord.gg/hRep4RUj7f ) lub [**grupy telegramowej** ](https://t.me/peass ) lub **śledź** nas na **Twitterze** 🐦 [**@hacktricks\_live** ](https://twitter.com/hacktricks\_live )**.**
* **Dziel się sztuczkami hackingowymi, przesyłając PR-y do** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) i [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) repozytoriów github.
2022-04-28 16:01:33 +00:00
< / details >
2024-07-19 05:25:54 +00:00
{% endhint %}