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 ์ง€์›ํ•˜๊ธฐ