289 lines
11 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

**Το ADB βρίσκεται συνήθως σε:**
```bash
#Windows
C:\Users\<username>\AppData\Local\Android\sdk\platform-tools\adb.exe
#MacOS
/Users/<username>/Library/Android/sdk/platform-tools/adb
```
**Πληροφορίες που αποκτήθηκαν από:** [**http://adbshell.com/**](http://adbshell.com)
# Σύνδεση
```
adb devices
```
Αυτό θα καταγράψει τις συνδεδεμένες συσκευές. Αν εμφανιστεί το "_**μη εξουσιοδοτημένο**_", αυτό σημαίνει ότι πρέπει να **ξεκλειδώσετε** το **κινητό** σας και να **αποδεχτείτε** τη σύνδεση.
Αυτό υποδεικνύει στη συσκευή ότι πρέπει να ξεκινήσει έναν adb server στη θύρα 5555:
```
adb tcpip 5555
```
Συνδεθείτε σε αυτήν τη διεύθυνση IP και σε αυτήν την θύρα:
```
adb connect <IP>:<PORT>
```
Αν λάβετε ένα σφάλμα όπως το παρακάτω σε ένα εικονικό λογισμικό Android (όπως το Genymotion):
```
adb server version (41) doesn't match this client (36); killing...
```
Είναι επειδή προσπαθείτε να συνδεθείτε σε έναν διακομιστή ADB με διαφορετική έκδοση. Απλώς προσπαθήστε να βρείτε το δυαδικό αρχείο adb που χρησιμοποιεί το λογισμικό (πηγαίνετε στο `C:\Program Files\Genymobile\Genymotion` και αναζητήστε το adb.exe)
## Πολλές συσκευές
Όποτε βρείτε **πολλές συσκευές συνδεδεμένες στον υπολογιστή σας** θα χρειαστεί να **καθορίσετε σε ποια** θέλετε να εκτελέσετε την εντολή 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
Σε περίπτωση που η **adb** **θύρα** είναι μόνο **προσβάσιμη** από **localhost** στη συσκευή android αλλά **έχετε πρόσβαση μέσω SSH**, μπορείτε να **προωθήσετε τη θύρα 5555** και να συνδεθείτε μέσω 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
```
# Διαχειριστής Πακέτων
## Εγκατάσταση/Απεγκατάσταση
### adb install \[option] \<path>
```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 uninstall \[options] \<PACKAGE>
```bash
adb uninstall com.test.app
adb uninstall -k com.test.app Keep the data and cache directories around after package removal.
```
## Πακέτα
Εκτυπώνει όλα τα πακέτα, προαιρετικά μόνο εκείνα των οποίων το όνομα πακέτου περιέχει το κείμενο στο \<FILTER>.
### adb shell pm list packages \[options] \<FILTER-STR>
```bash
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>
Εκτυπώνει τη διαδρομή προς το APK του δοθέντος.
```bash
adb shell pm path com.android.phone
```
### adb shell pm clear \<PACKAGE>
Διαγράψτε όλα τα δεδομένα που σχετίζονται με ένα πακέτο.
```bash
adb shell pm clear com.test.abc
```
# Διαχειριστής Αρχείων
### adb pull \<remote> \[local]
Κατεβάστε ένα συγκεκριμένο αρχείο από έναν εξομοιωτή/συσκευή στον υπολογιστή σας.
```bash
adb pull /sdcard/demo.mp4 ./
```
### adb push \<local> \<remote>
Ανεβάστε ένα συγκεκριμένο αρχείο από τον υπολογιστή σας σε έναν εξομοιωτή/συσκευή.
```bash
adb push test.apk /sdcard
```
# Screencapture/Screenrecord
### adb shell screencap \<filename>
Λήψη στιγμιότυπου οθόνης της οθόνης μιας συσκευής.
```bash
adb shell screencap /sdcard/screen.png
```
### adb shell screenrecord \[options] \<filename>
Καταγραφή της οθόνης συσκευών που τρέχουν Android 4.4 (API level 19) και ανώτερα.
```bash
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
```
(πατήστε Ctrl-C για να σταματήσετε την εγγραφή)
**Μπορείτε να κατεβάσετε τα αρχεία (εικόνες και βίντεο) χρησιμοποιώντας **_**adb pull**_
# Shell
### adb shell
Αποκτήστε πρόσβαση σε ένα shell μέσα στη συσκευή
```bash
adb shell
```
### adb shell \<CMD>
Εκτέλεση μιας εντολής μέσα στη συσκευή
```bash
adb shell ls
```
## pm
Οι παρακάτω εντολές εκτελούνται μέσα σε ένα shell
```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
```
# Διαδικασίες
Αν θέλετε να αποκτήσετε το PID της διαδικασίας της εφαρμογής σας, μπορείτε να εκτελέσετε:
```bash
adb shell ps
```
Και αναζητήστε την εφαρμογή σας
Ή μπορείτε να κάνετε
```bash
adb shell pidof com.your.application
```
Και θα εκτυπώσει το PID της εφαρμογής
# Σύστημα
```bash
adb root
```
Επανακινεί τη διαδικασία adbd με δικαιώματα root. Στη συνέχεια, πρέπει να συνδεθείτε ξανά στον διακομιστή ADB και θα είστε root (αν είναι διαθέσιμο).
```bash
adb sideload <update.zip>
```
flashing/restoring Android update.zip packages.
# Logs
## Logcat
Για να **φιλτράρετε τα μηνύματα μόνο μιας εφαρμογής**, αποκτήστε το PID της εφαρμογής και χρησιμοποιήστε grep (linux/macos) ή findstr (windows) για να φιλτράρετε την έξοδο του logcat:
```bash
adb logcat | grep 4526
adb logcat | findstr 4526
```
### adb logcat \[option] \[filter-specs]
```bash
adb logcat
```
Σημειώσεις: πατήστε Ctrl-C για να σταματήσετε την παρακολούθηση
```bash
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>
```bash
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
εξάγει δεδομένα συστήματος
### adb shell dumpsys \[options]
```bash
adb shell dumpsys
adb shell dumpsys meminfo
adb shell dumpsys battery
```
Σημειώσεις: Μια κινητή συσκευή με ενεργοποιημένες τις Επιλογές προγραμματιστή που τρέχει Android 5.0 ή υψηλότερη έκδοση.
```bash
adb shell dumpsys batterystats collects battery data from your device
```
Σημειώσεις: [Battery Historian](https://github.com/google/battery-historian) μετατρέπει αυτά τα δεδομένα σε μια οπτικοποίηση HTML. **ΒΗΜΑ 1** _adb shell dumpsys batterystats > batterystats.txt_ **ΒΗΜΑ 2** _python historian.py batterystats.txt > batterystats.html_
```bash
adb shell dumpsys batterystats --reset erases old collection data
```
adb shell dumpsys activity
# Δημιουργία Αντιγράφου
Δημιουργήστε ένα αντίγραφο ενός android συσκευής από το adb.
```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
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
```
Αν θέλετε να επιθεωρήσετε το περιεχόμενο του αντιγράφου ασφαλείας:
```bash
( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 myapp_backup.ab ) | tar xfvz -
```
{{#include ../../banners/hacktricks-training.md}}