Android Anti-Instrumentation & SSL Pinning Bypass (Frida/Objection)
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Azure Hacking’i öğrenin ve pratik yapın:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- abonelik planlarını kontrol edin!
- 💬 Discord grubuna veya telegram grubuna katılın ya da Twitter’da bizi takip edin 🐦 @hacktricks_live.**
- Hacking ipuçlarını paylaşmak için HackTricks ve HackTricks Cloud github reposuna PR gönderin.
Bu sayfa, enstrümantasyonu tespit eden/kök‑engelleme yapan veya TLS pinning uygulayan Android uygulamalarına karşı dinamik analizi geri kazanmak için pratik bir iş akışı sağlar. Hızlı triage, yaygın tespitler ve mümkün olduğunda repacking yapmadan atlatmaya yönelik kopyala‑yapıştır yapılabilir hook’lar/taktikler üzerine odaklanır.
Detection Surface (what apps check)
- Root checks: su binary, Magisk paths, getprop values, common root packages
- Frida/debugger checks (Java): Debug.isDebuggerConnected(), ActivityManager.getRunningAppProcesses(), getRunningServices(), scanning /proc, classpath, loaded libs
- Native anti‑debug: ptrace(), syscalls, anti‑attach, breakpoints, inline hooks
- Early init checks: Application.onCreate() or process start hooks that crash if instrumentation is present
- TLS pinning: custom TrustManager/HostnameVerifier, OkHttp CertificatePinner, Conscrypt pinning, native pins
Step 1 — Quick win: hide root with Magisk DenyList
- Enable Zygisk in Magisk
- Enable DenyList, add the target package
- Reboot and retest
Many apps only look for obvious indicators (su/Magisk paths/getprop). DenyList often neutralizes naive checks.
References:
- Magisk (Zygisk & DenyList): https://github.com/topjohnwu/Magisk
Step 2 — 30‑second Frida Codeshare tests
Derinlemesine dalmadan önce yaygın drop‑in script’leri dene:
- anti-root-bypass.js
- anti-frida-detection.js
- hide_frida_gum.js
Example:
frida -U -f com.example.app -l anti-frida-detection.js
Bunlar genellikle Java root/debug kontrollerini, process/service taramalarını ve native ptrace() çağrılarını stub’lar. Hafifçe korunan uygulamalarda işe yarar; sertleştirilmiş hedefler özel hook’lar gerektirebilir.
- Codeshare: https://codeshare.frida.re/
Medusa ile Otomasyon (Frida framework)
Medusa, SSL unpinning, root/emulator detection bypass, HTTP comms logging, crypto key interception ve daha fazlası için 90’dan fazla hazır modül sağlar.
git clone https://github.com/Ch0pin/medusa
cd medusa
pip install -r requirements.txt
python medusa.py
# Example interactive workflow
show categories
use http_communications/multiple_unpinner
use root_detection/universal_root_detection_bypass
run com.target.app
İpucu: Medusa, custom hooks yazmadan önce hızlı sonuçlar elde etmek için harikadır. Ayrıca cherry-pick modules yapabilir ve bunları kendi scripts’inizle birleştirebilirsiniz.
Step 3 — Başlatma zamanı dedektörlerini geç bağlanarak atlatma
Birçok tespit yalnızca process spawn/onCreate() sırasında çalışır. Spawn‑time injection (-f) veya gadgets yakalanır; UI yüklendikten sonra bağlanmak bunların arasından sıyrılabilir.
# Launch the app normally (launcher/adb), wait for UI, then attach
frida -U -n com.example.app
# Or with Objection to attach to running process
aobjection --gadget com.example.app explore # if using gadget
Bu işe yararsa, oturumu stabil tutun ve map ve stub kontrollerine devam edin.
Adım 4 — Tespit mantığını Jadx ile haritalayın ve string hunting yapın
Jadx’te statik triage anahtar kelimeleri:
- “frida”, “gum”, “root”, “magisk”, “ptrace”, “su”, “getprop”, “debugger”
Tipik Java kalıpları:
public boolean isFridaDetected() {
return getRunningServices().contains("frida");
}
Gözden geçirilecek/hook yapılacak yaygın API’ler:
- android.os.Debug.isDebuggerConnected
- android.app.ActivityManager.getRunningAppProcesses / getRunningServices
- java.lang.System.loadLibrary / System.load (native bridge)
- java.lang.Runtime.exec / ProcessBuilder (probing commands)
- android.os.SystemProperties.get (root/emulator heuristics)
Adım 5 — Frida (Java) ile çalışma zamanı stub oluşturma
Özel guard’ları yeniden yazarak yeniden paketleme yapmadan güvenli değerler döndürün:
Java.perform(() => {
const Checks = Java.use('com.example.security.Checks');
Checks.isFridaDetected.implementation = function () { return false; };
// Neutralize debugger checks
const Debug = Java.use('android.os.Debug');
Debug.isDebuggerConnected.implementation = function () { return false; };
// Example: kill ActivityManager scans
const AM = Java.use('android.app.ActivityManager');
AM.getRunningAppProcesses.implementation = function () { return java.util.Collections.emptyList(); };
});
Erken çökme analizi mi yapıyorsun? Uygulama kapanmadan hemen önce dump classes yaparak muhtemel detection namespaces’i tespit et:
Java.perform(() => {
Java.enumerateLoadedClasses({
onMatch: n => console.log(n),
onComplete: () => console.log('Done')
});
});
// Quick root detection stub example (adapt to target package/class names)
Java.perform(() => {
try {
const RootChecker = Java.use('com.target.security.RootCheck');
RootChecker.isDeviceRooted.implementation = function () { return false; };
} catch (e) {}
});
Yürütme akışını doğrulamak için şüpheli yöntemleri kaydedin ve etkisiz hale getirin:
Java.perform(() => {
const Det = Java.use('com.example.security.DetectionManager');
Det.checkFrida.implementation = function () {
console.log('checkFrida() called');
return false;
};
});
Bypass emulator/VM detection (Java stubs)
Yaygın heuristikler: Build.FINGERPRINT/MODEL/MANUFACTURER/HARDWARE alanlarının generic/goldfish/ranchu/sdk içermesi; QEMU artefaktları (ör. /dev/qemu_pipe, /dev/socket/qemud); varsayılan MAC 02:00:00:00:00:00; 10.0.2.x NAT; telephony/sensors eksikliği.
Build alanları için hızlı spoof:
Java.perform(function(){
var Build = Java.use('android.os.Build');
Build.MODEL.value = 'Pixel 7 Pro';
Build.MANUFACTURER.value = 'Google';
Build.BRAND.value = 'google';
Build.FINGERPRINT.value = 'google/panther/panther:14/UP1A.231105.003/1234567:user/release-keys';
});
Dosya varlığı kontrolleri ve tanımlayıcılar (TelephonyManager.getDeviceId/SubscriberId, WifiInfo.getMacAddress, SensorManager.getSensorList) için gerçekçi değerler döndürecek stub’larla tamamlayın.
SSL pinning bypass quick hook (Java)
Özel TrustManagers’ları etkisiz hale getir ve permissive SSL contexts kullanmaya zorla:
Java.perform(function(){
var X509TrustManager = Java.use('javax.net.ssl.X509TrustManager');
var SSLContext = Java.use('javax.net.ssl.SSLContext');
// No-op validations
X509TrustManager.checkClientTrusted.implementation = function(){ };
X509TrustManager.checkServerTrusted.implementation = function(){ };
// Force permissive TrustManagers
var TrustManagers = [ X509TrustManager.$new() ];
var SSLContextInit = SSLContext.init.overload('[Ljavax.net.ssl.KeyManager;','[Ljavax.net.ssl.TrustManager;','java.security.SecureRandom');
SSLContextInit.implementation = function(km, tm, sr){
return SSLContextInit.call(this, km, TrustManagers, sr);
};
});
Notlar
- OkHttp için: gerektiğinde okhttp3.CertificatePinner ve HostnameVerifier’ı hook edin veya CodeShare’den evrensel bir unpinning script’i kullanın.
- Örnek çalıştırma:
frida -U -f com.target.app -l ssl-bypass.js --no-pause
Adım 6 — Java hooks başarısız olduğunda JNI/native izini takip edin
JNI giriş noktalarını izleyerek native loader’ları ve detection init’i bulun:
frida-trace -n com.example.app -i "JNI_OnLoad"
Paketlenmiş .so dosyaları için hızlı native triage:
# List exported symbols & JNI
nm -D libfoo.so | head
objdump -T libfoo.so | grep Java_
strings -n 6 libfoo.so | egrep -i 'frida|ptrace|gum|magisk|su|root'
Interactive/native reversing:
- Ghidra: https://ghidra-sre.org/
- r2frida: https://github.com/nowsecure/r2frida
Örnek: neuter ptrace to defeat simple anti‑debug in libc:
const ptrace = Module.findExportByName(null, 'ptrace');
if (ptrace) {
Interceptor.replace(ptrace, new NativeCallback(function () {
return -1; // pretend failure
}, 'int', ['int', 'int', 'pointer', 'pointer']));
}
Ayrıca bakınız: Reversing Native Libraries
Adım 7 — Objection patching (embed gadget / strip basics)
Repacking’i runtime hooks yerine tercih ediyorsanız, şunu deneyin:
objection patchapk --source app.apk
Notes:
- Requires apktool; ensure a current version from the official guide to avoid build issues: https://apktool.org/docs/install
- Gadget injection enables instrumentation without root but can still be caught by stronger init‑time checks.
Optionally, add LSPosed modules and Shamiko for stronger root hiding in Zygisk environments, and curate DenyList to cover child processes.
For a complete workflow including script-mode Gadget configuration and bundling your Frida 17+ agent into the APK, see:
Frida Tutorial — Self-contained agent + Gadget embedding
References:
- Objection: https://github.com/sensepost/objection
Adım 8 — Yedek: Ağ görünürlüğü için TLS pinning’i yama
Eğer instrumentation engellenmişse, pinning’i statik olarak kaldırarak trafiği yine de inceleyebilirsiniz:
apk-mitm app.apk
# Then install the patched APK and proxy via Burp/mitmproxy
- Araç: https://github.com/shroudedcode/apk-mitm
- Ağ yapılandırması CA‑trust hileleri (ve Android 7+ kullanıcı CA güveni) için bakınız:
Make APK Accept CA Certificate
Kullanışlı komut hile‑sayfası
# List processes and attach
frida-ps -Uai
frida -U -n com.example.app
# Spawn with a script (may trigger detectors)
frida -U -f com.example.app -l anti-frida-detection.js
# Trace native init
frida-trace -n com.example.app -i "JNI_OnLoad"
# Objection runtime
objection --gadget com.example.app explore
# Static TLS pinning removal
apk-mitm app.apk
Universal proxy forcing + TLS unpinning (HTTP Toolkit Frida hooks)
Güncel uygulamalar sıklıkla system proxies’i görmezden gelir ve birden fazla pinning katmanı uygular (Java + native), bu da user/system CAs yüklü olsa bile trafiği yakalamayı zorlaştırır. Pratik bir yaklaşım, universal TLS unpinning ile proxy forcing’i hazır Frida hooks aracılığıyla birleştirmek ve her şeyi mitmproxy/Burp üzerinden yönlendirmektir.
Workflow
- Run mitmproxy on your host (or Burp). Ensure the device can reach the host IP/port.
- Load HTTP Toolkit’s consolidated Frida hooks to both unpin TLS and force proxy usage across common stacks (OkHttp/OkHttp3, HttpsURLConnection, Conscrypt, WebView, etc.). This bypasses CertificatePinner/TrustManager checks and overrides proxy selectors, so traffic is always sent via your proxy even if the app explicitly disables proxies.
- Start the target app with Frida and the hook script, and capture requests in mitmproxy.
Example
# Device connected via ADB or over network (-U)
# See the repo for the exact script names & options
frida -U -f com.vendor.app \
-l ./android-unpinning-with-proxy.js \
--no-pause
# mitmproxy listening locally
mitmproxy -p 8080
Notlar
- Mümkünse sistem genelinde bir proxy ile birleştirin:
adb shell settings put global http_proxy <host>:<port>. Frida hook’ları, uygulamalar global ayarları atlatmış olsalar bile proxy kullanımını zorlayacaktır. - Bu teknik, pinning/proxy kaçınmasının yaygın olduğu mobil’den IoT’e onboarding akışlarında MITM gerektiğinde idealdir.
- Hook’lar: https://github.com/httptoolkit/frida-interception-and-unpinning
Referanslar
- Reversing Android Apps: Bypassing Detection Like a Pro
- Frida Codeshare
- Objection
- apk-mitm
- Jadx
- Ghidra
- r2frida
- Apktool install guide
- Magisk
- Medusa (Android Frida framework)
- Build a Repeatable Android Bug Bounty Lab: Emulator vs Magisk, Burp, Frida, and Medusa
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Azure Hacking’i öğrenin ve pratik yapın:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- abonelik planlarını kontrol edin!
- 💬 Discord grubuna veya telegram grubuna katılın ya da Twitter’da bizi takip edin 🐦 @hacktricks_live.**
- Hacking ipuçlarını paylaşmak için HackTricks ve HackTricks Cloud github reposuna PR gönderin.
HackTricks

