β οΈ DISCLAIMER: This repository is strictly for educational and authorized security research. Only test on devices and accounts you own. Unauthorized interception of traffic is illegal.
|
π SSL/TLS Pinning Theory & Implementation |
π οΈ Frida & Objection Dynamic Instrumentation |
π΅οΈ Traffic Interception mitmproxy & Burp Suite |
π§ Advanced Hooks Custom Frida Scripts |
βοΈ Ethics & Law Responsible Research |
- π Quick Start
- π Lesson Plan
- π Repository Structure
- π§ Scripts Reference
- π‘ How SSL Pinning Works
- π§ͺ Lab Setup
β οΈ Legal & Ethics- π€ Contributing
- β Support This Project
Step 1 β Clone the repository
git clone https://github.com/algoanhaf/facebook-ssl-pinning-bypass.git
cd facebook-ssl-pinning-bypassStep 2 β Run the automated setup (creates the virtual environment, installs every tool, and pushes a matching frida-server)
./setup.sh
source ssl-lab/bin/activateStep 3 β Start frida-server on your device
adb shell su -c "/data/local/tmp/frida-server &"Step 4 β Run the bypass
python run.py com.facebook.katana --script allThat's it. Open the app, log in, and watch the traffic in mitmproxy. Full detail lives in Lesson 3.
| Lesson | Topic | What You Learn | Level |
|---|---|---|---|
| 01 | π οΈ Environment Setup | ADB, Python, Frida, Objection, mitmproxy, Android emulator configuration | π’ Beginner |
| 02 | π SSL/TLS Concepts | Certificate vs public key pinning, how Facebook implements it, why proxies fail | π‘ Intermediate |
| 03 | π¬ Tool Walkthrough | Objection one-liner, raw Frida scripting, mitmproxy traffic inspection | π‘ Intermediate |
| 04 | π§ Advanced Techniques | Writing custom hooks, CT bypass, anti-Frida detection, APK patching concepts | π΄ Advanced |
| 05 | βοΈ Ethics & Legal | Legal boundaries, lab rules, responsible disclosure, bug bounty programs | π’ All Levels |
π facebook-ssl-pinning-bypass/
β
βββ π lessons/
β βββ π 01_setup.md β Environment setup (ADB, Frida, emulator)
β βββ π 02_concepts.md β SSL/TLS pinning theory
β βββ π 03_walkthrough.md β Step-by-step bypass walkthrough
β βββ π 04_advanced.md β Advanced hooking techniques
β βββ π 05_ethics.md β Ethics, law & responsible disclosure
β
βββ π scripts/
β βββ π ssl_bypass_all.js β β
Start here β comprehensive bypass
β βββ π ssl_bypass_basic.js β Hook Android TrustManager
β βββ π ssl_bypass_okhttp.js β Hook OkHttp3 CertificatePinner
β
βββ π .github/ β Issue & PR templates
βββ π run.py β Spawns the app and injects a script
βββ βοΈ setup.sh β One-command lab bootstrap
βββ π requirements.txt β Pinned Python dependencies
βββ π SECURITY.md β Responsible disclosure policy
βββ π€ CONTRIBUTING.md β Contribution guidelines
βββ π README.md
βββ π LICENSE
π ssl_bypass_all.js β Recommended starting script
The comprehensive bypass script. Hooks all major pinning layers:
| Hook | Target | What It Does |
|---|---|---|
| 1 | javax.net.ssl.SSLContext.init() |
Replaces TrustManager with permissive version |
| 2 | HttpsURLConnection.setDefaultHostnameVerifier() |
Accepts all hostnames |
| 3 | okhttp3.CertificatePinner.check() |
Bypasses OkHttp3 pin check |
| 4 | com.squareup.okhttp.CertificatePinner |
Bypasses OkHttp2 pin check |
| 5 | NetworkSecurityTrustManager.checkPins() |
Bypasses Android 7+ NSC pins |
| 6 | Conscrypt TrustManagerImpl |
Bypasses deep SSL provider check |
| 7 | Dynamic class enumeration | Auto-discovers anonymous TrustManager classes |
python run.py com.facebook.katana --script allπ ssl_bypass_basic.js β TrustManager hooks
Targets the standard Java SSL stack. Good for apps that don't use OkHttp.
python run.py <package_name> --script basicπ ssl_bypass_okhttp.js β OkHttp-specific hooks
Targets OkHttp2 and OkHttp3 CertificatePinner plus Conscrypt internals.
python run.py <package_name> --script okhttpWithout Pinning: With Pinning (Facebook):
ββββββββββββ ββββββββββββ
β App β β App β
β β β β
β β
Is certβ β β
Is certβ β CA validation (same)
β signed β β signed β
β by a β β by a β
β trusted β β trusted β
β CA? β β CA? β
β β β β
β β
YES β β β
YES β
β β ALLOW β β β
ββββββββββββ β π Does β β Pin check (extra step)
β public β
β key hash β
β match? β
β β
β β NO β β Burp/mitmproxy cert fails here
β β BLOCK β
ββββββββββββ
Facebook uses 3 pinning layers:
- OkHttp3 CertificatePinner β primary, checks SHA-256 of public key
- Custom X509TrustManager β secondary validation layer
- Network Security Config β OS-level pins (Android 7+)
[ ] Rooted Android device or emulator (Genymotion / AVD "Google APIs" image)
[ ] Android 9.0 β 12.0 recommended (less aggressive anti-tampering)
[ ] ADB installed and device recognized (adb devices)
[ ] frida-server pushed to /data/local/tmp/ and running
[ ] mitmproxy CA installed in SYSTEM certificate store (not just user store)
[ ] Python 3.8+ with frida==16.5.9, frida-tools, objection, mitmproxy
[ ] Dummy Facebook account (NEVER use your real account)
adb devices
frida-ps -U | grep facebook
frida --version
objection --version
mitmproxy --versionadb devices shows your device, frida-ps -U confirms the client reaches the server, and frida --version must match the frida-server version on the device.
| Problem | Solution |
|---|---|
Unable to connect to frida-server |
adb shell su -c "/data/local/tmp/frida-server &" |
| App crashes after hook | Use -f (spawn) mode, not -n (attach) |
| No traffic in mitmproxy | Re-check proxy IP: adb shell settings get global http_proxy |
| Frida version mismatch | Re-download frida-server to match pip show frida version |
| mitmproxy CA not trusted | Push cert to /system/etc/security/cacerts/ (needs root) |
| β Legal | β Illegal |
|---|---|
|
Testing on your own device + dummy account Intercepting your own traffic in a private lab Reporting vulnerabilities via bug bounty Security research on apps you developed |
Intercepting someone else's traffic Targeting accounts you don't own Distributing patched APKs Scraping user data without authorization |
Three Lab Rules β confirm all before every session:
- π± The device is yours
- π€ The account is yours (dummy account)
- π The network is yours (isolated lab network)
Found a real vulnerability? Report it responsibly:
- π Meta Bug Bounty: hackerone.com/facebook
- π§ Facebook WhiteHat: facebook.com/whitehat
Contributions are welcome! Here's how:
Step 1 β Fork, then clone your fork
git clone https://github.com/<your-username>/facebook-ssl-pinning-bypass.gitStep 2 β Create a feature branch
git checkout -b feature/your-feature-nameStep 3 β Commit your changes
git commit -m "Add: description of your changes"Step 4 β Push and open a Pull Request
git push origin feature/your-feature-nameIdeas for contributions:
- π Add Frida scripts for other pinning implementations
- π Translate lessons to other languages
- π Fix issues or improve explanations
- πΈ Add screenshots / demo GIFs
Please read CONTRIBUTING.md before submitting.
BEGINNER βββββββββββββββββββββββββββββββββββββββΊ ADVANCED
[Lesson 1] [Lesson 2] [Lesson 3] [Lesson 4] [Lesson 5]
β β β β β
Setup & SSL/TLS Objection & Write your Ethics &
Tools Theory Frida Lab own hooks Law
β β β β β
30m 45m 60m 90m 20m
Total estimated time: ~4 hours for a complete first run
If this repository helped your learning journey:
MIT License β Copyright (c) 2026 HADI ANHAF AIMAN
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files, to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software,
subject to the conditions in the LICENSE file.
FOR EDUCATIONAL PURPOSES ONLY.