Android ์ ํ๋ฆฌ์ผ์ด์ Pentesting
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Android ์ ํ๋ฆฌ์ผ์ด์ ๊ธฐ์ด
์ด ํ์ด์ง๋ฅผ ๋จผ์ ์ฝ์ด Android ๋ณด์๊ณผ Android ์ ํ๋ฆฌ์ผ์ด์ ์์ ๊ฐ์ฅ ์ํํ ๊ตฌ์ฑ ์์๋ค๊ณผ ๊ด๋ จ๋ ๊ฐ์ฅ ์ค์ํ ๋ถ๋ถ๋ค์ ๋ํด ์๋ ๊ฒ์ ๊ฐ๋ ฅํ ๊ถ์ฅํฉ๋๋ค:
ADB (Android Debug Bridge)
์ด๊ฒ์ emulated ๋๋ physical Android device์ ์ฐ๊ฒฐํ๊ธฐ ์ํด ํ์ํ ์ฃผ์ ๋๊ตฌ์
๋๋ค.
ADB๋ฅผ ํตํด ์ปดํจํฐ์์ USB ๋๋ Network๋ฅผ ํตํด ์ฅ์น๋ฅผ ์ ์ดํ ์ ์์ต๋๋ค. ์ด ์ ํธ๋ฆฌํฐ๋ ํ์ผ์ ์๋ฐฉํฅ copying, ์ฑ์ installation ๋ฐ uninstallation, shell commands์ execution, ๋ฐ์ดํฐ์ backing up, ๋ก๊ทธ์ reading ๋ฑ ๋ค์ํ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
adb ์ฌ์ฉ๋ฒ์ ๋ฐฐ์ฐ๋ ค๋ฉด ๋ค์ ADB Commands ๋ชฉ๋ก์ ํ์ธํ์ธ์.
Smali
๋๋๋ก ์จ๊ฒจ์ง ์ ๋ณด(์: ์ ๋๋
ํ๋ passwords ๋๋ flags)์ ์ ๊ทผํ๊ธฐ ์ํด ์ ํ๋ฆฌ์ผ์ด์
์ฝ๋๋ฅผ modifyํ๋ ๊ฒ์ด ์ ์ฉํ ์ ์์ต๋๋ค. ์ด๋ด ๊ฒฝ์ฐ apk๋ฅผ decompileํ๊ณ ์ฝ๋๋ฅผ ์์ ํ ๋ค ๋ค์ recompileํ๋ ๊ฒ์ด ํฅ๋ฏธ๋ก์ด ๋ฐฉ๋ฒ์ด ๋ ์ ์์ต๋๋ค.
In this tutorial you can learn how to decompile and APK, modify Smali code and recompile the APK with the new functionality. ์ด ๋ฐฉ๋ฒ์ ์ดํ์ ์ ์๋ dynamic analysis ๋์์ ์ฌ๋ฌ ํ
์คํธ์ ๋ํ ๋์์ผ๋ก ๋งค์ฐ ์ ์ฉํ ์ ์์ต๋๋ค. ํญ์ ์ด ๊ฐ๋ฅ์ฑ์ ์ผ๋์ ๋์ธ์.
๊ธฐํ ํฅ๋ฏธ๋ก์ด ํธ๋ฆญ
- Spoofing your location in Play Store
- Play Integrity attestation spoofing (SafetyNet replacement)
- Shizuku Privileged API (ADB-based non-root privileged access)
- Exploiting Insecure In-App Update Mechanisms
- Abusing Accessibility Services (Android RAT)
- Android IME / InputMethodService Abuse (Malicious Keyboards)
- NFC/EMV Relay via HCE (Android Tap-to-Pay abuse)
- Download APKs: https://apps.evozi.com/apk-downloader/, https://apkpure.com/es/, https://www.apkmirror.com/, https://apkcombo.com/es-es/apk-downloader/, https://github.com/kiber-io/apkd
- ๊ธฐ๊ธฐ์์ APK ์ถ์ถ:
adb shell pm list packages
com.android.insecurebankv2
adb shell pm path com.android.insecurebankv2
package:/data/app/com.android.insecurebankv2-Jnf8pNgwy3QA_U5f-n_4jQ==/base.apk
adb pull /data/app/com.android.insecurebankv2-Jnf8pNgwy3QA_U5f-n_4jQ==/base.apk
- ๋ชจ๋ splits ๋ฐ base apks๋ฅผ APKEditor๋ก ๋ณํฉ:
mkdir splits
adb shell pm path com.android.insecurebankv2 | cut -d ':' -f 2 | xargs -n1 -i adb pull {} splits
java -jar ../APKEditor.jar m -i splits/ -o merged.apk
# after merging, you will need to align and sign the apk, personally, I like to use the uberapksigner
java -jar uber-apk-signer.jar -a merged.apk --allowResign -o merged_signed
Android Enterprise & Work Profile Attacks
Android Enterprise Work Profile Bypass
์ฌ๋ก ์ฐ๊ตฌ ๋ฐ ์ทจ์ฝ์
Air Keyboard Remote Input Injection
Android Rooting Frameworks Manager Auth Bypass Syscall Hook
Abusing Android Media Pipelines Image Parsers
Arm64 Static Linear Map Kaslr Bypass
์ ์ ๋ถ์
๋ฌด์๋ณด๋ค๋, APK๋ฅผ ๋ถ์ํ ๋๋ ๋์ปดํ์ผ๋ฌ๋ฅผ ์ฌ์ฉํด Java ์ฝ๋๋ฅผ ์ดํด๋ณด๋ ๊ฒ์ด ์ข์ต๋๋ค.
๋ค์ํ ์ฌ์ฉ ๊ฐ๋ฅํ ๋์ปดํ์ผ๋ฌ์ ๊ดํ ์ ๋ณด๋ฅผ ์ฐพ์ผ๋ ค๋ฉด ์ฌ๊ธฐ์์ ์ฝ์ด๋ณด์ธ์.
ํฅ๋ฏธ๋ก์ด ์ ๋ณด ์ฐพ๊ธฐ
APK์ ๋ฌธ์์ด๋ง ์ดํด๋ด๋ ๋น๋ฐ๋ฒํธ, URL, API ํค, ์ํธํ ๊ด๋ จ ํญ๋ชฉ, bluetooth uuids, ํ ํฐ ๋ฑ ํฅ๋ฏธ๋ก์ด ๊ฒ์ ๊ฒ์ํ ์ ์์ต๋๋คโฆ ์ฝ๋ ์คํ์ฉ ๋ฐฑ๋์ด๋ ์ธ์ฆ ๋ฐฑ๋์ด(์ฑ์ ํ๋์ฝ๋ฉ๋ ๊ด๋ฆฌ์ ์๊ฒฉ์ฆ๋ช )๋ ์ฐพ์๋ณด์ธ์.
Firebase
firebase URLs์ ํนํ ์ฃผ์ํ๊ณ ์ค์ ์ด ์๋ชป๋์ด ์๋์ง ํ์ธํ์ธ์. Firebase๊ฐ ๋ฌด์์ด๋ฉฐ ์ด๋ฅผ ์ด๋ป๊ฒ ์ ์ฉํ ์ ์๋์ง์ ๋ํ ์์ธํ ์ ๋ณด๋ ์ฌ๊ธฐ์์ ํ์ธํ์ธ์.
์ ํ๋ฆฌ์ผ์ด์ ์ ๊ธฐ๋ณธ ์ดํด - Manifest.xml, strings.xml
์ ํ๋ฆฌ์ผ์ด์ ์ Manifest.xml ๋ฐ strings.xml ํ์ผ์ ๊ฒ์ฌํ๋ฉด ์ ์ฌ์ ์ธ ๋ณด์ ์ทจ์ฝ์ ์ ๋๋ฌ๋ผ ์ ์์ต๋๋ค. ์ด ํ์ผ๋ค์ ๋์ปดํ์ผ๋ฌ๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ APK ํ์ผ ํ์ฅ์๋ฅผ .zip์ผ๋ก ๋ฐ๊พผ ๋ค ์์ถ์ ํ์ด ์ ๊ทผํ ์ ์์ต๋๋ค.
Manifest.xml์์ ์๋ณ๋๋ ์ทจ์ฝ์ ์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค:
- Debuggable Applications: Manifest.xml ํ์ผ์์
debuggable="true"๋ก ์ค์ ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฐ๊ฒฐ์ ํ์ฉํ์ฌ ์ ์ฉ๋ ์ ์์ผ๋ฏ๋ก ์ํํฉ๋๋ค. ๋๋ฒ๊น ๊ฐ๋ฅ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฐพ์ ์ฅ์น์์ ์ ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํ ํํ ๋ฆฌ์ผ์ ์ฐธ์กฐํ์ธ์. - Backup Settings: ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ๋ค๋ฃจ๋ ์ ํ๋ฆฌ์ผ์ด์
์
android:allowBackup="false"์์ฑ์ ๋ช ์์ ์ผ๋ก ์ค์ ํด์ผ ํ๋ฉฐ, ํนํ USB ๋๋ฒ๊น ์ด ํ์ฑํ๋ ๊ฒฝ์ฐ adb๋ฅผ ํตํ ๋ฌด๋จ ๋ฐ์ดํฐ ๋ฐฑ์ ์ ๋ฐฉ์งํด์ผ ํฉ๋๋ค. - Network Security:
android:networkSecurityConfig="@xml/network_security_config"๊ฐ์ ๋ง์ถค ๋คํธ์ํฌ ๋ณด์ ๊ตฌ์ฑ(res/xml/)์ ์ธ์ฆ์ ํ ๋ฐ HTTP ํธ๋ํฝ ์ค์ ๋ฑ ๋ณด์ ์ธ๋ถ์ฌํญ์ ์ง์ ํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ํน์ ๋๋ฉ์ธ์ ๋ํด HTTP ํธ๋ํฝ์ ํ์ฉํ ์ ์์ต๋๋ค. - Exported Activities and Services: ๋งค๋ํ์คํธ์์ ๋ด๋ณด๋ด์ง Activities์ Services๋ฅผ ์๋ณํ๋ฉด ์ค์ฉ๋ ์ ์๋ ๊ตฌ์ฑ ์์๋ฅผ ๋๋ฌ๋ผ ์ ์์ต๋๋ค. ๋์ ํ ์คํธ ์ค ์ถ๊ฐ ๋ถ์์ ํตํด ์ด๋ฌํ ๊ตฌ์ฑ ์์๋ฅผ ์ด๋ป๊ฒ ์ ์ฉํ ์ ์๋์ง ํ์ธํ์ธ์.
- Content Providers and FileProviders: ๋ ธ์ถ๋ content provider๋ ๋ฌด๋จ์ผ๋ก ๋ฐ์ดํฐ์ ์ ๊ทผํ๊ฑฐ๋ ์์ ํ ์ ์๊ฒ ํ ์ ์์ต๋๋ค. FileProviders์ ๊ตฌ์ฑ๋ ๋ฉด๋ฐํ ๊ฒํ ํด์ผ ํฉ๋๋ค.
- Broadcast Receivers and URL Schemes: ์ด๋ฌํ ๊ตฌ์ฑ ์์๋ค์ ์ ์ฉ์ ์ฌ์ฉ๋ ์ ์์ผ๋ฉฐ, ํนํ URL ์คํด์ด ์ ๋ ฅ ์ทจ์ฝ์ ์ ์ด๋ป๊ฒ ์ํฅ์ ๋ฏธ์น๋์ง ์ฃผ์ ๊น๊ฒ ํ์ธํด์ผ ํฉ๋๋ค.
- SDK Versions:
minSdkVersion,targetSDKVersion,maxSdkVersion์์ฑ์ ์ง์๋๋ Android ๋ฒ์ ์ ๋ํ๋ด๋ฉฐ, ์ค๋๋๊ณ ์ทจ์ฝํ Android ๋ฒ์ ์ ์ง์ํ์ง ์๋ ๊ฒ์ด ์ค์ํจ์ ๋ณด์ฌ์ค๋๋ค.
strings.xml ํ์ผ์์๋ API ํค, ์ปค์คํ ์คํค๋ง ๋ฐ ๊ธฐํ ๊ฐ๋ฐ์ ๋ ธํธ์ ๊ฐ์ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ๋ฐ๊ฒฌํ ์ ์์ผ๋ฏ๋ก ์ด๋ฌํ ๋ฆฌ์์ค๋ฅผ ์ฃผ์ ๊น๊ฒ ๊ฒํ ํด์ผ ํฉ๋๋ค.
Tapjacking
Tapjacking์ ์
์ฑ ์ ํ๋ฆฌ์ผ์ด์
์ด ์คํ๋์ด ํผํด์ ์ ํ๋ฆฌ์ผ์ด์
์์ ์์ ์ ์์น์ํค๋ ๊ณต๊ฒฉ์
๋๋ค. ํผํด์ ์ฑ์ ์๊ฐ์ ์ผ๋ก ๊ฐ๋ฆฌ๊ณ ๋๋ฉด, ๊ณต๊ฒฉ์์ UI๋ ์ฌ์ฉ์๋ฅผ ์์ฌ ์ํธ์์ฉํ๋๋ก ์ค๊ณ๋์ด ์์ผ๋ฉฐ, ๊ทธ ์ํธ์์ฉ์ ํผํด์ ์ฑ์ผ๋ก ์ ๋ฌํฉ๋๋ค.
๊ฒฐ๊ณผ์ ์ผ๋ก ์ฌ์ฉ์๋ ์์ ์ด ์ค์ ๋ก ํผํด์ ์ฑ์์ ๋์์ ์ํํ๊ณ ์๋ค๋ ์ฌ์ค์ ์์ง ๋ชปํ๊ฒ ๋ฉ๋๋ค.
์์ธํ ๋ด์ฉ์ ๋ค์์ ์ฐธ์กฐํ์ธ์:
Task Hijacking
launchMode๊ฐ **singleTask**๋ก ์ค์ ๋์ด ์๊ณ taskAffinity๊ฐ ์ ์๋์ด ์์ง ์์ activity๋ task Hijacking์ ์ทจ์ฝํฉ๋๋ค. ์ฆ, ์
์ฑ application์ด ์ค์น๋์ด ์ค์ ์ ํ๋ฆฌ์ผ์ด์
๋ณด๋ค ๋จผ์ ์คํ๋๋ฉด ์ค์ ์ ํ๋ฆฌ์ผ์ด์
์ ํ์คํฌ๋ฅผ ํ์ด์ฌํนํ ์ ์์ต๋๋ค (์ฌ์ฉ์๋ ์ค์ ์ ํ๋ฆฌ์ผ์ด์
์ ์ฌ์ฉํ๊ณ ์๋ค๊ณ ์๊ฐํ๋ฉด์ ์
์ฑ ์ ํ๋ฆฌ์ผ์ด์
๊ณผ ์ํธ์์ฉํ๊ฒ ๋ฉ๋๋ค).
์์ธํ ์ ๋ณด:
Insecure data storage
Internal Storage
Android์์ ๋ด๋ถ ์ ์ฅ์์ ์ ์ฅ๋ ํ์ผ์ ์ด๋ฅผ ์์ฑํ ์ฑ๋ง ์ ๊ทผํ๋๋ก ์ค๊ณ๋์ด ์์ต๋๋ค. ์ด ๋ณด์ ์กฐ์น๋ Android OS์ ์ํด ๊ฐ์ ๋๋ฉฐ ๋๋ถ๋ถ์ ์ ํ๋ฆฌ์ผ์ด์
๋ณด์ ์๊ตฌ์ฌํญ์ ์ ์ ํฉ๋๋ค. ๊ทธ๋ฌ๋ ๊ฐ๋ฐ์๋ ๋๋๋ก MODE_WORLD_READABLE ๋ฐ MODE_WORLD_WRITABLE๊ณผ ๊ฐ์ ๋ชจ๋๋ฅผ ์ฌ์ฉํด ํ์ผ์ ๋ค๋ฅธ ์ ํ๋ฆฌ์ผ์ด์
๊ฐ์ ๊ณต์ ํ๋๋ก ํ์ฉํฉ๋๋ค. ์ด ๋ชจ๋๋ค์ ์ ์ฌ์ ์ผ๋ก ์
์ฑ ์ ํ๋ฆฌ์ผ์ด์
์ ํฌํจํ ๋ค๋ฅธ ์ ํ๋ฆฌ์ผ์ด์
์ด ์ด๋ฌํ ํ์ผ์ ์ ๊ทผํ๋ ๊ฒ์ ์ ํํ์ง ๋ชปํฉ๋๋ค.
- ์ ์ ๋ถ์:
MODE_WORLD_READABLE๋ฐMODE_WORLD_WRITABLE์ ์ฌ์ฉ์ ์ ์คํ ๊ฒํ ํ์ธ์. ์ด๋ฌํ ๋ชจ๋๋ ํ์ผ์ ์์น ์๊ฑฐ๋ ๋ฌด๋จ์ธ ์ ๊ทผ์ ๋ ธ์ถ์ํฌ ์ ์์ต๋๋ค.
- ๋์ ๋ถ์:
- ์ฑ์ด ์์ฑํ ํ์ผ์ ์ค์ ๋ ๊ถํ์ ๊ฒ์ฆํ์ธ์. ํนํ ์ด๋ค ํ์ผ์ด ์ ์ญ์ ์ผ๋ก ์ฝ๊ธฐ ๋๋ ์ฐ๊ธฐ๊ฐ ๊ฐ๋ฅํ๋๋ก ์ค์ ๋์ด ์๋์ง ํ์ธํ์ธ์. ์ด๋ ์ฅ์น์ ์ค์น๋ ๋ชจ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ด ํด๋น ํ์ผ์ ์ฝ๊ฑฐ๋ ์์ ํ ์ ์๊ฒ ํ๋ฏ๋ก ์ฌ๊ฐํ ๋ณด์ ์ํ์ด ๋ ์ ์์ต๋๋ค.
External Storage
SD ์นด๋์ ๊ฐ์ ์ธ๋ถ ์ ์ฅ์์ ํ์ผ์ ๋ค๋ฃฐ ๋๋ ๋ค์ ์ ์ ์ ์ํด์ผ ํฉ๋๋ค:
- ์ ๊ทผ์ฑ:
- ์ธ๋ถ ์ ์ฅ์์ ํ์ผ์ ์ ์ญ์ ์ผ๋ก ์ฝ๊ธฐ ๋ฐ ์ฐ๊ธฐ ๊ฐ๋ฅํฉ๋๋ค. ์ด๋ ์ด๋ค ์ ํ๋ฆฌ์ผ์ด์ ์ด๋ ์ฌ์ฉ์๋ ํด๋น ํ์ผ์ ์ ๊ทผํ ์ ์์์ ์๋ฏธํฉ๋๋ค.
- ๋ณด์ ์ฐ๋ ค:
- ์ ๊ทผ์ด ์ฌ์ฐ๋ฏ๋ก ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ์ธ๋ถ ์ ์ฅ์์ ์ ์ฅํ์ง ์๋ ๊ฒ์ด ์ข์ต๋๋ค.
- ์ธ๋ถ ์ ์ฅ์๋ ์ ๊ฑฐ๋ ์ ์๊ฑฐ๋ ์ด๋ค ์ ํ๋ฆฌ์ผ์ด์ ์ ์ํด์๋ ์ ๊ทผ๋ ์ ์์ด ๋ ์์ ํ์ง ์์ต๋๋ค.
- ์ธ๋ถ ์ ์ฅ์์์ ๊ฐ์ ธ์จ ๋ฐ์ดํฐ ์ฒ๋ฆฌ:
- ์ธ๋ถ ์ ์ฅ์์์ ๊ฐ์ ธ์จ ๋ฐ์ดํฐ๋ ํญ์ ์ ๋ ฅ ๊ฒ์ฆ์ ์ํํ์ธ์. ์ด ๋ฐ์ดํฐ๋ ์ ๋ขฐํ ์ ์๋ ์์ค์์ ์จ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ๋งค์ฐ ์ค์ํฉ๋๋ค.
- ๋์ ๋ก๋ฉ์ ์ํด ์ธ๋ถ ์ ์ฅ์์ ์คํ ํ์ผ์ด๋ ํด๋์ค ํ์ผ์ ์ ์ฅํ๋ ๊ฒ์ ๊ฐ๋ ฅํ ๊ถ์ฅ๋์ง ์์ต๋๋ค.
- ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ธ๋ถ ์ ์ฅ์์์ ์คํ ํ์ผ์ ๊ฐ์ ธ์์ผ ํ๋ค๋ฉด, ๋์ ์ผ๋ก ๋ก๋ํ๊ธฐ ์ ์ ์ด๋ฌํ ํ์ผ์ด ์๋ช ๋์ด ์๊ณ ์ํธํ์ ์ผ๋ก ๊ฒ์ฆ๋์๋์ง ํ์ธํ์ธ์. ์ด๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ณด์ ๋ฌด๊ฒฐ์ฑ์ ์ ์งํ๋ ๋ฐ ํ์์ ์ ๋๋ค.
์ธ๋ถ ์ ์ฅ์๋ /storage/emulated/0 , /sdcard , /mnt/sdcard ์์ ์ ๊ทผํ ์ ์์ต๋๋ค.
Tip
Android 4.4(API 17)๋ถํฐ SD ์นด๋์๋ ์ฑ๋ณ๋ก ์ ๊ทผ์ ์ ํํ๋ ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ๊ฐ ๋์ ๋์์ต๋๋ค. ์ด๋ ์ ์ฑ ์ ํ๋ฆฌ์ผ์ด์ ์ด ๋ค๋ฅธ ์ฑ์ ํ์ผ์ ์ฝ๊ฑฐ๋ ์ฐ๋ ๊ฒ์ ๋ฐฉ์งํฉ๋๋ค.
ํ๋ฌธ์ผ๋ก ์ ์ฅ๋ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ
- Shared preferences: Android๋ ๊ฐ ์ ํ๋ฆฌ์ผ์ด์
์ด
/data/data/<packagename>/shared_prefs/๊ฒฝ๋ก์ XML ํ์ผ์ ์ฝ๊ฒ ์ ์ฅํ ์ ์๋๋ก ํ์ฉํ๋ฉฐ, ๋๋๋ก ํด๋น ํด๋์์ ํ๋ฌธ์ผ๋ก ๋ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค. - Databases: Android๋ ๊ฐ ์ ํ๋ฆฌ์ผ์ด์
์ด
/data/data/<packagename>/databases/๊ฒฝ๋ก์ sqlite ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ฝ๊ฒ ์ ์ฅํ ์ ์๋๋ก ํ์ฉํ๋ฉฐ, ๋๋๋ก ํด๋น ํด๋์์ ํ๋ฌธ์ผ๋ก ๋ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
Broken TLS
Accept All Certificates
์ด๋ค ์ด์ ์์์ธ์ง ๊ฐ๋ฐ์๋ค์ด ํธ์คํธ๋ช ์ด ์ผ์นํ์ง ์๋๋ผ๋ ๋ชจ๋ ์ธ์ฆ์๋ฅผ ์๋ฝํ๋ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ๋ค์๊ณผ ๊ฐ์ ์ฝ๋ ๋ผ์ธ๊ณผ ๊ฐ์ด:
SSLSocketFactory sf = new cc(trustStore);
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
A good way to test this is to try to capture the traffic using some proxy like Burp without authorising Burp CA inside the device. Also, you can generate with Burp a certificate for a different hostname and use it.
์ทจ์ฝํ ์ํธํ
๋น์ ์ ํ ํค ๊ด๋ฆฌ ์ ์ฐจ
์ผ๋ถ ๊ฐ๋ฐ์๋ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๋ฅผ ๋ก์ปฌ ์คํ ๋ฆฌ์ง์ ์ ์ฅํ๊ณ ์ฝ๋์ ํ๋์ฝ๋ฉ๋์๊ฑฐ๋ ์์ธก ๊ฐ๋ฅํ ํค๋ก ์ํธํํ๋ค. ์ญ๊ณตํ์ผ๋ก ์ธํด ๊ณต๊ฒฉ์๊ฐ ๊ธฐ๋ฐ ์ ๋ณด๋ฅผ ์ถ์ถํ ์ ์์ผ๋ฏ๋ก ์ด๋ ๊ฒ ํด์๋ ์ ๋๋ค.
์์ ํ์ง ์๊ฑฐ๋/๋๋ ํ๊ธฐ๋ ์๊ณ ๋ฆฌ์ฆ ์ฌ์ฉ
๊ฐ๋ฐ์๋ ๊ถํ ํ์ธ(authorisation checks), ๋ฐ์ดํฐ ์ ์ฅ ๋๋ ์ ์ก์ ํ๊ธฐ๋ ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํด์๋ ์ ๋๋ค. ์๋ก RC4, MD4, MD5, SHA1 ๋ฑ์ด ์๋ค. ์๋ฅผ ๋ค์ด ๋น๋ฐ๋ฒํธ ์ ์ฅ์ ํด์๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ํธ์ ํจ๊ป ๋ฌด์ฐจ๋ณ ๋์ ๊ณต๊ฒฉ์ ๊ฐํ ํด์๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค.
๊ธฐํ ์ ๊ฒ
- APK๋ฅผ ๋๋ ํํ์ฌ ๋ฆฌ๋ฒ์ค ์์ง๋์ด๋ง์ ์ด๋ ต๊ฒ ๋ง๋๋ ๊ฒ์ด ๊ถ์ฅ๋๋ค.
- ์ฑ์ด ๋ฏผ๊ฐํ ๊ฒฝ์ฐ(์: ์ํ ์ฑ) ์์ฒด์ ์ผ๋ก ๊ธฐ๊ธฐ๊ฐ ๋ฃจํ ๋์๋์ง ํ์ธํ๋ ๊ฒ์ฌ๋ฅผ ์ํํ๊ณ ๊ทธ์ ๋ฐ๋ผ ๋์ํด์ผ ํ๋ค.
- ์ฑ์ด ๋ฏผ๊ฐํ ๊ฒฝ์ฐ(์: ์ํ ์ฑ) ์๋ฎฌ๋ ์ดํฐ ์ฌ์ฉ ์ฌ๋ถ๋ฅผ ํ์ธํด์ผ ํ๋ค.
- ์ฑ์ด ๋ฏผ๊ฐํ ๊ฒฝ์ฐ(์: ์ํ ์ฑ) ์คํ ์ ์ ์์ฒด ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฌ๋ฅผ ์ํํ์ฌ ์์ ๋์๋์ง ํ์ธํด์ผ ํ๋ค.
- APKiD๋ฅผ ์ฌ์ฉํด ์ด๋ค compiler/packer/obfuscator๊ฐ APK ๋น๋์ ์ฌ์ฉ๋์๋์ง ํ์ธํ๋ผ.
React Native Application
Read the following page to learn how to easily access javascript code of React applications:
Xamarin Applications
Read the following page to learn how to easily access C# code of a xamarin applications:
Superpacked Applications
According to this blog post superpacked is a Meta algorithm that compress the content of an application into a single file. The blog talks about the possibility of creating an app that decompress these kind of appsโฆ and a faster way which involves to execute the application and gather the decompressed files from the filesystem.
์๋ํ๋ ์ ์ ์ฝ๋ ๋ถ์
๋๊ตฌ mariana-trench๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฝ๋๋ฅผ ์ค์บํ์ฌ ์ทจ์ฝ์ ์ ์ฐพ์๋ผ ์ ์๋ค. ์ด ๋๊ตฌ๋ ๋๊ตฌ์ ์ฌ์ฉ์์ ์ํด ์ ์ด๋๋ ์ ๋ ฅ์ด ์๋ ์์น๋ฅผ ์ง์ํ๋ ์ฌ๋ฌ known sources, ์ ์์ ์ ๋ ฅ์ด ํผํด๋ฅผ ์ค ์ ์๋ ์ํํ ์์น๋ฅผ ์ง์ํ๋ sinks, ๊ทธ๋ฆฌ๊ณ ๊ฒ์ถ ๊ท์น์ ์ ๊ณตํ๋ rules๋ฅผ ํฌํจํ๋ค. ์ด๋ฌํ ๊ท์น๋ค์ ์ทจ์ฝ์ ์ ๋ํ๋ด๋ sources-sinks์ ์กฐํฉ์ ์ ์ํ๋ค.
์ด ์ง์์ ๋ฐํ์ผ๋ก mariana-trench๋ ์ฝ๋๋ฅผ ๊ฒํ ํ์ฌ ๊ฐ๋ฅํ ์ทจ์ฝ์ ์ ์ฐพ์๋ธ๋ค.
Secrets leaked
An application may contain secrets (API keys, passwords, hidden urls, subdomainsโฆ) inside of it that you might be able to discover. You could us a tool such as https://github.com/dwisiswant0/apkleaks
Bypass Biometric Authentication
Bypass Biometric Authentication (Android)
๊ธฐํ ํฅ๋ฏธ๋ก์ด ๊ธฐ๋ฅ
- ์ฝ๋ ์คํ:
Runtime.exec(), ProcessBuilder(), native code:system() - SMS ์ ์ก:
sendTextMessage, sendMultipartTestMessage native๋ก ์ ์ธ๋ ๋ค์ดํฐ๋ธ ํจ์:public native, System.loadLibrary, System.load- ๋ค์ดํฐ๋ธ ํจ์๋ฅผ ๋ฆฌ๋ฒ์คํ๋ ๋ฐฉ๋ฒ์ ์ฝ์ด๋ณด๋ผ
- JNI๋ฅผ ํตํ ๋ฉ๋ชจ๋ฆฌ ๋ด ๋ค์ดํฐ๋ธ ์ฝ๋ ์คํ(๋ค์ด๋ก๋ํ shellcode โ mmap/mprotect โ ํธ์ถ):
In Memory Jni Shellcode Execution
Other tricks
๋์ ๋ถ์
๋ฌด์๋ณด๋ค๋ ์ ํ๋ฆฌ์ผ์ด์ ๊ณผ ๋ชจ๋ ํ๊ฒฝ(Burp CA cert, Drozer ๋ฐ Frida ๋ฑ)์ ์ค์นํ ์ ์๋ ํ๊ฒฝ์ด ํ์ํ๋ค. ๋ฐ๋ผ์ ๋ฃจํ ๋ ๊ธฐ๊ธฐ(์๋ฎฌ๋ ์ดํฐ ํฌํจ)๊ฐ ๊ฐ๋ ฅํ ๊ถ์ฅ๋๋ค.
์จ๋ผ์ธ ๋์ ๋ถ์
๋ค์์์ ๋ฌด๋ฃ ๊ณ์ ์ ๋ง๋ค ์ ์๋ค: https://appetize.io/. ์ด ํ๋ซํผ์ APK๋ฅผ ์ ๋ก๋ํ๊ณ ์คํํ ์ ์๊ฒ ํด์ฃผ๋ฏ๋ก APK์ ๋์์ ํ์ธํ๋ ๋ฐ ์ ์ฉํ๋ค.
์น์์ ์ ํ๋ฆฌ์ผ์ด์ ๋ก๊ทธ๋ฅผ ๋ณผ ์ ์๊ณ adb๋ก ์ฐ๊ฒฐํ ์๋ ์๋ค.
.png)
ADB ์ฐ๊ฒฐ ๋๋ถ์ ์๋ฎฌ๋ ์ดํฐ ๋ด์์ Drozer์ Frida๋ฅผ ์ฌ์ฉํ ์ ์๋ค.
๋ก์ปฌ ๋์ ๋ถ์
์๋ฎฌ๋ ์ดํฐ ์ฌ์ฉ
- Android Studio (x86 ๋ฐ arm ๋๋ฐ์ด์ค๋ฅผ ์์ฑํ ์ ์์ผ๋ฉฐ, this์ ๋ฐ๋ฅด๋ฉด ์ต์ x86 ๋ฒ์ ์ ๋๋ฆฐ arm ์๋ฎฌ๋ ์ดํฐ ์์ด๋ ARM ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ง์ํ๋ค).
- ์ค์ ๋ฐฉ๋ฒ์ ๋ค์ ํ์ด์ง๋ฅผ ์ฐธ๊ณ ํ๋ผ:
- Genymotion (Free version: Personal Edition, ๊ณ์ ์์ฑ ํ์. ์ ์ฌ์ ์ค๋ฅ๋ฅผ ํผํ๋ ค๋ฉด VirtualBox๊ฐ ํฌํจ๋ ๋ฒ์ ์ ๋ค์ด๋ก๋ํ๋ ๊ฒ์ ๊ถ์ฅํ๋ค.)
- Nox (๋ฌด๋ฃ์ง๋ง Frida๋ Drozer๋ฅผ ์ง์ํ์ง ์๋๋ค).
Tip
์๋ก์ด ์๋ฎฌ๋ ์ดํฐ๋ฅผ ๋ง๋ค ๋ ํ๋ฉด์ด ํด์๋ก ์๋ฎฌ๋ ์ดํฐ๊ฐ ๋๋ ค์ง๋ค๋ ์ ์ ๊ธฐ์ตํ๋ผ. ๊ฐ๋ฅํ๋ฉด ์์ ํ๋ฉด์ ์ ํํ๋ผ.
Genymotion์ google services(์: AppStore)๋ฅผ ์ค์นํ๋ ค๋ฉด ๋ค์ ์ด๋ฏธ์ง์ ๋นจ๊ฐ ํ์๋ ๋ฒํผ์ ํด๋ฆญํด์ผ ํ๋ค:
.png)
๋ํ Genymotion์ Android VM ์ค์ ์์ Bridge Network mode๋ฅผ ์ ํํ ์ ์๋ค๋ ์ ์ ์ ์ํ๋ผ(๋๊ตฌ๊ฐ ์ค์น๋ ๋ค๋ฅธ VM์์ Android VM์ ์ฐ๊ฒฐํ ๊ฒฝ์ฐ ์ ์ฉํ๋ค).
๋ฌผ๋ฆฌ์ ๊ธฐ๊ธฐ ์ฌ์ฉ
๋๋ฒ๊น ์ต์ ์ ํ์ฑํํด์ผ ํ๋ฉฐ ๊ฐ๋ฅํ๋ฉด ๋ฃจํ ํ๋ ๊ฒ์ด ์ข๋ค:
- ์ค์ .
- (Android 8.0๋ถํฐ) ์์คํ ์ ์ ํํ๋ค.
- ์ ํ ์ ๋ณด๋ฅผ ์ ํํ๋ค.
- ๋น๋ ๋ฒํธ๋ฅผ 7๋ฒ ๋๋ฅธ๋ค.
- ๋ค๋ก ๊ฐ๋ฉด ๊ฐ๋ฐ์ ์ต์ ์ ์ฐพ์ ์ ์๋ค.
์ ํ๋ฆฌ์ผ์ด์ ์ ์ค์นํ ํ ๊ฐ์ฅ ๋จผ์ ํด์ผ ํ ์ผ์ ์ฑ์ ์ฌ์ฉํด๋ณด๊ณ ๋ฌด์์ ํ๋์ง, ์ด๋ป๊ฒ ๋์ํ๋์ง ์กฐ์ฌํ์ฌ ์ต์ํด์ง๋ ๊ฒ์ด๋ค. ๋๋ ์ด ์ด๊ธฐ ๋์ ๋ถ์์ MobSF dynamic analysis + pidcat์ ์ฌ์ฉํด ์ํํ ๊ฒ์ ๊ถ์ฅํ๋ค. ์ด๋ ๊ฒ ํ๋ฉด MobSF๊ฐ ๋์ค์ ๊ฒํ ํ ์ ์๋ ๋ง์ ํฅ๋ฏธ๋ก์ด ๋ฐ์ดํฐ๋ฅผ ์บก์ฒํ๋ ๋์ ์ฑ์ ๋์์ ๋ฐฐ์ธ ์ ์๋ค.
Magisk/Zygisk ๊ฐ๋จ ๋ฉ๋ชจ (Pixel ๊ธฐ๊ธฐ ๊ถ์ฅ)
- Magisk ์ฑ์ผ๋ก boot.img๋ฅผ ํจ์นํ๊ณ fastboot๋ก ํ๋์ํ์ฌ systemless root๋ฅผ ์ป๋๋ค
- ๋ฃจํธ ์จ๊ธฐ๊ธฐ๋ฅผ ์ํด Zygisk + DenyList๋ฅผ ํ์ฑํํ๋ผ; ๋ ๊ฐ๋ ฅํ ์จ๊น์ด ํ์ํ ๊ฒฝ์ฐ LSPosed/Shamiko๋ฅผ ๊ณ ๋ คํ๋ผ
- OTA ์ ๋ฐ์ดํธ์์ ๋ณต๊ตฌํ ์ ์๋๋ก ์๋ณธ boot.img๋ฅผ ๋ณด๊ดํ๊ณ , OTA ํ์๋ ๋ค์ ํจ์นํ๋ผ
- ์คํฌ๋ฆฐ ๋ฏธ๋ฌ๋ง์ ํธ์คํธ์์ scrcpy๋ฅผ ์ฌ์ฉํ๋ผ
Unintended Data Leakage
Logging
๊ฐ๋ฐ์๋ ๋๋ฒ๊น
์ ๋ณด๋ฅผ ๊ณต๊ฐ์ ์ผ๋ก ๋
ธ์ถํ์ง ์๋๋ก ์ฃผ์ํด์ผ ํ๋ค, ์ด๋ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ leaks๋ก ์ด์ด์ง ์ ์๋ค. ์ ํ๋ฆฌ์ผ์ด์
๋ก๊ทธ๋ฅผ ๋ชจ๋ํฐ๋งํ์ฌ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ์๋ณํ๊ณ ๋ณดํธํ๊ธฐ ์ํด pidcat๊ณผ adb logcat์ ๊ถ์ฅํ๋ค. Pidcat์ ์ฌ์ฉ ํธ์์ฑ๊ณผ ๊ฐ๋
์ฑ ๋๋ฌธ์ ์ ํธ๋๋ค.
Warning
Android 4.0 ์ดํ ๋ฒ์ ๋ถํฐ ์ ํ๋ฆฌ์ผ์ด์ ์ ์์ ์ ๋ก๊ทธ๋ง ์ ๊ทผํ ์ ์๋ค. ๋ฐ๋ผ์ ์ฑ์ ๋ค๋ฅธ ์ฑ์ ๋ก๊ทธ์ ์ ๊ทผํ ์ ์๋ค.
์ด์จ๋ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ๋ก๊ทธ์ ๋จ๊ธฐ์ง ์๋ ๊ฒ์ด ๊ถ์ฅ๋๋ค.
๋ณต์ฌ/๋ถ์ฌ๋ฃ๊ธฐ ๋ฒํผ ์บ์ฑ
Android์ ํด๋ฆฝ๋ณด๋ ๊ธฐ๋ฐ ํ๋ ์์ํฌ๋ ์ฑ์์ ๋ณต์ฌ-๋ถ์ฌ๋ฃ๊ธฐ ๊ธฐ๋ฅ์ ๊ฐ๋ฅํ๊ฒ ํ์ง๋ง, ๋ค๋ฅธ ์ ํ๋ฆฌ์ผ์ด์ ์ด ํด๋ฆฝ๋ณด๋์ ์ ๊ทผํ ์ ์์ด ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๊ฐ ๋ ธ์ถ๋ ์ํ์ด ์๋ค. ์ ์ฉ์นด๋ ์ ๋ณด์ ๊ฐ์ ๋ฏผ๊ฐํ ์น์ ์ ๋ํด์๋ ๋ณต์ฌ/๋ถ์ฌ๋ฃ๊ธฐ ๊ธฐ๋ฅ์ ๋นํ์ฑํํ๋ ๊ฒ์ด ์ค์ํ๋ค.
ํฌ๋์ ๋ก๊ทธ
์ ํ๋ฆฌ์ผ์ด์ ์ด ํฌ๋์ํ๊ณ ๋ก๊ทธ๋ฅผ ์ ์ฅํ๋ฉด, ํนํ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ญ๊ณตํํ๊ธฐ ์ด๋ ค์ด ๊ฒฝ์ฐ ๊ณต๊ฒฉ์์๊ฒ ๋์์ด ๋ ์ ์๋ค. ์ด ์ํ์ ์ํํ๋ ค๋ฉด ํฌ๋์ ์ ๋ก๊น ์ ํผํ๊ณ , ๋ก๊ทธ๋ฅผ ๋คํธ์ํฌ๋ก ์ ์กํด์ผ ํ ๊ฒฝ์ฐ SSL ์ฑ๋๋ก ์ ์ก๋๋๋ก ํ๋ผ.
Pentester๋ก์ ์ด๋ฌํ ๋ก๊ทธ๋ฅผ ํ์ธํด ๋ณด๋ผ.
์ 3์์๊ฒ ์ ์ก๋ ๋ถ์ ๋ฐ์ดํฐ
์ฑ์ ์ข ์ข Google Adsense์ ๊ฐ์ ์๋น์ค๋ฅผ ํตํฉํ๋๋ฐ, ๊ฐ๋ฐ์์ ์๋ชป๋ ๊ตฌํ์ผ๋ก ์ธํด ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๊ฐ ์๋์น ์๊ฒ ๋ ธ์ถ๋ ์ ์๋ค. ๋ฐ์ดํฐ ์ ์ถ ๊ฐ๋ฅ์ฑ์ ํ์ธํ๋ ค๋ฉด ์ ํ๋ฆฌ์ผ์ด์ ์ ํธ๋ํฝ์ ๊ฐ๋ก์ฑ ์ 3์ ์๋น์ค๋ก ๋ฏผ๊ฐํ ์ ๋ณด๊ฐ ์ ์ก๋๋์ง ํ์ธํ๋ผ.
SQLite DBs
๋๋ถ๋ถ์ ์ ํ๋ฆฌ์ผ์ด์
์ ์ ๋ณด๋ฅผ ์ ์ฅํ๊ธฐ ์ํด ๋ด๋ถ SQLite ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ฌ์ฉํ๋ค. pentest ์ค์๋ ์์ฑ๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค, ํ
์ด๋ธ ๋ฐ ์ปฌ๋ผ ์ด๋ฆ๊ณผ ์ ์ฅ๋ ๋ชจ๋ ๋ฐ์ดํฐ๋ฅผ ํ์ธํ๋ผ. ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์์ผ๋ฉฐ ์ด๋ ์ทจ์ฝ์ ์ด๋ค.
๋ฐ์ดํฐ๋ฒ ์ด์ค๋ /data/data/the.package.name/databases์ ์์นํด์ผ ํ๋ฉฐ ์: /data/data/com.mwr.example.sieve/databases
๋ฐ์ดํฐ๋ฒ ์ด์ค๊ฐ ๊ธฐ๋ฐ ์ ๋ณด๋ฅผ ์ ์ฅํ๊ณ ์ํธํ๋์ด ์๋๋ผ๋ ์ ํ๋ฆฌ์ผ์ด์ ๋ด๋ถ์์ ๋น๋ฐ๋ฒํธ๋ฅผ ์ฐพ์๋ผ ์ ์๋ค๋ฉด ์ฌ์ ํ ์ทจ์ฝ์ ์ด๋ค.
ํ
์ด๋ธ์ .tables๋ก ์ด๊ฑฐํ๊ณ , ํ
์ด๋ธ์ ์ปฌ๋ผ์ .schema <table_name>๋ก ํ์ธํ๋ผ
Drozer (Exploit Activities, Content Providers and Services)
From Drozer Docs: Drozer allows you to assume the role of an Android app and interact with other apps. It can do anything that an installed application can do, such as make use of Androidโs Inter-Process Communication (IPC) mechanism and interact with the underlying operating system. .
Drozer is s useful tool to exploit exported activities, exported services and Content Providers as you will learn in the following sections.
Exploiting exported Activities
Read this if you want to refresh what is an Android Activity.
๋ํ ์กํฐ๋นํฐ์ ์ฝ๋๋ onCreate ๋ฉ์๋์์ ์์ํ๋ค.
Authorisation bypass
์กํฐ๋นํฐ๊ฐ exported ๋์ด ์์ผ๋ฉด ์ธ๋ถ ์ฑ์์ ํด๋น ํ๋ฉด์ ํธ์ถํ ์ ์๋ค. ๋ฐ๋ผ์ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ํฌํจํ ์กํฐ๋นํฐ๊ฐ exported ๋์ด ์๋ค๋ฉด ์ธ์ฆ ๋ฉ์ปค๋์ฆ์ ์ฐํํ์ฌ ์ ๊ทผํ ์ ์๋ค.
Learn how to exploit exported activities with Drozer.
You can also start an exported activity from adb:
- PackageName is com.example.demo
- Exported ActivityName is com.example.test.MainActivity
adb shell am start -n com.example.demo/com.example.test.MainActivity
NOTE: MobSF๋ ์กํฐ๋นํฐ์์ android:launchMode๋ก singleTask/singleInstance ์ฌ์ฉ์ ์
์ฑ์ผ๋ก ๊ฐ์งํ์ง๋ง, this ๋๋ฌธ์, ๋ณด์ด๋ ๋ฐ์ ๊ฐ์ด ์ด๋ ๊ตฌ๋ฒ์ (API versions < 21)์์๋ง ์ํํฉ๋๋ค.
Tip
๊ถํ ์ฐํ(authorisation bypass)๊ฐ ํญ์ ์ทจ์ฝ์ ์ธ ๊ฒ์ ์๋๋๋ค. ์ฐํ๊ฐ ์ด๋ป๊ฒ ๋์ํ๋์ง์ ์ด๋ค ์ ๋ณด๊ฐ ๋ ธ์ถ๋๋์ง์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋๋ค.
Sensitive information leakage
Activities๋ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ ์ ์์ต๋๋ค. export๋์ด ์๊ณ ๋ณดํธ๋์ง ์์ activity๊ฐ setResult ๋ฉ์๋๋ฅผ ํธ์ถํ์ฌ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ๋ฐํ(returning sensitive information) ํ๋ค๋ฉด, sensitive information leakage๊ฐ ๋ฐ์ํฉ๋๋ค.
Tapjacking
Tapjacking์ด ์ฐจ๋จ๋์ง ์์ผ๋ฉด, export๋ activity๋ฅผ ์ ์ฉํ์ฌ ์ฌ์ฉ์๊ฐ ์์์น ๋ชปํ ๋์์ ์ํํ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค. Tapjacking์ ๋ํ ์์ธํ ์ ๋ณด๋ what is Tapjacking follow the link๋ฅผ ์ฐธ์กฐํ์ธ์.
Exploiting Content Providers - Accessing and manipulating sensitive information
Read this if you want to refresh what is a Content Provider.
Content providers๋ ๊ธฐ๋ณธ์ ์ผ๋ก **๋ฐ์ดํฐ๋ฅผ ๊ณต์ (share data)**ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์ฑ์ ์ฌ์ฉ ๊ฐ๋ฅํ content providers๊ฐ ์๋ค๋ฉด, ๊ทธ๋ค๋ก๋ถํฐ **๋ฏผ๊ฐํ ๋ฐ์ดํฐ๋ฅผ ์ถ์ถ(extract sensitive)**ํ ์ ์์ต๋๋ค. ๋ํ ์ทจ์ฝํ ์ ์์ผ๋ฏ๋ก ๊ฐ๋ฅํ SQL injections ๋ฐ Path Traversals๋ ํ
์คํธํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค.
Learn how to exploit Content Providers with Drozer.
Exploiting Services
Read this if you want to refresh what is a Service.
Service์ ๋์์ onStartCommand ๋ฉ์๋์์ ์์๋๋ค๋ ๊ฒ์ ๊ธฐ์ตํ์ธ์.
Service๋ ๊ธฐ๋ณธ์ ์ผ๋ก **๋ฐ์ดํฐ๋ฅผ ์์ (receive data)**ํ๊ณ , **์ฒ๋ฆฌ(process)**ํ๋ฉฐ, ์๋ต์ ๋ฐํ(return)(๋๋ ๋ฐํํ์ง ์์)ํ ์ ์๋ ๊ตฌ์ฑ์์์
๋๋ค. ๋ฐ๋ผ์ ์ ํ๋ฆฌ์ผ์ด์
์ด ์ผ๋ถ ์๋น์ค๋ฅผ exportํ๊ณ ์๋ค๋ฉด, ๋ฌด์์ ํ๋์ง ์ดํดํ๊ธฐ ์ํด ํด๋น ์ฝ๋๋ฅผ **๊ฒํ (check)**ํ๊ณ ๊ธฐ๋ฐ ์ ๋ณด๋ฅผ ์ถ์ถํ๊ฑฐ๋ ์ธ์ฆ ์ฐํ๋ฅผ ์๋ํ๊ธฐ ์ํด **๋์ ํ
์คํธ(test dynamically)**๋ฅผ ์ํํด์ผ ํฉ๋๋ค.
Learn how to exploit Services with Drozer.
Exploiting Broadcast Receivers
Read this if you want to refresh what is a Broadcast Receiver.
Broadcast Receiver์ ๋์์ onReceive ๋ฉ์๋์์ ์์๋๋ค๋ ๊ฒ์ ๊ธฐ์ตํ์ธ์.
Broadcast receiver๋ ํน์ ํ์
์ ๋ฉ์์ง๋ฅผ ๊ธฐ๋ค๋ฆฝ๋๋ค. ๋ฆฌ์๋ฒ๊ฐ ๋ฉ์์ง๋ฅผ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ ๋ฐ๋ผ ์ทจ์ฝํด์ง ์ ์์ต๋๋ค.
Learn how to exploit Broadcast Receivers with Drozer.
Exploiting Schemes / Deep links
deep links๋ฅผ ์๋์ผ๋ก ์ฐพ์ ์ ์์ผ๋ฉฐ, MobSF ๊ฐ์ ๋๊ตฌ๋ this one ๊ฐ์ ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ ์ธ๋ scheme์ adb๋ browser๋ฅผ ์ฌ์ฉํด ์ด ์ ์์ต๋๋ค:
adb shell am start -a android.intent.action.VIEW -d "scheme://hostname/path?param=value" [your.package.name]
์ฐธ๊ณ : omit the package name์(๋ฅผ) ์๋ตํ๋ฉด ๋ชจ๋ฐ์ผ์ด ํด๋น ๋งํฌ๋ฅผ ์ด ์ฑ์ ์๋์ผ๋ก ํธ์ถํฉ๋๋ค.
<!-- Browser regular link -->
<a href="scheme://hostname/path?param=value">Click me</a>
<!-- fallback in your url you could try the intent url -->
<a href="intent://hostname#Intent;scheme=scheme;package=your.package.name;S.browser_fallback_url=http%3A%2F%2Fwww.example.com;end">with alternative</a>
์คํ๋๋ ์ฝ๋
์ฑ์์ ์คํ๋ ์ฝ๋๋ฅผ ์ฐพ์ผ๋ ค๋ฉด deeplink์ ์ํด ํธ์ถ๋๋ activity๋ก ๊ฐ์ ํจ์ **onNewIntent**์ ์ฐพ์๋ณด์ธ์.
 (1) (1) (1).png)
๋ฏผ๊ฐํ ์ ๋ณด
deep link๋ฅผ ๋ฐ๊ฒฌํ ๋๋ง๋ค URL parameters๋ฅผ ํตํด ๋น๋ฐ๋ฒํธ ๊ฐ์ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๋ฅผ ์์ ํ์ง ์๋์ง ํ์ธํด์ผ ํฉ๋๋ค. ๋ค๋ฅธ ์ ํ๋ฆฌ์ผ์ด์ ์ด ํด๋น deep link๋ฅผ ๊ฐ์ฅํด ๊ทธ ๋ฐ์ดํฐ๋ฅผ ํ์น ์ ์๊ธฐ ๋๋ฌธ์ ๋๋ค!
๊ฒฝ๋ก ๋ด ํ๋ผ๋ฏธํฐ
https://api.example.com/v1/users/{username} ๊ฐ์ URL ๊ฒฝ๋ก ์์ ํ๋ผ๋ฏธํฐ๋ฅผ ์ฌ์ฉํ๋ deep link๊ฐ ์๋์ง๋ ๋ฐ๋์ ํ์ธํด์ผ ํฉ๋๋ค. ๊ทธ๋ฐ ๊ฒฝ์ฐ์๋ example://app/users?username=../../unwanted-endpoint%3fparam=value ๊ฐ์ ๊ฐ์ ์ด์ฉํด path traversal์ ์ ๋ํ ์ ์์ต๋๋ค.
์ ํ๋ฆฌ์ผ์ด์
๋ด๋ถ์์ ์ฌ๋ฐ๋ฅธ ์๋ํฌ์ธํธ๋ฅผ ์ฐพ์ผ๋ฉด, ๊ฒฝ๋ก์ ์ผ๋ถ๊ฐ ๋๋ฉ์ธ ์ด๋ฆ์ผ๋ก ์ฌ์ฉ๋ ๋ Open Redirect๋ฅผ ์ ๋ฐํ๊ฑฐ๋(๋๋), CSRF ํ ํฐ ์์ด ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ์์ ํ ์ ์๊ณ ์ทจ์ฝํ ์๋ํฌ์ธํธ๊ฐ ์ฌ๋ฐ๋ฅธ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ค๋ฉด account takeover์ ๊ฐ์ ๋ค๋ฅธ ์ทจ์ฝ์ ์ ๋ฐ์์ํฌ ์ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ info about this here๋ฅผ ์ฐธ๊ณ ํ์ธ์.
์ถ๊ฐ ์์
An interesting bug bounty report about links (/.well-known/assetlinks.json).
์ ์ก ๊ณ์ธต ๊ฒ์ฌ ๋ฐ ๊ฒ์ฆ ์คํจ
- Certificates๊ฐ ํญ์ ์ ๋๋ก ๊ฒ์ฌ๋๋ ๊ฒ์ ์๋๋ค โ Android ์ ํ๋ฆฌ์ผ์ด์ ์์๋ ๊ฒฝ๊ณ ๋ฅผ ๋ฌด์ํ๊ณ self-signed certificates๋ฅผ ์๋ฝํ๊ฑฐ๋, ๊ฒฝ์ฐ์ ๋ฐ๋ผ HTTP ์ฐ๊ฒฐ๋ก ๋๋์๊ฐ๋ ์ผ์ด ํํฉ๋๋ค.
- SSL/TLS ํธ๋์ ฐ์ดํฌ ์ค ํ์์ด ๋๋๋ก ์ทจ์ฝํ๋ค โ ์ทจ์ฝํ cipher suites๋ฅผ ์ฌ์ฉํ๋ฉด ์ฐ๊ฒฐ์ด man-in-the-middle (MITM) ๊ณต๊ฒฉ์ ์ทจ์ฝํด์ ธ ๊ณต๊ฒฉ์๊ฐ ๋ฐ์ดํฐ๋ฅผ ๋ณตํธํํ ์ ์์ต๋๋ค.
- Leakage of private information์ ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ธ์ฆ์ ๋ณด์ ์ฑ๋๋ก ์ํํ๋ฉด์ ๋ค๋ฅธ ํต์ ์ ๋น๋ณด์ ์ฑ๋๋ก ํ ๊ฒฝ์ฐ ๋ฐ์ํ ์ ์๋ ์ํ์ ๋๋ค. ์ด ๋ฐฉ์์ ์ธ์ ์ฟ ํค๋ ์ฌ์ฉ์ ์ ๋ณด ๊ฐ์ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๋ฅผ ์ ์์ ์ฃผ์ฒด๊ฐ ๊ฐ๋ก์ฑ๋ ๊ฒ์ผ๋ก๋ถํฐ ๋ณดํธํ์ง ๋ชปํฉ๋๋ค.
์ธ์ฆ์ ๊ฒ์ฆ
์ฐ๋ฆฌ๋ ์ธ์ฆ์ ๊ฒ์ฆ์ ์ด์ ์ ๋ง์ถ ๊ฒ์ ๋๋ค. ์๋ฒ์ ์ธ์ฆ์ ๋ฌด๊ฒฐ์ฑ์ ๊ฒ์ฆํ๋ ๊ฒ์ ๋ณด์์ ๊ฐํํ๊ธฐ ์ํด ํ์์ ์ ๋๋ค. ๋ถ์์ ํ TLS ์ค์ ๊ณผ ์ํธํ๋์ง ์์ ์ฑ๋์ ํตํ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ ์ ์ก์ ์ฌ๊ฐํ ์ํ์ ์ด๋ํ ์ ์์ต๋๋ค. ์๋ฒ ์ธ์ฆ์ ๊ฒ์ฆ ๋ฐ ์ทจ์ฝ์ ํด๊ฒฐ์ ๋ํ ์์ธํ ๋จ๊ณ๋ this resource๋ฅผ ์ฐธ๊ณ ํ์ธ์.
SSL Pinning
SSL Pinning์ ์ ํ๋ฆฌ์ผ์ด์ ์ด ์๋ฒ์ ์ธ์ฆ์๋ฅผ ์ ํ๋ฆฌ์ผ์ด์ ๋ด์ ์ ์ฅ๋ ์๋ ค์ง ์ฌ๋ณธ๊ณผ ๋น๊ตํ์ฌ ๊ฒ์ฆํ๋ ๋ณด์ ๊ธฐ๋ฒ์ ๋๋ค. ์ด ๋ฐฉ๋ฒ์ MITM ๊ณต๊ฒฉ์ ๋ฐฉ์งํ๋ ๋ฐ ํ์์ ์ด๋ฉฐ, ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ๋ค๋ฃจ๋ ์ ํ๋ฆฌ์ผ์ด์ ์๋ SSL Pinning ๊ตฌํ์ ๊ฐ๋ ฅํ ๊ถ์ฅํฉ๋๋ค.
ํธ๋ํฝ ๊ฒ์ฌ
HTTP ํธ๋ํฝ์ ๊ฒ์ฌํ๋ ค๋ฉด ํ๋ก์ ๋๊ตฌ์ ์ธ์ฆ์๋ฅผ ์ค์น(์: Burp)ํด์ผ ํฉ๋๋ค. ์ด ์ธ์ฆ์๋ฅผ ์ค์นํ์ง ์์ผ๋ฉด ์ํธํ๋ ํธ๋ํฝ์ด ํ๋ก์๋ฅผ ํตํด ๋ณด์ด์ง ์์ ์ ์์ต๋๋ค. ์ปค์คํ CA ์ธ์ฆ์ ์ค์น ๊ฐ์ด๋๋ click here๋ฅผ ์ฐธ๊ณ ํ์ธ์.
API Level 24 ์ด์์ ํ๊น์ผ๋ก ํ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ํ๋ก์์ CA ์ธ์ฆ์๋ฅผ ์๋ฝํ๋๋ก Network Security Config๋ฅผ ์์ ํด์ผ ํฉ๋๋ค. ์ด ๋จ๊ณ๋ ์ํธํ๋ ํธ๋ํฝ์ ๊ฒ์ฌํ๋ ๋ฐ ์ค์ํฉ๋๋ค. Network Security Config ์์ ๋ฐฉ๋ฒ์ refer to this tutorial๋ฅผ ์ฐธ์กฐํ์ธ์.
๋ง์ฝ Flutter๋ฅผ ์ฌ์ฉํ๋ค๋ฉด this page์ ์ง์นจ์ ๋ฐ๋ผ์ผ ํฉ๋๋ค. ๋จ์ํ ์ธ์ฆ์๋ฅผ ์คํ ์ด์ ์ถ๊ฐํ๋ ๊ฒ๋ง์ผ๋ก๋ ๋์ํ์ง ์๋๋ฐ, Flutter๋ ์์ฒด ์ ํจ CA ๋ชฉ๋ก์ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ ๋๋ค.
Static detection of SSL/TLS pinning
๋ฐํ์ ์ฐํ ์๋๋ฅผ ํ๊ธฐ ์ ์ APK์์ pinning์ด ์ ์ฉ๋ ์์น๋ฅผ ๋น ๋ฅด๊ฒ ๋งคํํ์ธ์. ์ ์ ํ์ง๋ ํ /ํจ์น ๊ณํ์ ์ธ์ฐ๊ณ ์ฌ๋ฐ๋ฅธ ์ฝ๋ ๊ฒฝ๋ก์ ์ง์คํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค.
Tool: SSLPinDetect
- ์คํ์์ค ์ ์ ๋ถ์ ์ ํธ๋ฆฌํฐ๋ก, APK๋ฅผ Smali๋ก ๋์ปดํ์ผ(apktool ์ฌ์ฉ)ํ๊ณ SSL/TLS pinning ๊ตฌํ์ ์ปค๋ ์ดํ ๋ regex ํจํด์ ์ค์บํฉ๋๋ค.
- ๊ฐ ๋งค์น์ ๋ํด ์ ํํ ํ์ผ ๊ฒฝ๋ก, ๋ผ์ธ ๋ฒํธ ๋ฐ ์ฝ๋ ์ค๋ํซ์ ๋ฆฌํฌํธํฉ๋๋ค.
- ์ผ๋ฐ์ ์ธ ํ๋ ์์ํฌ ๋ฐ ์ปค์คํ ์ฝ๋ ๊ฒฝ๋ก๋ฅผ ๋ค๋ฃน๋๋ค: OkHttp CertificatePinner, custom javax.net.ssl.X509TrustManager.checkServerTrusted, SSLContext.init with custom TrustManagers/KeyManagers, ๊ทธ๋ฆฌ๊ณ Network Security Config XML pins.
์ค์น
- Prereqs: Python >= 3.8, Java on PATH, apktool
git clone https://github.com/aancw/SSLPinDetect
cd SSLPinDetect
pip install -r requirements.txt
์ฌ์ฉ๋ฒ
# Basic
python sslpindetect.py -f app.apk -a apktool.jar
# Verbose (timings + per-match path:line + snippet)
python sslpindetect.py -a apktool_2.11.0.jar -f sample/app-release.apk -v
์์ ํจํด ๊ท์น (JSON) signatures๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ํ์ฅํ์ฌ ๋ ์ /์ปค์คํ pinning ์คํ์ผ์ ํ์งํ์ธ์. ์์ ์ JSON์ ๋ก๋ํ์ฌ ๋๊ท๋ชจ๋ก ์ค์บํ ์ ์์ต๋๋ค.
{
"OkHttp Certificate Pinning": [
"Lcom/squareup/okhttp/CertificatePinner;",
"Lokhttp3/CertificatePinner;",
"setCertificatePinner"
],
"TrustManager Override": [
"Ljavax/net/ssl/X509TrustManager;",
"checkServerTrusted"
]
}
๋ ธํธ ๋ฐ ํ
- ๋๊ท๋ชจ ์ฑ์ ๋ฉํฐ์ค๋ ๋ฉ ๋ฐ memory-mapped I/O๋ก ๋น ๋ฅด๊ฒ ์ค์บ; ๋ฏธ๋ฆฌ ์ปดํ์ผ๋ regex๋ ์ค๋ฒํค๋์ ์คํ์ ์ค์ฌ์ค๋ค.
- Pattern collection: https://github.com/aancw/smali-sslpin-patterns
- ๋ค์์ผ๋ก ์ฐ์ ๋ถ๋ฅํ ์ผ๋ฐ์ ์ธ ํ์ง ๋์:
- OkHttp: CertificatePinner ์ฌ์ฉ, setCertificatePinner, okhttp3/okhttp ํจํค์ง ์ฐธ์กฐ
- Custom TrustManagers: javax.net.ssl.X509TrustManager, checkServerTrusted ์ค๋ฒ๋ผ์ด๋
- Custom SSL contexts: SSLContext.getInstance + SSLContext.init with custom managers
- res/xml์ ์ ์ธ์ pins ๋ฐ manifest ์ฐธ์กฐ
- ์ผ์นํ ์์น๋ฅผ ์ด์ฉํด dynamic testing ์ ์ Frida hooks, static patches ๋๋ ์ค์ ๋ฆฌ๋ทฐ๋ฅผ ๊ณํํ๋ผ.
SSL Pinning ์ฐํ
์ฑ์ SSL Pinning์ด ๊ตฌํ๋์ด ์์ผ๋ฉด HTTPS ํธ๋ํฝ์ ๊ฒ์ฌํ๊ธฐ ์ํด ์ด๋ฅผ ์ฐํํด์ผ ํ ํ์๊ฐ ์๋ค. ์ด๋ฅผ ์ํ ๋ค์ํ ๋ฐฉ๋ฒ์ด ์๋ค:
- ์๋์ผ๋ก ์์ ํ์ฌ apk๋ฅผ ์ฐํ(bypass)ํ๋ ค๋ฉด apk-mitm์ ์ฌ์ฉํ๋ผ. ์ด ์ต์ ์ ๊ฐ์ฅ ํฐ ์ฅ์ ์ SSL Pinning์ ์ฐํํ๊ธฐ ์ํด root๊ฐ ํ์ ์๋ค๋ ์ ์ด์ง๋ง, ์ ํ๋ฆฌ์ผ์ด์ ์ ์ญ์ ํ๊ณ ์๋ก ์ค์นํด์ผ ํ๋ฉฐ ํญ์ ์๋ํ์ง๋ ์๋๋ค.
- ์ด ๋ณดํธ๋ฅผ ์ฐํํ๋ ค๋ฉด Frida(์๋ ์ฐธ์กฐ)๋ฅผ ์ฌ์ฉํ ์ ์๋ค. Burp+Frida+Genymotion ์ฌ์ฉ ๊ฐ์ด๋๋ ๋ค์์ ์ฐธ์กฐ: https://spenkk.github.io/bugbounty/Configuring-Frida-with-Burp-and-GenyMotion-to-bypass-SSL-Pinning/
- objection๋ฅผ ์ฌ์ฉํด ์๋์ผ๋ก SSL Pinning์ ์ฐํํด๋ณผ ์๋ ์๋ค::
objection --gadget com.package.app explore --startup-command "android sslpinning disable" - MobSF dynamic analysis(์๋ ์ค๋ช )๋ก ์๋์ผ๋ก SSL Pinning์ ์ฐํํด๋ณผ ์๋ ์๋ค.
- ์ฌ์ ํ ์บก์ฒํ์ง ๋ชปํ๋ ํธ๋ํฝ์ด ์๋ค๊ณ ์๊ฐ๋๋ฉด iptables๋ฅผ ์ฌ์ฉํด ํธ๋ํฝ์ burp๋ก ํฌ์๋ฉํด ๋ณด๋ผ. ๊ด๋ จ ๋ธ๋ก๊ทธ: https://infosecwriteups.com/bypass-ssl-pinning-with-ip-forwarding-iptables-568171b52b62
์ผ๋ฐ์ ์ธ ์น ์ทจ์ฝ์ ์ฐพ๊ธฐ
์ ํ๋ฆฌ์ผ์ด์ ๋ด์์ ์ผ๋ฐ์ ์ธ ์น ์ทจ์ฝ์ ๋ ๊ฒ์ํ๋ ๊ฒ์ด ์ค์ํ๋ค. ์ด๋ฌํ ์ทจ์ฝ์ ์ ์๋ณํ๊ณ ์ํํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ด ์์ฝ์ ๋ฒ์๋ฅผ ๋ฒ์ด๋์ง๋ง ๋ค๋ฅธ ์๋ฃ์์ ๊ด๋ฒ์ํ๊ฒ ๋ค๋ฃจ๊ณ ์๋ค.
Frida
Frida๋ ๊ฐ๋ฐ์, ๋ฆฌ๋ฒ์ค ์์ง๋์ด, ๋ณด์ ์ฐ๊ตฌ์๋ฅผ ์ํ ๋์ ์ธ์คํธ๋ฃจ๋จผํ
์ด์
ํดํท์ด๋ค.
์คํ ์ค์ธ ์ ํ๋ฆฌ์ผ์ด์
์ ์ ๊ทผํด ๋ฐํ์์ ๋ฉ์๋๋ฅผ hookํ์ฌ ๋์์ ๋ณ๊ฒฝํ๊ฑฐ๋ ๊ฐ ์ถ์ถยท๋ณ๊ฒฝ, ๋ค๋ฅธ ์ฝ๋๋ฅผ ์คํํ ์ ์๋คโฆ
Android ์ ํ๋ฆฌ์ผ์ด์
์ pentestํ๋ ค๋ฉด Frida ์ฌ์ฉ๋ฒ์ ์์์ผ ํ๋ค.
- Frida ์ฌ์ฉ๋ฒ ๋ฐฐ์ฐ๊ธฐ: Frida tutorial
- Frida ์์ ์ฉ ์ผ๋ถ โGUIโ: https://github.com/m0bilesecurity/RMS-Runtime-Mobile-Security
- Ojection์ Frida ์ฌ์ฉ ์๋ํ์ ์ข๋ค: https://github.com/sensepost/objection , https://github.com/dpnishant/appmon
- Awesome Frida ์คํฌ๋ฆฝํธ ๋ชจ์: https://codeshare.frida.re/
- ptrace ์์ด Frida๋ฅผ ๋ก๋ํ๋ ๋ฐฉ์์ผ๋ก anti-debugging / anti-frida ๋ฉ์ปค๋์ฆ์ ์ฐํํด ๋ณด๋ผ(๊ฐ์ด๋: https://erfur.github.io/blog/dev/code-injection-without-ptrace, ํด: linjector)
Anti-instrumentation & SSL pinning ์ฐํ ์ํฌํ๋ก์ฐ
Android Anti Instrumentation And Ssl Pinning Bypass
๋ฉ๋ชจ๋ฆฌ ๋คํ - Fridump
์ ํ๋ฆฌ์ผ์ด์ ์ด ๋น๋ฐ๋ฒํธ๋ ๋๋ชจ๋ ๊ฐ์ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฅํด์๋ ์ ๋๋ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฅํ๊ณ ์๋์ง ํ์ธํ๋ผ.
Fridump3๋ฅผ ์ฌ์ฉํ๋ฉด ๋ค์๊ณผ ๊ฐ์ด ์ฑ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋คํํ ์ ์๋ค:
# With PID
python3 fridump3.py -u <PID>
# With name
frida-ps -Uai
python3 fridump3.py -u "<Name>"
์ด๊ฒ์ ./dump ํด๋์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ dumpํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ทธ ์์์ ๋ค์๊ณผ ๊ฐ์ด grepํ ์ ์์ต๋๋ค:
strings * | grep -E "^[a-z]+ [a-z]+ [a-z]+ [a-z]+ [a-z]+ [a-z]+ [a-z]+ [a-z]+ [a-z]+ [a-z]+ [a-z]+ [a-z]+$"
Keystore์ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ
Android์์ Keystore๋ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๊ธฐ์ ๊ฐ์ฅ ์ ํฉํ ์ฅ์์ด์ง๋ง, ์ถฉ๋ถํ ๊ถํ์ด ์์ผ๋ฉด ์ฌ์ ํ ์ ๊ทผํ ์ ์์ต๋๋ค. ์ ํ๋ฆฌ์ผ์ด์ ๋ค์ ์ฌ๊ธฐ์ ํ๋ฌธ์ผ๋ก ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋ ๊ฒฝํฅ์ด ์์ผ๋ฏ๋ก, pentests๋ ์ด๋ฅผ root user ๊ถํ์ผ๋ก ํ์ธํด์ผ ํฉ๋๋ค. ๊ธฐ๊ธฐ์ ๋ฌผ๋ฆฌ์ ์ผ๋ก ์ ๊ทผํ ์ ์๋ ์ฌ๋์ด ์ด ๋ฐ์ดํฐ๋ฅผ ํ์น ์ ์์ต๋๋ค.
์ฑ์ด keystore์ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋๋ผ๋, ๋ฐ์ดํฐ๋ ์ํธํ๋์ด์ผ ํฉ๋๋ค.
keystore ๋ด๋ถ์ ๋ฐ์ดํฐ์ ์ ๊ทผํ๋ ค๋ฉด ์ด Frida script๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค: https://github.com/WithSecureLabs/android-keystore-audit/blob/master/frida-scripts/tracer-cipher.js
frida -U -f com.example.app -l frida-scripts/tracer-cipher.js
Fingerprint/Biometrics Bypass
๋ค์ Frida ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ๋ฉด Android ์ ํ๋ฆฌ์ผ์ด์ ์ด ํน์ ๋ฏผ๊ฐํ ์์ญ์ ๋ณดํธํ๊ธฐ ์ํด ์ํํ ์ ์๋ bypass fingerprint authentication์ ์ฐํํ ์ ์์ต๋๋ค:
frida --codeshare krapgras/android-biometric-bypass-update-android-11 -U -f <app.package>
๋ฐฑ๊ทธ๋ผ์ด๋ ์ด๋ฏธ์ง
์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ๋ณด๋ผ ๋, Android๋ ์ ํ๋ฆฌ์ผ์ด์ ์ snapshot of the application์ ์ ์ฅํฉ๋๋ค. ํฌ์ด๊ทธ๋ผ์ด๋๋ก ๋ณต์๋ ๋ ์ฑ์ด ๋ก๋๋๊ธฐ ์ ์ ํด๋น ์ด๋ฏธ์ง๋ฅผ ๋จผ์ ๋ถ๋ฌ์ ์ฑ์ด ๋ ๋นจ๋ฆฌ ๋ก๋๋ ๊ฒ์ฒ๋ผ ๋ณด์ด๊ฒ ํฉ๋๋ค.
๊ทธ๋ฌ๋ ์ด snapshot์ ๋ฏผ๊ฐํ ์ ๋ณด๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, snapshot์ ์ ๊ทผํ ์ ์๋ ๋๊ตฐ๊ฐ๊ฐ ๊ทธ ์ ๋ณด๋ฅผ ํ์ทจํ ์ ์์ต๋๋ค(์ ๊ทผํ๋ ค๋ฉด root๊ฐ ํ์ํฉ๋๋ค).
์ด snapshot๋ค์ ๋ณดํต ๋ค์ ๊ฒฝ๋ก์ ์ ์ฅ๋ฉ๋๋ค: /data/system_ce/0/snapshots
Android๋ FLAG_SECURE ๋ ์ด์์ ํ๋ผ๋ฏธํฐ๋ฅผ ์ค์ ํ์ฌ screenshot capture๋ฅผ ๋ฐฉ์งํ๋ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค. ์ด ํ๋๊ทธ๋ฅผ ์ฌ์ฉํ๋ฉด ์ฐฝ ๋ด์ฉ์ด ๋ณด์ ์ฒ๋ฆฌ๋์ด screenshots์ ๋ํ๋๊ฑฐ๋ ๋น๋ณด์ ๋์คํ๋ ์ด์์ ํ์๋๋ ๊ฒ์ ๋ฐฉ์งํฉ๋๋ค.
getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
Android Application Analyzer
์ด ๋๊ตฌ๋ ๋์ ๋ถ์ ์ค ๋ค์ํ ๋๊ตฌ๋ฅผ ๊ด๋ฆฌํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค: https://github.com/NotSoSecure/android_application_analyzer
Intent Injection
๊ฐ๋ฐ์๋ค์ ์ข
์ข
activities, services, ๊ทธ๋ฆฌ๊ณ broadcast receivers ๊ฐ์ ํ๋ก์ ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค์ด ์ด๋ฌํ Intents๋ฅผ ์ฒ๋ฆฌํ๊ณ startActivity(...)๋ sendBroadcast(...) ๊ฐ์ ๋ฉ์๋๋ก ์ ๋ฌํ๋๋ฐ, ์ด๋ ์ํํ ์ ์์ต๋๋ค.
์ํ์ ๊ณต๊ฒฉ์๊ฐ ์ด๋ฌํ Intents๋ฅผ ์๋ชป ์ ๋ํ์ฌ non-exported app components๋ฅผ ํธ๋ฆฌ๊ฑฐํ๊ฑฐ๋ ๋ฏผ๊ฐํ content providers์ ์ ๊ทผํ ์ ์๊ฒ ํ์ฉํ๋ ๋ฐ ์์ต๋๋ค. ๋ํ์ ์ธ ์๋ก WebView ์ปดํฌ๋ํธ๊ฐ URL์ Intent ๊ฐ์ฒด๋ก ๋ณํํ๊ธฐ ์ํด Intent.parseUri(...)๋ฅผ ์ฌ์ฉํ ๋ค ์คํํ๋ฉด, ์
์์ ์ธ Intent ์ฃผ์
์ผ๋ก ์ด์ด์ง ์ ์์ต๋๋ค.
ํต์ฌ ์์
- Intent Injection์ ์น์ Open Redirect ๋ฌธ์ ์ ์ ์ฌํฉ๋๋ค.
- ์ต์คํ๋ก์์ Intent ๊ฐ์ฒด๋ฅผ extras๋ก ์ ๋ฌํ์ฌ ์์ ํ์ง ์์ ๋์์ ์คํํ๋๋ก ๋ฆฌ๋ค์ด๋ ํธํ๋ ๋ฐฉ์์ผ๋ก ์ด๋ค์ง๋๋ค.
- ๋น๋ ธ์ถ(non-exported) ์ปดํฌ๋ํธ์ content providers๋ฅผ ๊ณต๊ฒฉ์์๊ฒ ๋ ธ์ถ์ํฌ ์ ์์ต๋๋ค.
WebView์ URL โIntent๋ณํ์ ์๋ํ์ง ์์ ๋์์ ์ด์งํ ์ ์์ต๋๋ค.
Android ํด๋ผ์ด์ธํธ ์ธก ์ธ์ ์ ๋ฐ ๊ธฐํ
์๋ง ์น์์ ์ด๋ฐ ์ข ๋ฅ์ ์ทจ์ฝ์ ์ ์ ํด๋ณด์ จ์ ๊ฒ๋๋ค. Android ์ ํ๋ฆฌ์ผ์ด์ ์์๋ ๋ค์ ์ทจ์ฝ์ ๋ค์ ํนํ ์ฃผ์ํด์ผ ํฉ๋๋ค:
- SQL Injection: ๋์ ์ฟผ๋ฆฌ๋ Content-Providers๋ฅผ ๋ค๋ฃฐ ๋๋ ํ๋ผ๋ฏธํฐํ๋ ์ฟผ๋ฆฌ๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
- JavaScript Injection (XSS): ๋ชจ๋ WebViews์ ๋ํด JavaScript ๋ฐ Plugin ์ง์์ด ๋นํ์ฑํ๋์ด ์๋์ง ํ์ธํ์ธ์(๊ธฐ๋ณธ์ ์ผ๋ก ๋นํ์ฑํ๋์ด ์์). More info here.
- Local File Inclusion: WebViews๋ ํ์ผ ์์คํ
์ ๊ทผ์ด ๋นํ์ฑํ๋์ด์ผ ํฉ๋๋ค(๊ธฐ๋ณธ์ ์ผ๋ก ํ์ฑํ๋์ด ์์) -
(webview.getSettings().setAllowFileAccess(false);). More info here. - Eternal cookies: ์ฌ๋ฌ ๊ฒฝ์ฐ์์ Android ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ธ์ ์ ์ข ๋ฃํ ๋ ์ฟ ํค๊ฐ ์ทจ์๋์ง ์๊ฑฐ๋ ๋์คํฌ์ ์ ์ฅ๋ ์ ์์ต๋๋ค.
- Secure Flag in cookies
์๋ ๋ถ์
MobSF
์ ์ ๋ถ์
.png)
์ ํ๋ฆฌ์ผ์ด์ ์ ์ทจ์ฝ์ ํ๊ฐ๋ฅผ ์น ๊ธฐ๋ฐ ํ๋ก ํธ์๋๋ฅผ ํตํด ์ ๊ณตํฉ๋๋ค. ๋์ ๋ถ์๋ ์ํํ ์ ์์ผ๋(๋์ ๋ถ์์ ์ํด์๋ ํ๊ฒฝ์ ์ค๋นํด์ผ ํจ) ํ๊ฒฝ ์ค์ ์ด ํ์ํฉ๋๋ค.
docker pull opensecurity/mobile-security-framework-mobsf
docker run -it -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest
์ฃผ์: MobSF๋ Android(apk), IOS(ipa) and Windows(apx) ์ ํ๋ฆฌ์ผ์ด์
์ ๋ถ์ํ ์ ์์ต๋๋ค (Windows applications must be analyzed from a MobSF installed in a Windows host).
๋ํ, Android ๋๋ IOS ์ฑ์ ์์ค ์ฝ๋๋ก ZIP ํ์ผ์ ๋ง๋ค๋ฉด(์ ํ๋ฆฌ์ผ์ด์
์ ๋ฃจํธ ํด๋๋ก ์ด๋ํด ๋ชจ๋ ํ์ผ์ ์ ํํ ๋ค ZIPfile ์์ฑ) ๊ทธ๊ฒ๋ ๋ถ์ํ ์ ์์ต๋๋ค.
MobSF๋ ๋ํ diff/Compare ๋ถ์์ ์ง์ํ๊ณ VirusTotal๊ณผ ํตํฉํ ์ ์์ต๋๋ค (API ํค๋ฅผ _MobSF/settings.py_์ ์ค์ ํ๊ณ ํ์ฑํํด์ผ ํฉ๋๋ค: VT_ENABLED = TRUE VT_API_KEY = <Your API key> VT_UPLOAD = TRUE). VT_UPLOAD์ False๋ก ์ค์ ํ๋ฉด ํ์ผ ๋์ hash๊ฐ upload๋ฉ๋๋ค.
Assisted Dynamic analysis with MobSF
MobSF๋ Android์ dynamic analysis์์๋ ๋งค์ฐ ์ ์ฉํ์ง๋ง, ์ด ๊ฒฝ์ฐ ํธ์คํธ์ MobSF์ genymotion์ ์ค์นํด์ผ ํฉ๋๋ค(๊ฐ์๋จธ์ ๋๋ Docker์์๋ ์๋ํ์ง ์์ต๋๋ค). Note: You need to start first a VM in genymotion and then MobSF.
MobSF dynamic analyser๋ ๋ค์์ ์ํํ ์ ์์ต๋๋ค:
- Dump application data (URLs, ๋ก๊ทธ, ํด๋ฆฝ๋ณด๋, ์ฌ์ฉ์๊ฐ ์ฐ์ ์คํฌ๋ฆฐ์ท, โExported Activity Testerโ๋ก ์์ฑํ ์คํฌ๋ฆฐ์ท, ์ด๋ฉ์ผ, SQLite ๋ฐ์ดํฐ๋ฒ ์ด์ค, XML ํ์ผ ๋ฐ ๊ธฐํ ์์ฑ๋ ํ์ผ). ์ด๋ค ๋๋ถ๋ถ์ ์๋์ผ๋ก ์ํ๋์ง๋ง, ์คํฌ๋ฆฐ์ท์ ์๋์ผ๋ก ์ฐ์ด์ผ ํ๋ฉฐ ๋ชจ๋ exported activities์ ์คํฌ๋ฆฐ์ท์ ์ป์ผ๋ ค๋ฉด โExported Activity Testerโ๋ฅผ ๋๋ฌ์ผ ํฉ๋๋ค.
- Capture HTTPS traffic
- Frida๋ฅผ ์ฌ์ฉํด runtime information ํ๋
android versions > 5๋ถํฐ๋ Frida๋ฅผ ์๋์ผ๋ก ์์ํ๊ณ ํธ๋ํฝ์ ์บก์ฒํ๊ธฐ ์ํด ์ ์ญ proxy ์ค์ ์ ๊ตฌ์ฑํฉ๋๋ค. ์ด ์ค์ ์ ํ ์คํธ ์ค์ธ ์ ํ๋ฆฌ์ผ์ด์ ์ ํธ๋ํฝ๋ง ์บก์ฒํฉ๋๋ค.
Frida
๊ธฐ๋ณธ์ ์ผ๋ก ๋ช๋ช Frida ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํด bypass SSL pinning, root detection, debugger detection์ ์ํํ๊ณ ํฅ๋ฏธ๋ก์ด API๋ฅผ monitorํฉ๋๋ค.
MobSF๋ ๋ํ invoke exported activitiesํ๊ณ ํด๋น ํ๋์ screenshots์ ์บก์ฒํ์ฌ ๋ณด๊ณ ์์ saveํ ์ ์์ต๋๋ค.
๋์ ํ
์คํธ๋ฅผ startํ๋ ค๋ฉด ์ด๋ก์ ๋ฒํผ: โStart Instrumentationโ์ ๋๋ฅด์ญ์์ค. โFrida Live Logsโ๋ฅผ ๋๋ฌ Frida ์คํฌ๋ฆฝํธ๊ฐ ์์ฑํ ๋ก๊ทธ๋ฅผ ํ์ธํ๊ณ โLive API Monitorโ๋ฅผ ๋๋ฌ ํํน๋ ๋ฉ์๋์ ํธ์ถ, ์ ๋ฌ๋ ์ธ์ ๋ฐ ๋ฐํ๊ฐ์ ํ์ธํ ์ ์์ต๋๋ค(์ด ๊ธฐ๋ฅ์ โStart Instrumentationโ์ ๋๋ฅธ ํ ํ์๋ฉ๋๋ค).
MobSF๋ ์์ฒด Frida scripts๋ฅผ ๋ก๋ํ ์๋ ์์ต๋๋ค(Frida ์คํฌ๋ฆฝํธ์ ๊ฒฐ๊ณผ๋ฅผ MobSF๋ก ๋ณด๋ด๋ ค๋ฉด send() ํจ์๋ฅผ ์ฌ์ฉํ์ญ์์ค). ๋ํ ๋ช๋ช pre-written scripts๋ฅผ ๋ก๋ํ ์ ์์ผ๋ฉฐ(์ถ๊ฐ ์คํฌ๋ฆฝํธ๋ MobSF/DynamicAnalyzer/tools/frida_scripts/others/์ ์ถ๊ฐ ๊ฐ๋ฅ), ์คํฌ๋ฆฝํธ๋ฅผ selectํ ๋ค โLoadโ์ โStart Instrumentationโ์ ๋๋ฅด๋ฉด ํด๋น ์คํฌ๋ฆฝํธ์ ๋ก๊ทธ๋ฅผ โFrida Live Logsโ์์ ๋ณผ ์ ์์ต๋๋ค.
.png)
๋ํ ๋ช ๊ฐ์ง ๋ณด์กฐ Frida ๊ธฐ๋ฅ์ด ์์ต๋๋ค:
- Enumerate Loaded Classes: ๋ก๋๋ ๋ชจ๋ ํด๋์ค๋ฅผ ์ถ๋ ฅํฉ๋๋ค
- Capture Strings: ์ ํ๋ฆฌ์ผ์ด์ ์ฌ์ฉ ์ค ์บก์ฒ๋ ๋ชจ๋ ๋ฌธ์์ด์ ์ถ๋ ฅํฉ๋๋ค(๋งค์ฐ ๋ง์ ์ก์ ๋ฐ์)
- Capture String Comparisons: ๋งค์ฐ ์ ์ฉํ ์ ์์ต๋๋ค. ๋น๊ต๋๋ ๋ ๋ฌธ์์ด๊ณผ ๊ทธ ๊ฒฐ๊ณผ(True/False)๋ฅผ showํฉ๋๋ค.
- Enumerate Class Methods: ํด๋์ค ์ด๋ฆ(์: โjava.io.Fileโ)์ ์ ๋ ฅํ๋ฉด ํด๋น ํด๋์ค์ ๋ชจ๋ ๋ฉ์๋๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
- Search Class Pattern: ํจํด์ผ๋ก ํด๋์ค ๊ฒ์
- Trace Class Methods: Trace ์ ์ฒด ํด๋์ค๋ฅผ ๊ธฐ๋กํฉ๋๋ค(ํด๋์ค์ ๋ชจ๋ ๋ฉ์๋ ์ ๋ ฅ๊ณผ ์ถ๋ ฅ ํ์ธ). ๊ธฐ๋ณธ์ ์ผ๋ก MobSF๋ ์ฌ๋ฌ ํฅ๋ฏธ๋ก์ด Android Api ๋ฉ์๋๋ฅผ traceํฉ๋๋ค.
์ฌ์ฉํ ๋ณด์กฐ ๋ชจ๋์ ์ ํํ ํ โStart Intrumentationโ์ ๋๋ฅด๋ฉด ๋ชจ๋ ์ถ๋ ฅ์ด โFrida Live Logsโ์ ํ์๋ฉ๋๋ค.
Shell
MobSF๋ ๋์ ๋ถ์ ํ์ด์ง ํ๋จ์ ๋ช ๊ฐ์ง adb ๋ช ๋ น, MobSF commands, ๊ทธ๋ฆฌ๊ณ ์ผ๋ฐ์ ์ธ shell commands๋ฅผ ์ ๊ณตํ๋ shell์ ํฌํจํฉ๋๋ค. ๋ช ๊ฐ์ง ํฅ๋ฏธ๋ก์ด ๋ช ๋ น:
help
shell ls
activities
exported_activities
services
receivers
HTTP ๋๊ตฌ
When http traffic is capture you can see an ugly view of the captured traffic on โHTTP(S) Trafficโ bottom or a nicer view in โStart HTTPToolsโ green bottom. From the second option, you can send the captured requests to proxies like Burp or Owasp ZAP.
To do so, power on Burp โ> turn off Intercept โ> in MobSB HTTPTools select the request โ> press โSend to Fuzzerโ โ> select the proxy address (http://127.0.0.1:8080\).
Once you finish the dynamic analysis with MobSF you can press on โStart Web API Fuzzerโ to fuzz http requests an look for vulnerabilities.
Tip
After performing a dynamic analysis with MobSF the proxy settings me be misconfigured and you wonโt be able to fix them from the GUI. You can fix the proxy settings by doing:
adb shell settings put global http_proxy :0
Inspeckage๋ฅผ ์ด์ฉํ Assisted Dynamic Analysis
You can get the tool from Inspeckage.
This tool with use some Hooks to let you know what is happening in the application while you perform a dynamic analysis.
Yaazhini
This is a great tool to perform static analysis with a GUI
.png)
Qark
This tool is designed to look for several security related Android application vulnerabilities, either in source code or packaged APKs. The tool is also capable of creating a โProof-of-Conceptโ deployable APK and ADB commands, to exploit some of the found vulnerabilities (Exposed activities, intents, tapjackingโฆ). As with Drozer, there is no need to root the test device.
pip3 install --user qark # --user is only needed if not using a virtualenv
qark --apk path/to/my.apk
qark --java path/to/parent/java/folder
qark --java path/to/specific/java/file.java
ReverseAPK
- ์ฐธ๊ณ ํ๊ธฐ ์ฝ๋๋ก ์ถ์ถ๋ ๋ชจ๋ ํ์ผ์ ํ์
- APK ํ์ผ์ Java ๋ฐ Smali ํ์์ผ๋ก ์๋์ผ๋ก ๋์ปดํ์ผ
- AndroidManifest.xml์ ๋ถ์ํ์ฌ ์ผ๋ฐ์ ์ธ ์ทจ์ฝ์ ๋ฐ ๋์ ํ์ธ
- ์ ์ ์์ค ์ฝ๋ ๋ถ์์ผ๋ก ์ผ๋ฐ์ ์ธ ์ทจ์ฝ์ ๋ฐ ๋์ ๊ฒ์ฌ
- ๊ธฐ๊ธฐ ์ ๋ณด
- ๊ทธ ์ธ
reverse-apk relative/path/to/APP.apk
SUPER Android Analyzer
SUPER๋ Windows, MacOS X ๋ฐ Linux์์ ์ฌ์ฉํ ์ ์๋ ์ปค๋งจ๋๋ผ์ธ ์ ํ๋ฆฌ์ผ์ด์ ์ผ๋ก, ์ทจ์ฝ์ ์ ์ฐพ๊ธฐ ์ํด .apk ํ์ผ์ ๋ถ์ํฉ๋๋ค. ์ด๋ APKs๋ฅผ ์์ถ ํด์ ํ๊ณ ์ผ๋ จ์ ๊ท์น์ ์ ์ฉํ์ฌ ํด๋น ์ทจ์ฝ์ ์ ํ์งํฉ๋๋ค.
๋ชจ๋ ๊ท์น์ rules.json ํ์ผ์ ์ง์ค๋์ด ์์ผ๋ฉฐ, ๊ฐ ํ์ฌ๋ ํ
์คํฐ๋ ํ์ํ ๋ถ์์ ์ํด ์์ฒด ๊ท์น์ ์์ฑํ ์ ์์ต๋๋ค.
์ต์ ๋ฐ์ด๋๋ฆฌ๋ download page์์ ๋ค์ด๋ก๋ํ์ธ์.
super-analyzer {apk_file}
StaCoAn
.png)
StaCoAn์ ๋ชจ๋ฐ์ผ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ํ static code analysis๋ฅผ ์ํํ๋ ๊ฐ๋ฐ์, bugbounty hunters ๋ฐ ethical hackers๋ฅผ ๋๋ crossplatform ๋๊ตฌ์ ๋๋ค.
๊ฐ๋ ์ ๋ชจ๋ฐ์ผ ์ ํ๋ฆฌ์ผ์ด์ ํ์ผ(.apk ๋๋ .ipa ํ์ผ)์ StaCoAn ์ ํ๋ฆฌ์ผ์ด์ ์ผ๋ก ๋๋๊ทธ ์ค ๋๋กญํ๋ฉด ์๊ฐ์ ์ด๊ณ ํด๋ ๊ฐ๋ฅํ ๋ณด๊ณ ์๋ฅผ ์์ฑํด ์ค๋ค๋ ๊ฒ์ ๋๋ค. ์ค์ ๊ณผ wordlists๋ฅผ ์กฐ์ ํ์ฌ ๋ง์ถคํ ๊ฒฝํ์ ์ป์ ์ ์์ต๋๋ค.
๋ค์ด๋ก๋ latest release:
./stacoan
AndroBugs
AndroBugs Framework๋ Android ์ ํ๋ฆฌ์ผ์ด์
์ ์ ์ฌ์ ์ธ security vulnerabilities๋ฅผ ๊ฐ๋ฐ์ ๋๋ hackers๊ฐ ์ฐพ์ ์ ์๋๋ก ๋๋ vulnerability analysis ์์คํ
์
๋๋ค.
Windows releases
python androbugs.py -f [APK file]
androbugs.exe -f [APK file]
Androwarn
Androwarn์ Android ์ ํ๋ฆฌ์ผ์ด์ ์ด ๊ฐ๋ฐํ ์ ์ฌ์ ์ธ ์ ์ฑ ๋์์ ํ์งํ๊ณ ์ฌ์ฉ์์๊ฒ ๊ฒฝ๊ณ ํ๋ ๊ฒ์ ์ฃผ๋ ๋ชฉํ๋ก ํ๋ ๋๊ตฌ์ ๋๋ค.
ํ์ง๋ ์ ํ๋ฆฌ์ผ์ด์
์ Dalvik bytecode๋ฅผ Smali๋ก ํํํ ๊ฒ์ androguard ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ static analysis๋ก ์ํ๋ฉ๋๋ค.
์ด ๋๊ตฌ๋ ๋ค์๊ณผ ๊ฐ์ โ์ ์ฑโ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ผ๋ฐ์ ์ธ ๋์์ ์ฐพ์ต๋๋ค: Telephony identifiers exfiltration, Audio/video flow interception, PIM data modification, Arbitrary code executionโฆ
python androwarn.py -i my_application_to_be_analyzed.apk -r html -v 3
MARA Framework
.png)
MARA is a Mobile Application Reverse engineering and Analysis Framework. ์ด ๋๊ตฌ๋ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋๋ mobile application reverse engineering and analysis tools๋ฅผ ๋ชจ์ OWASP mobile security threats์ ๋ํด ๋ชจ๋ฐ์ผ ์ ํ๋ฆฌ์ผ์ด์ ์ ํ ์คํธํ๋ ๊ฒ์ ๋์ต๋๋ค. ๋ชฉ์ ์ ๋ชจ๋ฐ์ผ ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ๋ฐ์์ ๋ณด์ ์ ๋ฌธ๊ฐ๋ค์ด ์ด ์์ ์ ๋ ์ฝ๊ณ ์นํ์ ์ผ๋ก ์ํํ ์ ์๊ฒ ํ๋ ๊ฒ์ ๋๋ค.
It is able to:
- Extract Java and Smali code using different tools
- Analyze APKs using: smalisca, ClassyShark, androbugs, androwarn, APKiD
- Extract private information from the APK using regexps.
- Analyze the Manifest.
- Analyze found domains using: pyssltest, testssl and whatweb
- Deobfuscate APK via apk-deguard.com
Koodous
Useful to detect malware: https://koodous.com/
Obfuscating/Deobfuscating code
Note that depending the service and configuration you use to obfuscate the code. Secrets may or may not ended obfuscated.
ProGuard
From Wikipedia: ProGuard is an open source command-line tool that shrinks, optimizes and obfuscates Java code. It is able to optimize bytecode as well as detect and remove unused instructions. ProGuard is free software and is distributed under the GNU General Public License, version 2.
ProGuard is distributed as part of the Android SDK and runs when building the application in release mode.
DexGuard
Find a step-by-step guide to deobfuscate the apk in https://blog.lexfo.fr/dexguard.html
(From that guide) Last time we checked, the Dexguard mode of operation was:
- load a resource as an InputStream;
- feed the result to a class inheriting from FilterInputStream to decrypt it;
- do some useless obfuscation to waste a few minutes of time from a reverser;
- feed the decrypted result to a ZipInputStream to get a DEX file;
- finally load the resulting DEX as a Resource using the
loadDexmethod.
DeGuard
DeGuard reverses the process of obfuscation performed by Android obfuscation tools. This enables numerous security analyses, including code inspection and predicting libraries.
You can upload an obfuscated APK to their platform.
[Deobfuscate android App]https://github.com/In3tinct/deobfuscate-android-app
This is a LLM tool to find any potential security vulnerabilities in android apps and deobfuscate android app code. Uses Googleโs Gemini public API.
Simplify
It is a generic android deobfuscator. Simplify virtually executes an app to understand its behavior and then tries to optimize the code so it behaves identically but is easier for a human to understand. Each optimization type is simple and generic, so it doesnโt matter what the specific type of obfuscation is used.
APKiD
APKiD gives you information about how an APK was made. It identifies many compilers, packers, obfuscators, and other weird stuff. Itโs PEiD for Android.
Manual
Read this tutorial to learn some tricks on how to reverse custom obfuscation
Labs
Androl4b
AndroL4b is an Android security virtual machine based on ubuntu-mate includes the collection of latest framework, tutorials and labs from different security geeks and researchers for reverse engineering and malware analysis.
References
- Play Integrity API: How It Works & How to Bypass It
- https://owasp.org/www-project-mobile-app-security/
- https://appsecwiki.com/#/ It is a great list of resources
- https://maddiestone.github.io/AndroidAppRE/ Android quick course
- https://manifestsecurity.com/android-application-security/
- https://github.com/Ralireza/Android-Security-Teryaagh
- https://www.youtube.com/watch?v=PMKnPaGWxtg&feature=youtu.be&ab_channel=B3nacSec
- SSLPinDetect: Advanced SSL Pinning Detection for Android Security Analysis
- SSLPinDetect GitHub
- smali-sslpin-patterns
- Build a Repeatable Android Bug Bounty Lab: Emulator vs Magisk, Burp, Frida, and Medusa
- CoRPhone โ Android in-memory JNI execution and packaging pipeline
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


