Adb๋ ์ผ๋ฐ์ ์ผ๋ก ๋ค์ ์์น์ ์์ต๋๋ค:
#Windows
C:\Users\<username>\AppData\Local\Android\sdk\platform-tools\adb.exe
#MacOS
/Users/<username>/Library/Android/sdk/platform-tools/adb
์ ๋ณด ์ถ์ฒ: http://adbshell.com/
์ฐ๊ฒฐ
adb devices
์ด ๋ช ๋ น์ ์ฐ๊ฒฐ๋ ์ฅ์น๋ฅผ ๋์ดํฉ๋๋ค. ๋ง์ฝ โunauthorizedโ๊ฐ ๋ํ๋๋ฉด, ์ด๋ ๋ชจ๋ฐ์ผ์ ์ ๊ธ์ ํด์ ํ๊ณ ์ฐ๊ฒฐ์ ์๋ฝํด์ผ ํจ์ ์๋ฏธํฉ๋๋ค.
์ด๋ ์ฅ์น์ ํฌํธ 5555์์ adb ์๋ฒ๋ฅผ ์์ํด์ผ ํจ์ ๋ํ๋ ๋๋ค:
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 ๋ช ๋ น์ ์คํํ ๊ฒ์ธ์ง ์ง์ ํด์ผ ํฉ๋๋ค.
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
ํฌํธ ํฐ๋๋ง
์๋๋ก์ด๋ ์ฅ์น์์ adb ํฌํธ์ ๋ก์ปฌํธ์คํธ์์๋ง ์ ๊ทผํ ์ ์์ง๋ง SSH๋ฅผ ํตํด ์ ๊ทผํ ์ ์๋ ๊ฒฝ์ฐ, ํฌํธ 5555๋ฅผ ํฌ์๋ฉํ๊ณ adb๋ฅผ ํตํด ์ฐ๊ฒฐํ ์ ์์ต๋๋ค:
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>
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.
ํจํค์ง
๋ชจ๋ ํจํค์ง๋ฅผ ์ถ๋ ฅํ๋ฉฐ, ์ ํ์ ์ผ๋ก ํจํค์ง ์ด๋ฆ์ <FILTER> ํ ์คํธ๊ฐ ํฌํจ๋ ํจํค์ง๋ง ์ถ๋ ฅํฉ๋๋ค.
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>
์ฃผ์ด์ง APK์ ๊ฒฝ๋ก๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
adb shell pm path com.android.phone
adb shell pm clear <PACKAGE>
ํจํค์ง์ ๊ด๋ จ๋ ๋ชจ๋ ๋ฐ์ดํฐ๋ฅผ ์ญ์ ํฉ๋๋ค.
adb shell pm clear com.test.abc
ํ์ผ ๊ด๋ฆฌ์
adb pull <remote> [local]
์ง์ ๋ ํ์ผ์ ์๋ฎฌ๋ ์ดํฐ/์ฅ์น์์ ์ปดํจํฐ๋ก ๋ค์ด๋ก๋ํฉ๋๋ค.
adb pull /sdcard/demo.mp4 ./
adb push <local> <remote>
์ง์ ๋ ํ์ผ์ ์ปดํจํฐ์์ ์๋ฎฌ๋ ์ดํฐ/์ฅ์น๋ก ์ ๋ก๋ํฉ๋๋ค.
adb push test.apk /sdcard
Screencapture/Screenrecord
adb shell screencap <filename>
๋๋ฐ์ด์ค ํ๋ฉด์ ์คํฌ๋ฆฐ์ท์ ์ฐ์ต๋๋ค.
adb shell screencap /sdcard/screen.png
adb shell screenrecord [options] <filename>
Android 4.4 (API ๋ ๋ฒจ 19) ์ด์์์ ์คํ๋๋ ์ฅ์น์ ํ๋ฉด์ ๋ นํํฉ๋๋ค.
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
(press Ctrl-C to stop recording)
**ํ์ผ(์ด๋ฏธ์ง ๋ฐ ๋น๋์ค)์ _adb pull_์ ์ฌ์ฉํ์ฌ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค.
Shell
adb shell
์ฅ์น ๋ด๋ถ์์ ์ ธ์ ๊ฐ์ ธ์ต๋๋ค.
adb shell
adb shell <CMD>
๋๋ฐ์ด์ค ๋ด์์ ๋ช ๋ น์ ์คํํฉ๋๋ค.
adb shell ls
pm
๋ค์ ๋ช ๋ น์ ์ ธ ๋ด์์ ์คํ๋ฉ๋๋ค.
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๋ฅผ ์ป์ผ๋ ค๋ฉด ๋ค์์ ์คํํ ์ ์์ต๋๋ค:
adb shell ps
๋น์ ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ฒ์ํ์ธ์
๋๋ ๋ค์์ ์ํํ ์ ์์ต๋๋ค
adb shell pidof com.your.application
์ ํ๋ฆฌ์ผ์ด์ ์ PID๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
์์คํ
adb root
๋ฃจํธ ๊ถํ์ผ๋ก adbd ๋ฐ๋ชฌ์ ์ฌ์์ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ADB ์๋ฒ์ ๋ค์ ์ฐ๊ฒฐํด์ผ ํ๋ฉฐ, ๋ฃจํธ ๊ถํ์ ์ฌ์ฉํ ์ ์์ต๋๋ค(๊ฐ๋ฅํ ๊ฒฝ์ฐ).
adb sideload <update.zip>
ํ๋์ฑ/๋ณต์ Android update.zip ํจํค์ง.
๋ก๊ทธ
Logcat
ํ๋์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฉ์์ง๋ง ํํฐ๋งํ๋ ค๋ฉด, ์ ํ๋ฆฌ์ผ์ด์ ์ PID๋ฅผ ๊ฐ์ ธ์ค๊ณ grep (linux/macos) ๋๋ findstr (windows)๋ฅผ ์ฌ์ฉํ์ฌ logcat์ ์ถ๋ ฅ์ ํํฐ๋งํฉ๋๋ค:
adb logcat | grep 4526
adb logcat | findstr 4526
adb logcat [option] [filter-specs]
adb logcat
๋ ธํธ: ๋ชจ๋ํฐ๋ฅผ ์ค์งํ๋ ค๋ฉด Ctrl-C๋ฅผ ๋๋ฅด์ธ์.
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
์์คํ ๋ฐ์ดํฐ ๋คํ
adb shell dumpsys [options]
adb shell dumpsys
adb shell dumpsys meminfo
adb shell dumpsys battery
๋ ธํธ: Android 5.0 ์ด์์์ ๊ฐ๋ฐ์ ์ต์ ์ด ํ์ฑํ๋ ๋ชจ๋ฐ์ผ ์ฅ์น.
adb shell dumpsys batterystats collects battery data from your device
๋ ธํธ: Battery Historian์ ํด๋น ๋ฐ์ดํฐ๋ฅผ HTML ์๊ฐํ๋ก ๋ณํํฉ๋๋ค. 1๋จ๊ณ adb shell dumpsys batterystats > batterystats.txt 2๋จ๊ณ python historian.py batterystats.txt > batterystats.html
adb shell dumpsys batterystats --reset erases old collection data
adb shell dumpsys activity
๋ฐฑ์
adb๋ฅผ ์ฌ์ฉํ์ฌ ์๋๋ก์ด๋ ๊ธฐ๊ธฐ๋ฅผ ๋ฐฑ์ ํฉ๋๋ค.
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
๋ฐฑ์ ์ ๋ด์ฉ์ ๊ฒ์ฌํ๋ ค๋ฉด:
( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 myapp_backup.ab ) | tar xfvz -
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


