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ããµããŒããã
- ãµãã¹ã¯ãªãã·ã§ã³ãã©ã³ã確èªããŠãã ããïŒ
- **ð¬ Discordã°ã«ãŒããŸãã¯ãã¬ã°ã©ã ã°ã«ãŒãã«åå ããããTwitter ðŠ @hacktricks_liveããã©ããŒããŠãã ããã
- HackTricksããã³HackTricks Cloudã®GitHubãªããžããªã«PRãæåºããŠãããã³ã°ããªãã¯ãå ±æããŠãã ããã
Androidã¢ããªã±ãŒã·ã§ã³ã®åºæ¬
ãã®ããŒãžãæåã«èªãããšã匷ãããããããŸããAndroidã»ãã¥ãªãã£ã«é¢é£ããæãéèŠãªéšåãšãAndroidã¢ããªã±ãŒã·ã§ã³å ã§æãå±éºãªã³ã³ããŒãã³ãã«ã€ããŠç¥ãããã§ãïŒ
ADB (Android Debug Bridge)
ããã¯Androidããã€ã¹ïŒãšãã¥ã¬ãŒãããããã®ãŸãã¯å®æ©ïŒã«æ¥ç¶ããããã«å¿
èŠãªäž»èŠãªããŒã«ã§ãã
ADB ã䜿ããšãã³ã³ãã¥ãŒã¿ãã USB ãŸã㯠Network çµç±ã§ããã€ã¹ãå¶åŸ¡ã§ããŸãããã®ãŠãŒãã£ãªãã£ã¯ããã¡ã€ã«ã®åæ¹åã® ã³ããŒãã¢ããªã® ã€ã³ã¹ããŒã« ãš ã¢ã³ã€ã³ã¹ããŒã«ãã·ã§ã«ã³ãã³ãã® å®è¡ãããŒã¿ã® ããã¯ã¢ããããã°ã® èªã¿åã ãªã©ã®æ©èœãæäŸããŸãã
adbã®äœ¿ãæ¹ãåŠã¶ã«ã¯ã以äžã® ADB Commands ã®äžèЧãåç §ããŠãã ããã
Smali
æã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒãã倿Žããããšã§é ãããæ
å ±ïŒå·§åŠã«é£èªåããããã¹ã¯ãŒãããã©ã°ãªã©ïŒã«ã¢ã¯ã»ã¹ããããšãæçšã§ãããã®å Žåãapkããã³ã³ãã€ã«ããŠã³ãŒããä¿®æ£ããåã³ã³ãã€ã«ããããšãæå¹ãããããŸããã
In this tutorial you can learn how to decompile and APK, modify Smali code and recompile the APK with the new functionalityãããã¯ããããã玹ä»ããåçè§£æäžã®è€æ°ã®ãã¹ãã«å¯Ÿããä»£æ¿ææ®µãšããŠéåžžã«æçšã§ãããããã£ãŠããã®å¯èœæ§ãåžžã«å¿µé ã«çœ®ããŠãããŠãã ããã
ãã®ä»ã®è峿·±ãããªãã¯
- 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)
- APKãããŠã³ããŒã: 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 ã®æ»æ
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 ã® strings ãèŠãã ãã§ãpasswordsãURLs (https://github.com/ndelphit/apkurlgrep)ãapi keysãencryptionãbluetooth uuidsãtokens ãªã©ãè峿·±ããã®ãæ€çŽ¢ã§ããŸããã³ãŒãå®è¡ã® backdoors ãèªèšŒ backdoorsïŒã¢ããªã«ããŒãã³ãŒãã£ã³ã°ããã管çè è³æ Œæ å ±ïŒãæ¢ããŠãã ããã
Firebase
ç¹ã« firebase URLs ã«æ³šæããèšå®ãã¹ããªãã確èªããŠãã ããã More information about whats is FIrebase and how to exploit it here.
ã¢ããªã±ãŒã·ã§ã³ã®åºæ¬ççè§£ - Manifest.xmlãstrings.xml
ã¢ããªã±ãŒã·ã§ã³ã® Manifest.xml ãš strings.xml ãã¡ã€ã«ã®èª¿æ»ã¯æœåšçãªã»ãã¥ãªãã£è匱æ§ãæããã«ããããšããããŸãããããã®ãã¡ã€ã«ã¯ãã³ã³ãã€ã©ã䜿çšããããAPK ã®æ¡åŒµåã .zip ã«å€æŽããŠå±éããããšã§ååŸã§ããŸãã
Manifest.xml ããç¹å®ãããè匱æ§ã«ã¯æ¬¡ã®ãã®ããããŸã:
- Debuggable Applications: Manifest.xml ã«
debuggable="true"ãèšå®ãããã¢ããªã¯ãªã¹ã¯ããããŸããå€éšããã®æ¥ç¶ãèš±ããŠããŸããæªçšã«ã€ãªããå¯èœæ§ããããŸããããã€ã¹äžã§ debuggable ãªã¢ããªãçºèŠã»æªçšããæ¹æ³ã«ã€ããŠã¯ãã¥ãŒããªã¢ã«ãåç §ããŠãã ããã - Backup Settings:
android:allowBackup="false"屿§ã¯ãæ©å¯æ å ±ãæ±ãã¢ããªã§ã¯æç€ºçã«èšå®ããŠããã¹ãã§ããç¹ã« usb debugging ãæå¹ãªå Žåãadb çµç±ã§ã®äžæ£ãªããŒã¿ããã¯ã¢ãããé²ãããéèŠã§ãã - Network Security: ã«ã¹ã¿ã ã®ãããã¯ãŒã¯ã»ãã¥ãªãã£èšå®ïŒ
android:networkSecurityConfig="@xml/network_security_config"ïŒã¯ res/xml/ ã«çœ®ãããèšŒææžãã³ã HTTP ãã©ãã£ãã¯ã®èš±å¯èšå®ãªã©ã®ã»ãã¥ãªãã£è©³çްãæå®ã§ããŸããäŸãã°ç¹å®ãã¡ã€ã³åãã« HTTP ãã©ãã£ãã¯ãèš±å¯ããèšå®ãªã©ããããŸãã - Exported Activities and Services: ãããã§ã¹ãå ã® exported 㪠activities ã services ãç¹å®ããããšã§ãäžæ£å©çšãããå¯èœæ§ã®ããã³ã³ããŒãã³ããæããã«ãªããŸããåçãã¹ãäžã®è¿œå è§£æã§ããããã©ã®ããã«æªçšã§ããããåãããŸãã
- Content Providers and FileProviders: å ¬éããã content provider ã¯ããŒã¿ãžã®äžæ£ãªã¢ã¯ã»ã¹ãæ¹ãããèš±ãå¯èœæ§ããããŸããFileProvider ã®èšå®ãæ³šææ·±ã確èªããå¿ èŠããããŸãã
- Broadcast Receivers and URL Schemes: ãããã®ã³ã³ããŒãã³ãã¯æªçšã«äœ¿ãããããšããããç¹ã« URL ã¹ããŒã ã®å ¥ååŠçã«æ³šæãå¿ èŠã§ãã
- SDK Versions:
minSdkVersionãtargetSDKVersionãmaxSdkVersion屿§ã¯ãµããŒããã Android ããŒãžã§ã³ã瀺ããŸããå€ãè匱㪠Android ããŒãžã§ã³ããµããŒããç¶ããããšã®å±éºæ§ã瀺ããŸãã
strings.xml ãã㯠API keysãcustom schemasãããã³ãã®ä»ã®éçºè ã¡ã¢ãªã©ã®æ©å¯æ å ±ãèŠã€ããããšãããããããã®ãªãœãŒã¹ãæ éã«ã¬ãã¥ãŒããå¿ èŠããããŸãã
Tapjacking
Tapjacking ã¯ãæªæã®ããã¢ããªãèµ·åããã被害è ã¢ããªã®äžã«èªèº«ãé 眮ããæ»æã§ãã被害ã¢ããªãèŠèŠçã«èŠãé ããåŸãæªæããã¢ããªã® UI ã¯ãŠãŒã¶ãŒãéšããŠæäœããã€ã€ããã®æäœã被害ã¢ããªãžééçã«æž¡ãããã«èšèšãããŸããçµæãšããŠãŠãŒã¶ãŒã¯ãå®éã«ã¯è¢«å®³ã¢ããªäžã§æäœãè¡ã£ãŠããããšã«æ°ã¥ããªããªããŸãã
Find more information in:
Task Hijacking
launchMode ã singleTask ã«èšå®ãããã〠taskAffinity ãå®çŸ©ãããŠããªã activity 㯠Task Hijacking ã®åœ±é¿ãåããŸããããã¯ãæªæã®ãã application ãã€ã³ã¹ããŒã«ããŠæ¬ç©ã®ã¢ããªããå
ã«èµ·åãããšãæ¬ç©ã®ã¢ããªã®ã¿ã¹ã¯ã hijack ããŠããŸãå¯èœæ§ãããããšãæå³ããŸãïŒãŠãŒã¶ãŒã¯æ¬ç©ã®ã¢ããªã䜿ã£ãŠããã€ããã§æªæããã¢ããªãšããåãããŠããããšã«ãªããŸãïŒã
More info in:
äžé©åãªããŒã¿ä¿å
å éšã¹ãã¬ãŒãž (Internal Storage)
Android ã§ã¯ãå
éšã¹ãã¬ãŒãžã«ä¿åããããã¡ã€ã«ã¯ãããäœæããã¢ããªã®ã¿ãã¢ã¯ã»ã¹ã§ããããã«èšèšãããŠããŸãããã®ã»ãã¥ãªãã£å¯Ÿç㯠OS ã«ãã£ãŠåŒ·å¶ãããå€ãã®ã¢ããªã®ã»ãã¥ãªãã£èŠä»¶ã«ã¯ååã§ããããããéçºè
ã MODE_WORLD_READABLE ã MODE_WORLD_WRITABLE ãšãã£ãã¢ãŒããå©çšããŠãã¡ã€ã«ãä»ã®ã¢ããªéã§å
±æããããšããããŸãããããã®ã¢ãŒãã¯ä»ã®ã¢ããªãå Žåã«ãã£ãŠã¯æªæããã¢ããªã«ããã¢ã¯ã»ã¹ãå¶éããŸããã
- éçè§£æ:
MODE_WORLD_READABLEãšMODE_WORLD_WRITABLEã®äœ¿çšãæ éã«ç¢ºèªããŠãã ããããããã®ã¢ãŒãã¯ãã¡ã€ã«ãæå³ããªãããŸãã¯äžæ£ãªã¢ã¯ã»ã¹ã«æãå¯èœæ§ããããŸãã
- åçè§£æ:
- ã¢ããªãäœæãããã¡ã€ã«ã®æš©éãæ€èšŒããŠãã ãããç¹ã«ããã¡ã€ã«ãäžçäžã§èªã¿åããŸãã¯æžã蟌ã¿å¯èœã«èšå®ãããŠããªããã確èªããŸããããã¯é倧ãªã»ãã¥ãªãã£ãªã¹ã¯ãšãªããããã€ã¹äžã®ã©ã®ã¢ããªããã§ããã¡ã€ã«ãèªã¿æžããããå¯èœæ§ããããŸãã
å€éšã¹ãã¬ãŒãž (External Storage)
SD ã«ãŒããªã©ã®å€éšã¹ãã¬ãŒãžã®ãã¡ã€ã«ãæ±ãéã®æ³šæç¹:
- ã¢ã¯ã»ã¹æ§:
- å€éšã¹ãã¬ãŒãžäžã®ãã¡ã€ã«ã¯äžè¬ã«ã°ããŒãã«ã«èªã¿æžãå¯èœã§ããã€ãŸããä»»æã®ã¢ããªããŠãŒã¶ãŒãã¢ã¯ã»ã¹ã§ããŸãã
- ã»ãã¥ãªãã£äžã®æžå¿µ:
- ã¢ã¯ã»ã¹ã容æãªãããå€éšã¹ãã¬ãŒãžã«æ©å¯æ å ±ãä¿åããªãããšãæšå¥šãããŸãã
- å€éšã¹ãã¬ãŒãžã¯åãå€ãããããä»»æã®ã¢ããªããã¢ã¯ã»ã¹ããåŸãããå®å šæ§ãäœããªããŸãã
- å€éšã¹ãã¬ãŒãžããã®ããŒã¿æ±ã:
- å€éšã¹ãã¬ãŒãžããååŸããããŒã¿ã¯åžžã«å ¥åæ€èšŒãè¡ã£ãŠãã ãããå€éšã¹ãã¬ãŒãžäžã®ããŒã¿ã¯ä¿¡é Œã§ããªããœãŒã¹ããæ¥ãå¯èœæ§ãããããéèŠã§ãã
- å€éšã¹ãã¬ãŒãžã« executables ã class ãã¡ã€ã«ã眮ããŠåçã«ããŒãããããšã¯åŒ·ãæšå¥šãããŸããã
- ã©ãããŠãå€éšã¹ãã¬ãŒãžããå®è¡ãã¡ã€ã«ãååŸããå¿ èŠãããå Žåã¯ããããã®ãã¡ã€ã«ã眲åããæå·çã«æ€èšŒãããŠããããšã確èªããŠããåçã«ããŒãããŠãã ãããããã¯ã¢ããªã®ã»ãã¥ãªãã£æŽåæ§ãä¿ã€ããã«äžå¯æ¬ ã§ãã
å€éšã¹ãã¬ãŒãžã¯ /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 ããŒã¿ããŒã¹ãç°¡åã«ä¿åã§ããããã«ããŠããããã®ãã©ã«ãå ã«å¹³æã§æ©å¯æ å ±ãèŠã€ããããšããããŸãã
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.
æå·ã®è匱æ§
äžé©åãªããŒç®¡çããã»ã¹
äžéšã®éçºè ã¯ãæ©å¯ããŒã¿ãããŒã«ã«ã¹ãã¬ãŒãžã«ä¿åããã³ãŒãå ã«ããŒãã³ãŒãïŒäºæž¬å¯èœãªããŒã§æå·åããŠããŸããããã¯é¿ããã¹ãã§ããªããŒã¹ãšã³ãžãã¢ãªã³ã°ã«ããæ»æè ãæ©å¯æ å ±ãæœåºã§ããå¯èœæ§ããããŸãã
Insecure ããã³/ãŸã㯠Deprecated ãªã¢ã«ãŽãªãºã ã®äœ¿çš
éçºè ã¯èªèšŒãã§ãã¯ãããŒã¿ã®ä¿åãéä¿¡ã« deprecated algorithms ã䜿çšãã¹ãã§ã¯ãããŸãããäŸãšã㊠RC4ãMD4ãMD5ãSHA1 ãªã©ããããŸããäŸãã°ãã¹ã¯ãŒãã®ä¿åã« hashes ã䜿ãå Žåã¯ãsalt ã䜿ã£ã brute-force resistant ãªããã·ã¥ãå©çšããŠãã ããã
ãã®ä»ã®ãã§ãã¯
- éè§£æã®é£æåºŠãäžããããã«ãAPK ã obfuscate ããããšãæšå¥šãããŸãã
- ã¢ããªãæ©å¯æ§ã®é«ããã®ïŒbank apps ã®ãããªïŒã§ããã°ãã¢ãã€ã«ã rooted ãã©ãããã¢ããªèªèº«ã§ãã§ãã¯ããããã«å¿ãã察åŠãè¡ãã¹ãã§ãã
- ã¢ããªãæ©å¯æ§ã®é«ããã®ïŒbank apps ã®ãããªïŒã§ããã°ãemulator ã䜿ãããŠãããã©ããããã§ãã¯ããã¹ãã§ãã
- ã¢ããªãæ©å¯æ§ã®é«ããã®ïŒbank apps ã®ãããªïŒã§ããã°ãå®è¡åã« èªèº«ã®æŽåæ§ããã§ã㯠ããŠæ¹å€ãããŠããªãã確èªããã¹ãã§ãã
- APK ããã«ãããéã«äœ¿ãããã³ã³ãã€ã©ïŒããã«ãŒïŒobfuscator ã確èªããã«ã¯ APKiD ã䜿çšããŠãã ãã
React Native ã¢ããªã±ãŒã·ã§ã³
React ã¢ããªã±ãŒã·ã§ã³ã® javascript ã³ãŒãã«ç°¡åã«ã¢ã¯ã»ã¹ããæ¹æ³ã«ã€ããŠã¯ã次ã®ããŒãžãåç §ããŠãã ããïŒ
Xamarin ã¢ããªã±ãŒã·ã§ã³
Xamarin ã¢ããªã±ãŒã·ã§ã³ã® C# ã³ãŒãã«ç°¡åã«ã¢ã¯ã»ã¹ããæ¹æ³ã«ã€ããŠã¯ã次ã®ããŒãžãåç §ããŠãã ããïŒ
Superpacked Applications
ãã® blog post ã«ãããšãsuperpacked ã¯ã¢ããªã®ã³ã³ãã³ããåäžãã¡ã€ã«ã«å§çž®ãã Meta ã¢ã«ãŽãªãºã ã§ããããã°ã§ã¯ãã®çš®ã®ã¢ããªãå±éããã¢ããªãäœããå¯èœæ§ã«ã€ããŠè¿°ã¹ãããŠããããã¡ã€ã«ã·ã¹ãã ããå±éæžã¿ãã¡ã€ã«ãåéããããã« ã¢ããªãå®è¡ããŠå±éããããã¡ã€ã«ãååŸãã ããé«éãªæ¹æ³ã«ã€ããŠãè§ŠããããŠããŸãã
èªåéçã³ãŒãè§£æ
ããŒã« mariana-trench ã¯ã¢ããªã±ãŒã·ã§ã³ã® code ã scanning ããããšã§ vulnerabilities ãæ€åºããããšãã§ããŸãããã®ããŒã«ã¯ known sourcesïŒãŠãŒã¶ãå¶åŸ¡ãã input ãå ¥ã å Žæ ãããŒã«ã«ç€ºããã®ïŒãsinksïŒæªæããå ¥åããã¡ãŒãžãäžããã å±éºãªå Žæ ã瀺ããã®ïŒãããã³ rules ãå«ã¿ãŸãããããã® rules ã¯è匱æ§ã瀺ã sources-sinks ã®çµã¿åãã ãå®çŸ©ããŸãã
ãã®ç¥èã«ãããmariana-trench ã¯ã³ãŒããã¬ãã¥ãŒããŠæœåšçãªè匱æ§ãçºèŠããŸãã
Secrets leaked
ã¢ããªã±ãŒã·ã§ã³ã«ã¯ API keysããã¹ã¯ãŒããé ã URLããµããã¡ã€ã³ãªã©ã® secrets ãå«ãŸããŠããããšããããããããçºèŠã§ããå¯èœæ§ããããŸããäŸãã°æ¬¡ã®ãããªããŒã«ã䜿ããŸã: https://github.com/dwisiswant0/apkleaks
Bypass Biometric Authentication
Bypass Biometric Authentication (Android)
ãã®ä»ã®è峿·±ã颿°
- Code execution:
Runtime.exec(), ProcessBuilder(), native code:system() - Send SMSs:
sendTextMessage, sendMultipartTestMessage - Native functions 宣èšã¯
native:public native, System.loadLibrary, System.load - ãã€ãã£ã颿°ããªããŒã¹ããæ¹æ³ã¯ãã¡ããåç §
- JNI ãä»ããã¡ã¢ãªå ãã€ãã£ãã³ãŒãå®è¡ïŒããŠã³ããŒããã shellcode â mmap/mprotect â åŒã³åºãïŒ:
In Memory Jni Shellcode Execution
Other tricks
Dynamic Analysis
ãŸã第äžã«ãã¢ããªã±ãŒã·ã§ã³ããã³å¿ èŠãªç°å¢ïŒBurp CA certãDrozerãFrida ãªã©ïŒãã€ã³ã¹ããŒã«ã§ããç°å¢ãå¿ èŠã§ãããããã£ãŠãrooted ããã€ã¹ïŒãšãã¥ã¬ãŒãããããã®ã§ãïŒã¯åŒ·ãæšå¥šãããŸãã
Online Dynamic analysis
ç¡æã¢ã«ãŠã³ããäœæã§ãããµãŒãã¹ã®äžã€ã«: https://appetize.io/ ããããŸãããã®ãã©ãããã©ãŒã 㯠APK ã upload ã㊠execute ã§ãããããAPK ã®æåã確èªããã®ã«äŸ¿å©ã§ãã
Web äžã§ã¢ããªã±ãŒã·ã§ã³ã®ãã°ã èŠã ããšãã§ããadb ãéããŠæ¥ç¶ããããšãã§ããŸãã
.png)
ADB æ¥ç¶ã«ããããšãã¥ã¬ãŒã¿å ã§ Drozer ã Frida ã䜿çšã§ããŸãã
Local Dynamic Analysis
Using an emulator
- Android StudioïŒx86 ãš arm ããã€ã¹ãäœæã§ããŸãããŸã ãã®æ å ± ã«ããã° ææ°ã® x86 ã§ã¯é ã arm ãšãã¥ã¬ãŒã¿ã䜿ããã« ARM ã©ã€ãã©ãªããµããŒãããŠããŸãïŒã
- ã»ããã¢ããæ¹æ³ã¯æ¬¡ã®ããŒãžãåç §ããŠãã ããïŒ
- Genymotion (Free version: Personal Editionãã¢ã«ãŠã³ãäœæãå¿ èŠã§ãããšã©ãŒåé¿ã®ããã« VirtualBox ãšäžç·ã® ããŒãžã§ã³ã download ããããšãæšå¥šããŸãã_)
- NoxïŒç¡æã§ãããFrida ã Drozer ããµããŒãããŸããïŒã
Tip
ã©ã®ãã©ãããã©ãŒã ã§æ°ãããšãã¥ã¬ãŒã¿ãäœæããå Žåã§ããç»é¢ã倧ããã»ã©ãšãã¥ã¬ãŒã¿ã¯é ããªããŸããå¯èœã§ããã°å°ããç»é¢ãéžæããŠãã ããã
Genymotion ã« Google ãµãŒãã¹ïŒPlay Store çïŒãã€ã³ã¹ããŒã«ããã«ã¯ã次ã®ç»åã®èµ€ããã¿ã³ãã¯ãªãã¯ããŠãã ããïŒ
.png)
ãŸããGenymotion ã® Android VM ã®èšå®ã§ Bridge Network mode ãéžæã§ããããšã«æ³šæããŠãã ããïŒããã¯å¥ã® VM ããããŒã«ã§ Android VM ã«æ¥ç¶ããå Žåã«æçšã§ãïŒã
Use a physical device
debugging ãªãã·ã§ã³ãæå¹ã«ããå¯èœã§ããã° root ããããšãæãŸããã§ãïŒ
- Settingsã
- (FromAndroid 8.0) System ãéžæã
- About phone ãéžæã
- Build number ã7åæŒãã
- æ»ããš Developer options ã衚瀺ãããŸãã
ã¢ããªãã€ã³ã¹ããŒã«ããããæåã«è¡ãã¹ãããšã¯ã¢ããªã䜿ã£ãŠäœãããã®ããã©ã®ããã«åäœããã®ãã調ã¹ãæ £ããããšã§ãã
ãŸã㯠MobSF dynamic analysis + pidcat ã䜿ã£ãŠãã®åæã®åçè§£æãè¡ãããšãæšå¥šããŸããããã«ããã¢ããªã®åäœãåŠã³ã€ã€ãMobSF ãåŸã§ã¬ãã¥ãŒã§ããå€ãã®è峿·±ãããŒã¿ã capture ããŠãããŸãã
Magisk/Zygisk quick notes (Pixel ããã€ã¹ã§æšå¥š)
- Magisk ã¢ããªã§ boot.img ã patch ããfastboot çµç±ã§ flash ã㊠systemless root ãååŸ
- Zygisk ãæå¹åã DenyList ã§ root é èœãè¡ãïŒãã匷åãªé èœãå¿ èŠãªå Žå㯠LSPosed/Shamiko ãæ€èš
- OTA æŽæ°ããã®åŸ©æ§çšã«å ã® boot.img ãä¿æïŒOTA æ¯ã«å patch
- ç»é¢ãã©ãŒãªã³ã°ã«ã¯ãã¹ãã§ scrcpy ã䜿çš
Unintended Data Leakage
Logging
éçºè
㯠debugging information ãå
¬éããªãããæ³šæããã¹ãã§ããå
¬éããããšæ©å¯ããŒã¿ã® leak ã«ç¹ããå¯èœæ§ããããŸããã¢ããªãã°ã®ç£èŠã«ã¯ pidcat ã adb logcat ãæšå¥šããŸããPidcat ã¯äœ¿ãããããšå¯èªæ§ãã奜ãŸããŸãã
Warning
Android 4.0 ããæ°ããããŒãžã§ã³ä»¥éã§ã¯ãã¢ããªã±ãŒã·ã§ã³ã¯èªåèªèº«ã®ãã°ã«ããã¢ã¯ã»ã¹ã§ããŸããããããã£ãŠãä»ã®ã¢ããªã®ãã°ã«ã¯ã¢ã¯ã»ã¹ã§ããŸããã
ããã§ããªããæ©å¯æ å ±ããã°ã«åºåããªãããšãæšå¥šãããŸãã
Copy/Paste Buffer Caching
Android ã® clipboard-based ãã¬ãŒã ã¯ãŒã¯ã¯ã¢ããªéã§ã®ã³ããŒïŒããŒã¹ããå¯èœã«ããŸãããä»ã®ã¢ããªãã¯ãªããããŒãã«ã¢ã¯ã»ã¹ã§ãããããæ©å¯ããŒã¿ãé²åºãããªã¹ã¯ããããŸããã¯ã¬ãžããã«ãŒãæ å ±ãªã©æ©å¯æ§ã®é«ãã»ã¯ã·ã§ã³ã§ã¯ copy/paste æ©èœãç¡å¹ã«ããããšãéèŠã§ãã
Crash Logs
ã¢ããªãã¯ã©ãã·ã¥ããŠãã°ãä¿åããŠããå Žåããããã®ãã°ã¯ãªããŒã¹ã§ããªãã¢ããªã«å¯ŸããŠãæ»æè ãå©ããããšããããŸãã察çãšããŠã¯ãã¯ã©ãã·ã¥æã®ãã°åºåãé¿ãããããã°ããããã¯ãŒã¯çµç±ã§éä¿¡ããå¿ èŠãããå Žå㯠SSL ãã£ãã«ã䜿çšããŠãã ããã
pentester ãšããŠããããã®ãã°ã確èªããããã«ããŠãã ããã
Analytics Data Sent To 3rd Parties
ã¢ããªã¯ãã°ãã° Google Adsense ã®ãããªãµãŒãã¹ãçµ±åããŠãããéçºè ã®å®è£ äžåã«ããæ©å¯ããŒã¿ã第äžè ã« leak ããå¯èœæ§ããããŸãã第äžè ãµãŒãã¹ã«éä¿¡ãããŠããæ©å¯æ å ±ã確èªããã«ã¯ãã¢ããªã®ãã©ãã£ãã¯ã intercept ããŠãã§ãã¯ããããšãæšå¥šããŸãã
SQLite DBs
ã»ãšãã©ã®ã¢ããªã¯æ
å ±ãä¿åããããã« internal SQLite databases ã䜿çšããŸãããã³ãã¹ãäžã¯äœæããã databasesãtables ãš columns ã®ååãä¿åãããŠãããã¹ãŠã® data ã確èªããŠãã ãããããã«æ©å¯æ
å ±ãèŠã€ããããšããããŸãïŒè匱æ§ãšãªããŸãïŒã
ããŒã¿ããŒã¹ã¯éåžž /data/data/the.package.name/databases ã«ãããŸããäŸãã° /data/data/com.mwr.example.sieve/databases
ããŒã¿ããŒã¹ãæ©å¯æ å ±ãä¿åããŠã㊠encrypted ãããŠããŠããã¢ããªå ã«ãã¹ã¯ãŒããèŠã€ããå Žåã¯ããã¯äŸç¶ãšã㊠èåŒ±æ§ ã§ãã
.tables ã䜿ã£ãŠããŒãã«ãåæãã.schema <table_name> ã§ããŒãã«ã®ã«ã©ã ãåæããŠãã ããã
Drozer (Exploit Activities, Content Providers and Services)
From Drozer Docs: Drozer ã䜿ããš Android ã¢ããªã®åœ¹å²ãæ
ããä»ã®ã¢ããªãšããåãã§ããŸããã€ã³ã¹ããŒã«æžã¿ã¢ããªãã§ããããšãªãäœã§ãå®è¡ã§ããAndroid ã® Inter-Process Communication (IPC) æ©æ§ãå©çšããããåºç€ãšãªã OS ãšããåãã§ããŸãã
Drozer 㯠exported activitiesãexported servicesãContent Providers ã exploit ããããã®æçšãªããŒã«ã§ãã以äžã®ã»ã¯ã·ã§ã³ã§åŠã¹ãŸãã
Exploiting exported Activities
Read this if you want to refresh what is an Android Activity.
ãŸããActivity ã®ã³ãŒã㯠onCreate ã¡ãœããããéå§ããããšãèŠããŠãããŠãã ããã
Authorisation bypass
Activity ã exported ãããŠããå Žåãå€éšã¢ããªãããã®ç»é¢ãåŒã³åºãããšãã§ããŸãããããã£ãŠãsensitive information ãæ±ã Activity ã exported ãããŠãããšãèªèšŒæ©æ§ã bypass ããŠã¢ã¯ã»ã¹ãããå¯èœæ§ããããŸãã
Learn how to exploit exported activities with Drozer.
adb ãã exported activity ãèµ·åããããšãã§ããŸã:
- PackageName is com.example.demo
- Exported ActivityName is com.example.test.MainActivity
adb shell am start -n com.example.demo/com.example.test.MainActivity
泚æ: MobSF ã¯ã¢ã¯ãã£ããã£ã§ singleTask/singleInstance ã android:launchMode ãšããŠäœ¿çšããŠãããšæªæãããã®ãšæ€åºããŸãããthis ã«ãããšãããã¯å€ãããŒãžã§ã³ïŒAPI ããŒãžã§ã³ < 21ïŒã®ã¿ã§å±éºãªããã§ãã
Tip
Note that an authorisation bypass is not always a vulnerability, it would depend on how the bypass works and which information is exposed.
æ©å¯æ å ±ã®æŒæŽ©
Activities can also return results. If you manage to find an exported and unprotected activity calling the setResult method and returning sensitive information, there is a sensitive information leakage.
Tapjacking
If tapjacking isnât prevented, you could abuse the exported activity to make the user perform unexpected actions. For more info about 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 are basically used to share data. If an app has available content providers you may be able to extract sensitive data from them. It also interesting to test possible SQL injections and Path Traversals as they could be vulnerable.
Learn how to exploit Content Providers with Drozer.
Exploiting Services
Read this if you want to refresh what is a Service.
Remember that a the actions of a Service start in the method onStartCommand.
As service is basically something that can receive data, process it and returns (or not) a response. Then, if an application is exporting some services you should check the code to understand what is it doing and test it dynamically for extracting confidential info, bypassing authentication measuresâŠ
Learn how to exploit Services with Drozer.
Exploiting Broadcast Receivers
Read this if you want to refresh what is a Broadcast Receiver.
Remember that a the actions of a Broadcast Receiver start in the method onReceive.
A broadcast receiver will be waiting for a type of message. Depending on how the receiver handles the message it could be vulnerable.
Learn how to exploit Broadcast Receivers with Drozer.
Exploiting Schemes / Deep links
You can look for deep links manually, using tools like MobSF or scripts like this one.
You can open a declared scheme using adb or a 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>
Code executed
ã¢ããªã§å®è¡ãããã³ãŒããèŠã€ããããã«ãdeeplink ã«ãã£ãŠåŒã³åºããã activity ã«ç§»åãã颿° onNewIntent ãæ€çŽ¢ããŠãã ããã
 (1) (1) (1).png)
Sensitive info
deep link ãèŠã€ãããã³ã«ãURL ãã©ã¡ãŒã¿çµç±ã§ãã¹ã¯ãŒãã®ãã㪠sensitive data ãåãåã£ãŠããªãã確èªããŠãã ããããããªããšãä»ã®ã¢ããªã±ãŒã·ã§ã³ã deep link ãåœè£ ããŠãã®ããŒã¿ãçãå¯èœæ§ããããŸãïŒ
Parameters in path
URL ã®ãã¹å
ã§ãã©ã¡ãŒã¿ã䜿çšããŠãã deep link ããªãããå¿
ã確èªããŠãã ãããäŸãã°: https://api.example.com/v1/users/{username} ããã®å Žåãexample://app/users?username=../../unwanted-endpoint%3fparam=value ã®ããã« path traversal ã匷å¶ã§ããããšããããŸãã
ã¢ããªå
ã§è©²åœã®ãšã³ããã€ã³ããèŠã€ããå ŽåãïŒãã¹ã®äžéšããã¡ã€ã³åãšããŠäœ¿ããããšïŒOpen Redirect ãåŒãèµ·ãããããïŒCSRF token ããªããè匱ãªãšã³ããã€ã³ããæ£ããã¡ãœããã䜿çšããŠããå ŽåïŒaccount takeover ãåŒãèµ·ããããããã®ä»ã®è匱æ§ã«ç¹ããå¯èœæ§ãããç¹ã«æ³šæããŠãã ãããMore info about this here.
More examples
An interesting bug bounty report about links (/.well-known/assetlinks.json).
Transport Layer Inspection and Verification Failures
- Certificates are not always inspected properly by Android applications. ãããã®ã¢ããªãèŠåãèŠèœãšã㊠self-signed certificates ãåãå ¥ããããå Žåã«ãã£ãŠã¯ HTTP æ¥ç¶ã«æ»ãããããã®ã¯ããããããšã§ãã
- Negotiations during the SSL/TLS handshake are sometimes weak, insecure 㪠cipher suites ã䜿çšããŠããããšããããŸãããã®è匱æ§ã«ããæ¥ç¶ã man-in-the-middle (MITM) æ»æã«å¯ŸããŠè匱ã«ãªããæ»æè ãããŒã¿ã埩å·ã§ããå¯èœæ§ããããŸãã
- Leakage of private information ã¯ãã¢ããªãå®å šãªãã£ãã«ã§èªèšŒããåŸã«ä»ã®ååŒã§éå®å šãªãã£ãã«ã䜿çšããå Žåã«ãªã¹ã¯ãšãªããŸãããã®ããæ¹ã¯ã»ãã·ã§ã³ cookie ããŠãŒã¶ãŒè©³çްãªã©ã®æ©å¯ããŒã¿ãæªæãã第äžè ã«ããååããä¿è·ã§ããŸããã
Certificate Verification
ããã§ã¯ certificate verification ã«çŠç¹ãåœãŠãŸãããµãŒããŒèšŒææžã®æŽåæ§ãæ€èšŒããããšã¯ã»ãã¥ãªãã£ãé«ããäžã§éåžžã«éèŠã§ãããªããªããäžé©å㪠TLS èšå®ãæå·åãããŠããªããã£ãã«ã§ã®æ©å¯ããŒã¿éä¿¡ã¯é倧ãªãªã¹ã¯ãåŒãèµ·ããå¯èœæ§ãããããã§ãããµãŒããŒèšŒææžã®æ€èšŒãè匱æ§å¯Ÿå¿ã«é¢ããè©³çŽ°ãªæé ã¯ãthis resource ãåç §ããŠãã ããã
SSL Pinning
SSL Pinning ã¯ãã¢ããªããµãŒããŒèšŒææžãã¢ããªå ã«ä¿åãããæ¢ç¥ã®ã³ããŒãšç §åããŠæ€èšŒããã»ãã¥ãªãã£ææ³ã§ãããã®æ¹æ³ã¯ MITM æ»æãé²ãããã«éèŠã§ããæ©å¯æ å ±ãæ±ãã¢ããªã±ãŒã·ã§ã³ã«ã¯ SSL Pinning ã®å®è£ ãåŒ·ãæšå¥šããŸãã
Traffic Inspection
HTTP ãã©ãã£ãã¯ãæ€æ»ããã«ã¯ãproxy tool ã®èšŒææžãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãïŒäŸ: BurpïŒããã®èšŒææžãã€ã³ã¹ããŒã«ããªããã°ãæå·åããããã©ãã£ãã¯ã¯ãããã·äžã§å¯èŠåãããªãããšããããŸããã«ã¹ã¿ã CA èšŒææžã®ã€ã³ã¹ããŒã«æé 㯠click here ãåç §ããŠãã ããã
API Level 24 and above ãã¿ãŒã²ããã«ããŠããã¢ããªã±ãŒã·ã§ã³ã¯ãproxy ã® 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
- Open-source static-analysis utility that decompiles the APK to Smali (via apktool) and scans for curated regex patterns of SSL/TLS pinning implementations.
- Reports exact file path, line number, and a code snippet for each match.
- Covers common frameworks and custom code paths: OkHttp CertificatePinner, custom javax.net.ssl.X509TrustManager.checkServerTrusted, SSLContext.init with custom TrustManagers/KeyManagers, and Network Security Config XML pins.
Install
- åææ¡ä»¶: 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"
]
}
Notes and tips
- å€§èŠæš¡ãªã¢ããªããã«ãã¹ã¬ããã£ã³ã°ãšã¡ã¢ãªãããã I/O ã§é«éã¹ãã£ã³; äºåã³ã³ãã€ã«ããæ£èŠè¡šçŸã¯ãªãŒããŒãããïŒèª€æ€ç¥ãæžããã
- Pattern collection: https://github.com/aancw/smali-sslpin-patterns
- Typical detection targets to triage next:
- OkHttp: CertificatePinner usage, setCertificatePinner, okhttp3/okhttp package references
- Custom TrustManagers: javax.net.ssl.X509TrustManager, checkServerTrusted overrides
- Custom SSL contexts: SSLContext.getInstance + SSLContext.init with custom managers
- Declarative pins in res/xml network security config and manifest references
- Use the matched locations to plan Frida hooks, static patches, or config reviews before dynamic testing.
SSL Pinning ã®åé¿
When SSL Pinning is implemented, bypassing it becomes necessary to inspect HTTPS traffic. Various methods are available for this purpose:
- Automatically modify the apk to bypass SSLPinning with apk-mitm. The best pro of this option, is that you wonât need root to bypass the SSL Pinning, but you will need to delete the application and reinstall the new one, and this wonât always work.
- You could use Frida (discussed below) to bypass this protection. Here you have a guide to use Burp+Frida+Genymotion: https://spenkk.github.io/bugbounty/Configuring-Frida-with-Burp-and-GenyMotion-to-bypass-SSL-Pinning/
- You can also try to automatically bypass SSL Pinning using objection:
objection --gadget com.package.app explore --startup-command "android sslpinning disable" - You can also try to automatically bypass SSL Pinning using MobSF dynamic analysis (explained below)
- If you still think that there is some traffic that you arenât capturing you can try to forward the traffic to burp using iptables. Read this blog: https://infosecwriteups.com/bypass-ssl-pinning-with-ip-forwarding-iptables-568171b52b62
Looking for Common Web Vulnerabilities
Itâs important to also search for common web vulnerabilities within the application. Detailed information on identifying and mitigating these vulnerabilities is beyond the scope of this summary but is extensively covered elsewhere.
Frida
Frida is a dynamic instrumentation toolkit for developers, reverse-engineers, and security researchers.
You can access running application and hook methods on run time to change the behaviour, change values, extract values, run different codeâŠ
If you want to pentest Android applications you need to know how to use Frida.
- Learn how to use Frida: Frida tutorial
- Some âGUIâ for actions with Frida: https://github.com/m0bilesecurity/RMS-Runtime-Mobile-Security
- Ojection is great to automate the use of Frida: https://github.com/sensepost/objection , https://github.com/dpnishant/appmon
- You can find some Awesome Frida scripts here: https://codeshare.frida.re/
- Try to bypass anti-debugging / anti-frida mechanisms loading Frida as in indicated in https://erfur.github.io/blog/dev/code-injection-without-ptrace (tool linjector)
Anti-instrumentation & SSL pinning bypass workflow
Android Anti Instrumentation And Ssl Pinning Bypass
ã¡ã¢ãªãã³ã - Fridump
Check if the application is storing sensitive information inside the memory that it shouldnât be storing like passwords or mnemonics.
Using Fridump3 you can dump the memory of the app with:
# With PID
python3 fridump3.py -u <PID>
# With name
frida-ps -Uai
python3 fridump3.py -u "<Name>"
ããã¯ã¡ã¢ãªã ./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ãæ©å¯ããŒã¿ãä¿åããæè¯ã®å Žæã§ãããååãªæš©éãããã°äŸç¶ãšããŠã¢ã¯ã»ã¹å¯èœã§ããå€ãã®ã¢ããªã±ãŒã·ã§ã³ã¯ããã«æ©å¯ããŒã¿ãclear textã§ä¿åããã¡ã§ãããããpentestsã§ã¯root userãšããŠç¢ºèªããå¿ èŠããããŸããdeviceã«physical accessãæã€è ã¯ãã®ããŒã¿ãçãããšãã§ããŸãã
ããšãã¢ããªãKeystoreã«ããŒã¿ãä¿åããŠããŠãããã®ããŒã¿ã¯æå·åãããŠããã¹ãã§ãã
Keystoreå ã®ããŒã¿ã«ã¢ã¯ã»ã¹ããã«ã¯ã次ã®Fridaã¹ã¯ãªããã䜿çšã§ããŸã: 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ã¯ã¢ããªã±ãŒã·ã§ã³ã®ã¹ãããã·ã§ãããä¿åããŸãããã©ã¢ã°ã©ãŠã³ãã«åŸ©åž°ãããšããã¢ããªã®èªã¿èŸŒã¿åã«ãã®ã€ã¡ãŒãžãèªã¿èŸŒããããã¢ããªãããéãèµ·åããããã«èŠããŸãã
ãããããã®ã¹ãããã·ã§ããã«æ©å¯æ å ±ãå«ãŸããŠããå Žåãã¹ãããã·ã§ããã«ã¢ã¯ã»ã¹ã§ããè ããã®æ å ±ãçãå¯èœæ§ããããŸãïŒã¢ã¯ã»ã¹ããã«ã¯rootæš©éãå¿ èŠã§ããç¹ã«æ³šæããŠãã ããïŒã
ã¹ãããã·ã§ããã¯é垞次ã®å Žæã«ä¿åãããŸãïŒ /data/system_ce/0/snapshots
Androidã¯FLAG_SECUREãèšå®ããŠã¹ã¯ãªãŒã³ã·ã§ããã®ååŸãé²ãæ¹æ³ãæäŸããŸãããã®ãã©ã°ã䜿çšãããšããŠã£ã³ããŠã®å 容ãã»ãã¥ã¢ãšããŠæ±ãããã¹ã¯ãªãŒã³ã·ã§ããã«è¡šç€ºããããéã»ãã¥ã¢ãªãã£ã¹ãã¬ã€ã§è¡šç€ºããããããããšãé²ããŸãã
getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
Android Application Analyzer
ãã®ããŒã«ã¯ dynamic analysis äžã«è€æ°ã®ããŒã«ã管çããã®ã«åœ¹ç«ã¡ãŸã: https://github.com/NotSoSecure/android_application_analyzer
Intent Injection
Developers often create proxy components like activities, services, and broadcast receivers that handle these Intents and pass them to methods such as startActivity(...) or sendBroadcast(...), which can be risky.
å±éºãªã®ã¯ãæ»æè
ããããã® Intents ã誀èªå°ããããšã§ãéãšã¯ã¹ããŒãã®ã¢ããªã³ã³ããŒãã³ããèµ·åãããããæ©å¯æ§ã®é«ã Content-Providers ã«ã¢ã¯ã»ã¹ããããã§ããç¹ã«ãããŸããé¡èãªäŸãšããŠãWebView ã³ã³ããŒãã³ãã URL ã Intent.parseUri(...) ã䜿ã£ãŠ Intent ãªããžã§ã¯ãã«å€æãããããå®è¡ããŠããŸãããšã§ãæªæãã Intent 泚å
¥ã«ã€ãªããå¯èœæ§ããããŸãã
Essential Takeaways
- Intent Injection 㯠web ã® Open Redirect åé¡ã«é¡äŒŒããŠããŸãã
- ãšã¯ã¹ããã€ãã¯
Intentãªããžã§ã¯ãã extras ãšããŠæž¡ããããããªãã€ã¬ã¯ãããŠå®å šã§ãªãæäœãå®è¡ãããããšã䌎ããŸãã - éãšã¯ã¹ããŒãã®ã³ã³ããŒãã³ãã Content-Providers ãæ»æè ã«é²åºããå¯èœæ§ããããŸãã
WebViewã® URL ããIntentãžã®å€æã¯ãæå³ããªãåäœãåŒãèµ·ããå¯èœæ§ããããŸãã
Android Client Side Injections and others
ãããããããã®è匱æ§ã¯ Web ã§ãèŠæ £ããŠãããšæããŸããAndroid ã¢ããªã§ã¯ç¹ã«ä»¥äžã«æ³šæããŠãã ãã:
- SQL Injection: åçãªã¯ãšãªã Content-Providers ãæ±ãéã¯ãå¿ ããã©ã¡ãŒã¿åãããã¯ãšãªã䜿çšããŠãã ããã
- JavaScript Injection (XSS): JavaScript ãš Plugin ã®ãµããŒãã WebViews ã§ç¡å¹ã«ãªã£ãŠããããšã確èªããŠãã ããïŒããã©ã«ãã§ç¡å¹ïŒãMore info here.
- Local File Inclusion: WebViews ã¯ãã¡ã€ã«ã·ã¹ãã ãžã®ã¢ã¯ã»ã¹ãç¡å¹ã«ããã¹ãã§ãïŒããã©ã«ãã§ã¯æå¹ïŒ -
(webview.getSettings().setAllowFileAccess(false);). More info here. - Eternal cookies: å€ãã®å ŽåãAndroid ã¢ããªãã»ãã·ã§ã³ãçµäºããŠãã¯ãããŒãç¡å¹åãããªãã£ããããã£ã¹ã¯ã«ä¿åãããŠããŸãããšããããŸã
- Secure Flag in cookies
Automatic Analysis
MobSF
Static analysis
.png)
Vulnerability assessment of the application ã¯äœ¿ãããã web ããŒã¹ã®ããã³ããšã³ãã䜿ã£ãŠè¡ãããŸããYou can also perform dynamic analysis (but you need to prepare the environment).
docker pull opensecurity/mobile-security-framework-mobsf
docker run -it -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest
Notice that MobSF can analyse Android(apk), IOS(ipa) and Windows(apx) applications (Windows applications must be analyzed from a MobSF installed in a Windows host).
Also, if you create a ZIP file with the source code if an Android or an IOS app (go to the root folder of the application, select everything and create a ZIPfile), it will be able to analyse it also.
MobSF also allows you to diff/Compare analysis and to integrate VirusTotal (you will need to set your API key in MobSF/settings.py and enable it: VT_ENABLED = TRUE VT_API_KEY = <Your API key> VT_UPLOAD = TRUE). You can also set VT_UPLOAD to False, then the hash will be upload instead of the file.
Assisted Dynamic analysis with MobSF
MobSF can also be very helpful for dynamic analysis in Android, but in that case you will need to install MobSF and genymotion in your host (a VM or Docker wonât work). Note: You need to start first a VM in genymotion and then MobSF.
The MobSF dynamic analyser can:
- Dump application data (URLs, logs, clipboard, screenshots made by you, screenshots made by âExported Activity Testerâ, emails, SQLite databases, XML files, and other created files). All of this is done automatically except for the screenshots, you need to press when you want a screenshot or you need to press âExported Activity Testerâ to obtain screenshots of all the exported activities.
- Capture HTTPS traffic
- Use Frida to obtain runtime information
From android versions > 5, it will automatically start Frida and will set global proxy settings to capture traffic. It will only capture traffic from the tested application.
Frida
By default, it will also use some Frida Scripts to bypass SSL pinning, root detection and debugger detection and to monitor interesting APIs.
MobSF can also invoke exported activities, grab screenshots of them and save them for the report.
To start the dynamic testing press the green bottom: âStart Instrumentationâ. Press the âFrida Live Logsâ to see the logs generated by the Frida scripts and âLive API Monitorâ to see all the invocation to hooked methods, arguments passed and returned values (this will appear after pressing âStart Instrumentationâ).
MobSF also allows you to load your own Frida scripts (to send the results of your Friday scripts to MobSF use the function send()). It also has several pre-written scripts you can load (you can add more in MobSF/DynamicAnalyzer/tools/frida_scripts/others/), just select them, press âLoadâ and press âStart Instrumentationâ (you will be able to see the logs of that scripts inside âFrida Live Logsâ).
.png)
Moreover, you have some Auxiliary Frida functionalities:
- Enumerate Loaded Classes: It will print all the loaded classes
- Capture Strings: It will print all the capture strings while using the application (super noisy)
- Capture String Comparisons: Could be very useful. It will show the 2 strings being compared and if the result was True or False.
- Enumerate Class Methods: Put the class name (like âjava.io.Fileâ) and it will print all the methods of the class.
- Search Class Pattern: Search classes by pattern
- Trace Class Methods: Trace a whole class (see inputs and outputs of all methods of th class). Remember that by default MobSF traces several interesting Android Api methods.
Once you have selected the auxiliary module you want to use you need to press âStart Intrumentationâ and you will see all the outputs in âFrida Live Logsâ.
Shell
Mobsf also brings you a shell with some adb commands, MobSF commands, and common shell commands at the bottom of the dynamic analysis page. Some interesting commands:
help
shell ls
activities
exported_activities
services
receivers
HTTP tools
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
Assisted Dynamic Analysis with Inspeckage
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 ãã¡ã€ã«ãè§£æããŸããããã¯APKãå±éããäžé£ã®ã«ãŒã«ãé©çšããŠãããã®è匱æ§ãæ€åºããããšã§è¡ãããŸãã
ãã¹ãŠã®ã«ãŒã«ã¯ rules.json ãã¡ã€ã«ã«éäžããŠãããåäŒæ¥ããã¹ã¿ãŒã¯å¿
èŠã«å¿ããŠç¬èªã®ã«ãŒã«ãäœæããŠè§£æã§ããŸãã
ææ°ã®ãã€ããªã¯ download page ããããŠã³ããŒãããŠãã ããã
super-analyzer {apk_file}
StaCoAn
.png)
StaCoAnã¯ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã®static code analysisãè¡ãéçºè ãbugbounty huntersãethical hackersãæ¯æŽããã¯ãã¹ãã©ãããã©ãŒã ããŒã«ã§ãã
ã³ã³ã»ããã¯ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ãã¡ã€ã«ïŒ.apk ãŸã㯠.ipa ãã¡ã€ã«ïŒã StaCoAn ã¢ããªã«ãã©ãã°ïŒãããããããšãèŠèŠçã§æã¡éã³å¯èœãªã¬ããŒããçæãããšãããã®ã§ããèšå®ã wordlists ã調æŽããŠã«ã¹ã¿ãã€ãºããäœéšãåŸãããšãã§ããŸãã
ããŠã³ããŒã latest release:
./stacoan
AndroBugs
AndroBugs Frameworkã¯ãAndroidã¢ããªã±ãŒã·ã§ã³ã®æœåšçãªã»ãã¥ãªãã£è匱æ§ãéçºè
ã hackers ãçºèŠããã®ãæ¯æŽããè§£æã·ã¹ãã ã§ãã
Windows releases
python androbugs.py -f [APK file]
androbugs.exe -f [APK file]
Androwarn
Androwarn ã¯ãAndroidã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠåŒãèµ·ããããå¯èœæ§ã®ããæªæã®ããæ¯ãèããæ€åºãããŠãŒã¶ãŒã«èŠåããããšãäž»ç®çãšããããŒã«ã§ãã
æ€åºã¯ãã¢ããªã±ãŒã·ã§ã³ã® Dalvik ãã€ãã³ãŒãïŒSmali ã§è¡šçŸïŒã«å¯Ÿãã static analysis ã androguard ã©ã€ãã©ãªãçšããŠè¡ããŸãã
ãã®ããŒã«ã¯ããæªæã®ããã¢ããªã«å ±éããæ¯ãèãã ãæ€åºããŸããäŸ: 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 㯠Mobile Application Reverse engineering and Analysis Framework ã§ããäžè¬çã«äœ¿ãããã¢ãã€ã«ã¢ããªã®ãªããŒã¹ãšã³ãžãã¢ãªã³ã°ããã³è§£æããŒã«ããŸãšããŠãOWASP ã® mobile security è åšã«å¯Ÿããã¢ãã€ã«ã¢ããªã®ãã¹ããæ¯æŽããããã®ããŒã«ã§ããç®çã¯ããã®äœæ¥ãã¢ãã€ã«ã¢ããªéçºè ãã»ãã¥ãªãã£å°éå®¶ã«ãšã£ãŠããç°¡åã§æ±ããããããããšã§ãã
ã§ããããšïŒ
- ããŸããŸãªããŒã«ã䜿ã£ãŠ Java ãš Smali ã®ã³ãŒããæœåºãã
- 以äžã䜿çšã㊠APK ãè§£æãã: smalisca, ClassyShark, androbugs, androwarn, APKiD
- æ£èŠè¡šçŸã䜿çšã㊠APK ãããã©ã€ããŒãæ å ±ãæœåºãã
- Manifest ãè§£æãã
- çºèŠãããã¡ã€ã³ã以äžã§è§£æãã: pyssltest, testssl and whatweb
- apk-deguard.com çµç±ã§ APK ã®éé£èªåãè¡ã
Koodous
ãã«ãŠã§ã¢æ€åºã«æçš: https://koodous.com/
Obfuscating/Deobfuscating code
ã³ãŒããé£èªåãããµãŒãã¹ãèšå®ã«ãã£ãŠãã·ãŒã¯ã¬ãããé£èªåãããå Žåãšãããªãå Žåãããç¹ã«æ³šæããŠãã ããã
ProGuard
From Wikipedia: ProGuard 㯠Java ã³ãŒããçž®å°ãæé©åãé£èªåãããªãŒãã³ãœãŒã¹ã®ã³ãã³ãã©ã€ã³ããŒã«ã§ãããã€ãã³ãŒãã®æé©åãæªäœ¿çšåœä»€ã®æ€åºã»åé€ãå¯èœã§ããProGuard ã¯ããªãŒãœãããŠã§ã¢ã§ãGNU General Public License version 2 ã®äžã§é åžãããŠããŸãã
ProGuard 㯠Android SDK ã®äžéšãšããŠé åžãããã¢ããªããªãªãŒã¹ã¢ãŒãã§ãã«ãããéã«å®è¡ãããŸãã
DexGuard
APK ãéé£èªåããã¹ããããã€ã¹ãããã®ã¬ã€ã㯠https://blog.lexfo.fr/dexguard.html ã«ãããŸãã
ïŒãã®ã¬ã€ãããïŒæçµç¢ºèªæç¹ã§ã® Dexguard ã®åäœã¯æ¬¡ã®ãšããã§ãã:
- ãªãœãŒã¹ã InputStream ãšããŠèªã¿èŸŒã;
- FilterInputStream ãç¶æ¿ããã¯ã©ã¹ã«çµæãæž¡ããŠåŸ©å·ãã;
- ãªããŒã¹ãšã³ãžãã¢ã®æéãæµªè²»ããããã«ããã€ãã®ç¡æå³ãªé£èªåãè¡ã;
- 埩å·ããçµæã ZipInputStream ã«æž¡ã㊠DEX ãã¡ã€ã«ãååŸãã;
- æåŸã«ã
loadDexã¡ãœããã䜿ã£ãŠçæããã DEX ã Resource ãšããŠããŒãããã
DeGuard
DeGuard 㯠Android ã®é£èªåããŒã«ã«ãã£ãŠè¡ãããé£èªåããã»ã¹ãé転ããŸããããã«ããã³ãŒãæ€æ»ãã©ã€ãã©ãªã®äºæž¬ãªã©ã倿°ã®ã»ãã¥ãªãã£è§£æãå¯èœã«ãªããŸãã
é£èªåããã APK ããã©ãããã©ãŒã ã«ã¢ããããŒãã§ããŸãã
[Deobfuscate android App]https://github.com/In3tinct/deobfuscate-android-app
ãã㯠Android ã¢ããªå ã®æœåšçãªã»ãã¥ãªãã£è匱æ§ãèŠã€ããAndroid ã¢ããªã®ã³ãŒããéé£èªåããããã® LLM ããŒã«ã§ããGoogle ã® Gemini public API ã䜿çšããŸãã
Simplify
ããã¯æ±çšã® Android éé£èªåããŒã«ã§ããSimplify ã¯ã¢ããªãäºå®äžå®è¡ããŠãã®æ¯ãèããçè§£ãããã®åŸã³ãŒããæé©åããŠãåäžã®æ¯ãèããç¶æãã€ã€äººéã«ãšã£ãŠçè§£ããããããããšããŸããåæé©åã¿ã€ãã¯åçŽãã€æ±çšçã§ãããããå ·äœçã«ã©ã®ã¿ã€ãã®é£èªåã䜿ãããŠãããã¯åé¡ã«ãªããŸããã
APKiD
APKiD 㯠APK ãã©ã®ããã«äœããããã®æ å ±ãæäŸããŸããå€ãã®ã³ã³ãã€ã©ãããã«ãŒããªããuscatorïŒé£èªåããŒã«ïŒããã®ä»ã®æªãããªãã®ãèå¥ããŸããAndroid çšã® PEiD ã®ãããªããŒã«ã§ãã
Manual
Read this tutorial to learn some tricks on how to reverse custom obfuscation
Labs
Androl4b
AndroL4b 㯠ubuntu-mate ããŒã¹ã® Android ã»ãã¥ãªãã£ä»®æ³ãã·ã³ã§ããªããŒã¹ãšã³ãžãã¢ãªã³ã°ããã«ãŠã§ã¢è§£æã®ããã®ææ°ãã¬ãŒã ã¯ãŒã¯ããã¥ãŒããªã¢ã«ãã©ããããŸããŸãªã»ãã¥ãªãã£ç ç©¶è ãæå¥œå®¶ããåéããŠããŸãã
References
- Play Integrity API: How It Works & How to Bypass It
- https://owasp.org/www-project-mobile-app-security/
- https://appsecwiki.com/#/ çŽ æŽããããªãœãŒã¹ã®äžèЧã§ã
- https://maddiestone.github.io/AndroidAppRE/ Android ã®ã¯ã€ãã¯ã³ãŒã¹
- 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ããµããŒããã
- ãµãã¹ã¯ãªãã·ã§ã³ãã©ã³ã確èªããŠãã ããïŒ
- **ð¬ Discordã°ã«ãŒããŸãã¯ãã¬ã°ã©ã ã°ã«ãŒãã«åå ããããTwitter ðŠ @hacktricks_liveããã©ããŒããŠãã ããã
- HackTricksããã³HackTricks Cloudã®GitHubãªããžããªã«PRãæåºããŠãããã³ã°ããªãã¯ãå ±æããŠãã ããã


