Objection ํŠœํ† ๋ฆฌ์–ผ

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

์†Œ๊ฐœ

objection - ๋Ÿฐํƒ€์ž„ ๋ชจ๋ฐ”์ผ ํƒ์ƒ‰

Objection๋Š” Frida์— ์˜ํ•ด ๊ตฌ๋™๋˜๋Š” ๋Ÿฐํƒ€์ž„ ๋ชจ๋ฐ”์ผ ํƒ์ƒ‰ ํˆดํ‚ท์ž…๋‹ˆ๋‹ค. jailbroken ๋˜๋Š” rooted ๋ชจ๋ฐ”์ผ ๊ธฐ๊ธฐ๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š๊ณ  ๋ชจ๋ฐ”์ผ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ ๊ทธ ๋ณด์•ˆ ์ƒํƒœ๋ฅผ ํ‰๊ฐ€ํ•˜๋Š” ๋ฐ ๋„์›€์„ ์ฃผ๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด์กŒ์Šต๋‹ˆ๋‹ค.

์ฐธ๊ณ : ์ด๊ฒƒ์€ ์–ด๋–ค ํ˜•ํƒœ์˜ jailbreak / root bypass๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. objection์„ ์‚ฌ์šฉํ•˜๋”๋ผ๋„, ๋‹น์‹ ์€ ์—ฌ์ „ํžˆ ์ ์šฉ๋˜๋Š” sandbox๊ฐ€ ๋ถ€๊ณผํ•˜๋Š” ๋ชจ๋“  ์ œํ•œ์˜ ์˜ํ–ฅ์„ ๋ฐ›์Šต๋‹ˆ๋‹ค.

์š”์•ฝ

objection์˜ ๋ชฉํ‘œ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ Frida๊ฐ€ ์ œ๊ณตํ•˜๋Š” ์ฃผ์š” ์ž‘์—…๋“ค์„ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด, ์‚ฌ์šฉ์ž๋Š” ํ…Œ์ŠคํŠธํ•˜๋ ค๋Š” ๊ฐ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋Œ€ํ•ด ๋‹จ์ผ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

ํŠœํ† ๋ฆฌ์–ผ

์ด ํŠœํ† ๋ฆฌ์–ผ์—์„œ๋Š” ์—ฌ๊ธฐ์—์„œ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋Š” APK๋ฅผ ์‚ฌ์šฉํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค:

๋˜๋Š” ๊ทธ original repository (download app-release.apk)์—์„œ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์„ค์น˜

pip3 install objection

์—ฐ๊ฒฐ

์ผ๋ฐ˜์ ์ธ ADB conection์„ ํ•˜๊ณ  ์žฅ์น˜์—์„œ frida ์„œ๋ฒ„๋ฅผ ์‹œ์ž‘ํ•˜์„ธ์š” (ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„ ๋‘˜ ๋‹ค์—์„œ frida๊ฐ€ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”).

๋งŒ์•ฝ rooted device๋ฅผ ์‚ฌ์šฉ ์ค‘์ด๋ผ๋ฉด, โ€“gadget ์˜ต์…˜ ์•ˆ์—์„œ ํ…Œ์ŠคํŠธํ•˜๋ ค๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์„ ํƒํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ:

frida-ps -Uai
objection --gadget asvid.github.io.fridaapp explore

๊ธฐ๋ณธ ๋™์ž‘

์ด ํŠœํ† ๋ฆฌ์–ผ์—๋Š” objections์˜ ๋ชจ๋“  ๊ฐ€๋Šฅํ•œ ๋ช…๋ น์„ ๋‚˜์—ดํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ œ๊ฐ€ ๋” ์œ ์šฉํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•œ ๊ฒƒ๋“ค๋งŒ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

ํ™˜๊ฒฝ

ํ™˜๊ฒฝ ๋‚ด๋ถ€์—์„œ (์˜ˆ: passwords ๋˜๋Š” paths)์™€ ๊ฐ™์€ ํฅ๋ฏธ๋กœ์šด ์ •๋ณด๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

env

Frida ์ •๋ณด

frida

์—…๋กœ๋“œ/๋‹ค์šด๋กœ๋“œ

file download <remote path> [<local path>]
file upload <local path> [<remote path>]

frida script ์ž„ํฌํŠธ

import <local path frida-script>

SSLPinning

android sslpinning disable #Attempts to disable SSL Pinning on Android devices.

๋ฃจํŒ… ํƒ์ง€

android root disable  #Attempts to disable root detection on Android devices.
android root simulate #Attempts to simulate a rooted Android environment.

๋ช…๋ น ์‹คํ–‰

android shell_exec whoami

์Šคํฌ๋ฆฐ์ƒท

android ui screenshot /tmp/screenshot
android ui FLAG_SECURE false  #This may enable you to take screenshots using the hardware keys

Static analysis๋ฅผ Dynamicํ•˜๊ฒŒ ์ ์šฉํ•˜๊ธฐ

์‹ค์ œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ๋Š” objection์„ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— ์ด ์„น์…˜์—์„œ ๋ฐœ๊ฒฌ๋œ ๋ชจ๋“  ์ •๋ณด๋ฅผ static analysis ๋•๋ถ„์— ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์–ด์จŒ๋“ , ์—ฌ๊ธฐ์„œ๋Š” classes, methods and exported objects์˜ ์ „์ฒด ๋ชฉ๋ก๋งŒ ์ œ๊ณต๋˜๋ฏ€๋กœ ์ด ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” ์ƒˆ๋กœ์šด ๊ฒƒ์„ ๋ฐœ๊ฒฌํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ ์•ฑ์˜ ์ฝ์„ ์ˆ˜ ์žˆ๋Š” source code๋ฅผ ์–ป์„ ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ์—๋„ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

activities, receivers and services ๋‚˜์—ด

android hooking list activities

android hooking list services
android hooking list receivers

Frida๋Š” ์•„๋ฌด๊ฒƒ๋„ ์ฐพ์ง€ ๋ชปํ•˜๋ฉด ์˜ค๋ฅ˜๋ฅผ ๋ฐœ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค

ํ˜„์žฌ activity ๊ฐ€์ ธ์˜ค๊ธฐ

android hooking get current_activity

ํด๋ž˜์Šค ๊ฒ€์ƒ‰

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋‚ด๋ถ€์—์„œ ํด๋ž˜์Šค๋“ค์„ ์ฐพ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

android hooking search classes asvid.github.io.fridaapp

ํด๋ž˜์Šค์˜ ๋ฉ”์„œ๋“œ ๊ฒ€์ƒ‰

์ด์ œ ํด๋ž˜์Šค MainActivity: ์•ˆ์— ์žˆ๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”์ถœํ•ด๋ณด์ž.

android hooking search methods asvid.github.io.fridaapp MainActivity

ํด๋ž˜์Šค์— ์„ ์–ธ๋œ ๋ฉ”์„œ๋“œ์™€ ํ•ด๋‹น ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ชฉ๋ก

ํด๋ž˜์Šค์˜ ๋ฉ”์„œ๋“œ๋“ค์ด ์–ด๋–ค ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ํ•„์š”๋กœ ํ•˜๋Š”์ง€ ์•Œ์•„๋ณด์ž:

android hooking list class_methods asvid.github.io.fridaapp.MainActivity

ํด๋ž˜์Šค ๋‚˜์—ด

ํ˜„์žฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๋กœ๋“œ๋œ ๋ชจ๋“  ํด๋ž˜์Šค๋ฅผ ๋‚˜์—ดํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค:

android hooking list classes #List all loaded classes, As the target application gets usedmore, this command will return more classes.

์ด๋Š” ํด๋ž˜์Šค์˜ ์ด๋ฆ„๋งŒ ์•Œ๊ณ  ์žˆ๊ณ  hook the method of a class and you only know the name of the class ํ•˜๋ ค๋Š” ๊ฒฝ์šฐ์— ๋งค์šฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด ํด๋ž˜์Šค๊ฐ€ ์–ด๋А ๋ชจ๋“ˆ์— ์†ํ•˜๋Š”์ง€ search which module owns the class ๋ฅผ ์ฐพ์•„๋‚ธ ๋‹ค์Œ ํ•ด๋‹น method๋ฅผ hookํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Hooking being easy

Hooking (watching) a method

From the source code of the application we know that the function sum() from MainActivity is being run every second. Lets try to dump all possible information each time the function is called (arguments, return value and backtrace):

android hooking watch class_method asvid.github.io.fridaapp.MainActivity.sum --dump-args --dump-backtrace --dump-return

Hooking (์ „์ฒด ํด๋ž˜์Šค ๊ฐ์‹œํ•˜๊ธฐ)

์‚ฌ์‹ค MainActivity ํด๋ž˜์Šค์˜ ๋ชจ๋“  ๋ฉ”์†Œ๋“œ๊ฐ€ ๋งค์šฐ ํฅ๋ฏธ๋กœ์›Œ์„œ, ์ „๋ถ€ hook them all ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ฃผ์˜: ์ด๋กœ ์ธํ•ด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด crash ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

android hooking watch class asvid.github.io.fridaapp.MainActivity --dump-args --dump-return

If you play with the application while the class is hooked you will see when each function is being called, its arguments and the return value.

ํ•จ์ˆ˜์˜ boolean ๋ฐ˜ํ™˜๊ฐ’ ๋ณ€๊ฒฝ

์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด ํ•จ์ˆ˜ _checkPin_์ด _String_์„ ์ธ์ˆ˜๋กœ ๋ฐ›๊ณ  _boolean_์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ํ•จ์ˆ˜๋ฅผ ํ•ญ์ƒ true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ๋งŒ๋“ค์–ด๋ณด์ž:

์ด์ œ PIN ์ฝ”๋“œ ์ž…๋ ฅ๋ž€์— ๋ฌด์—‡์ด๋“  ์“ฐ๋ฉด ๋ชจ๋‘ ์œ ํšจํ•œ ๊ฒƒ์œผ๋กœ ๋ณด์ผ ๊ฒƒ์ž…๋‹ˆ๋‹ค:

ํด๋ž˜์Šค ์ธ์Šคํ„ด์Šค

ํŠน์ •ํ•œ Java class์˜ live instances๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค(์™„์ „ํ•œ ํด๋ž˜์Šค ์ด๋ฆ„์œผ๋กœ ์ง€์ •). Out์€ ๋ฐœ๊ฒฌ๋œ objection์— ๋Œ€ํ•ด string ๊ฐ’์„ ์–ป์œผ๋ ค๋Š” ์‹œ๋„์˜ ๊ฒฐ๊ณผ์ด๋ฉฐ, ์ผ๋ฐ˜์ ์œผ๋กœ ๊ฐ์ฒด์˜ property ๊ฐ’๋“ค์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

android heap print_instances <class>

ํ‚ค์Šคํ† ์–ด/์ธํ…ํŠธ

๋‹ค์Œ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•ด keystore์™€ intents๋ฅผ ์กฐ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

android keystore list
android intents launch_activity
android intent launch_service

๋ฉ”๋ชจ๋ฆฌ

๋คํ”„

memory dump all <local destination> #Dump all memory
memory dump from_base <base_address> <size_to_dump> <local_destination> #Dump a part

๋ชฉ๋ก

memory list modules

๋ชฉ๋ก ๋งจ ์•„๋ž˜์— frida๊ฐ€ ๋ณด์ž…๋‹ˆ๋‹ค:

frida๊ฐ€ ๋‚ด๋ณด๋‚ด๋Š” ํ•ญ๋ชฉ์„ ํ™•์ธํ•ด๋ด…์‹œ๋‹ค:

๊ฒ€์ƒ‰/์“ฐ๊ธฐ

objection์„ ์‚ฌ์šฉํ•ด ๋ฉ”๋ชจ๋ฆฌ ๋‚ด๋ถ€๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  ์“ธ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค:

memory search "<pattern eg: 41 41 41 ?? 41>" (--string) (--offsets-only)
memory write "<address>" "<pattern eg: 41 41 41 41>" (--string)

SQLite

sqlite ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๋ ค๋ฉด sqlite ๋ช…๋ น์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ข…๋ฃŒ

exit

Objection์—์„œ ์•„์‰ฌ์šด ์ 

  • hooking methods๋Š” ๊ฐ€๋” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํฌ๋ž˜์‹œ์‹œํ‚จ๋‹ค(์ด๋Š” Frida ๋•Œ๋ฌธ์ด๊ธฐ๋„ ํ•จ).
  • ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์‚ฌ์šฉํ•ด ๊ทธ ์ธ์Šคํ„ด์Šค์˜ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜ ์—†๋‹ค. ๋˜ํ•œ ํด๋ž˜์Šค๋ฅผ ์ƒˆ๋กœ ์ธ์Šคํ„ด์Šคํ™”ํ•˜์—ฌ ๊ทธ ์ธ์Šคํ„ด์Šค๋กœ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜๋„ ์—†๋‹ค.
  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ผ๋ฐ˜์ ์ธ crypto methods๋ฅผ ๋ชจ๋‘ ํ›…ํ‚นํ•˜์—ฌ cyphered text, plain text, keys, IVs ๋ฐ algorithms์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ๋‹จ์ถ• ๊ธฐ๋Šฅ(์˜ˆ: sslpinnin์šฉ)์€ ์—†๋‹ค.

References

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