Flutter

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 지원하기

Flutter는 개발자가 단일 Dart 코드베이스를 작성하면 Engine(네이티브 C/C++)이 이를 Android 및 iOS용 플랫폼별 머신 코드로 변환해주는 Google의 크로스-플랫폼 UI 툴킷입니다. Engine은 Dart VM, BoringSSL, Skia 등을 번들로 포함하며 libflutter.so(Android) 또는 Flutter.framework(iOS) 같은 공유 라이브러리로 배포됩니다. 실제 네트워킹(DNS, sockets, TLS)은 모두 이 라이브러리 내부에서 발생하며, 일반적인 Java/Kotlin Swift/Obj-C 레이어에서는 이루어지지 않습니다. 이러한 분리된 설계 때문에 일반적인 Java 수준의 Frida 훅이 Flutter 앱에서는 실패합니다.

Intercepting HTTPS traffic in Flutter

This is a summary of this blog post.

Why HTTPS interception is tricky in Flutter

  • SSL/TLS verification lives two layers down in BoringSSL, so Java SSL‐pinning bypasses don’t touch it.
  • BoringSSL uses its own CA store inside libflutter.so; importing your Burp/ZAP CA into Android’s system store changes nothing.
  • Symbols in libflutter.so are stripped & mangled, hiding the certificate-verification function from dynamic tools.

Fingerprint the exact Flutter stack

버전을 알면 올바른 바이너리를 재빌드하거나 패턴 매칭할 수 있습니다.

StepCommand / FileOutcome
Get snapshot hashpython3 get_snapshot_hash.py libapp.soadb4292f3ec25…
Map hash → Engineenginehash list in reFlutterFlutter 3 · 7 · 12 + engine commit 1a65d409…
Pull dependent commitsDEPS file in that engine commitdart_revision → Dart v2 · 19 · 6
dart_boringssl_rev → BoringSSL 87f316d7…

Find get_snapshot_hash.py here.

Target: ssl_crypto_x509_session_verify_cert_chain()

  • Located in ssl_x509.cc inside BoringSSL.
  • Returns bool – a single true is enough to bypass the whole certificate chain check.
  • Same function exists on every CPU arch; only the opcodes differ.

Option A – Binary patching with reFlutter

  1. Clone the exact Engine & Dart sources for the app’s Flutter version.
  2. Regex-patch two hotspots:
  • In ssl_x509.cc, force return 1;
  • (Optional) In socket_android.cc, hard-code a proxy ("10.0.2.2:8080").
  1. Re-compile libflutter.so, drop it back into the APK/IPA, sign, install.
  2. Pre-patched builds for common versions are shipped in the reFlutter GitHub releases to save hours of build time.

### Option B – Live hooking with Frida (the “hard-core” path) 심볼이 제거되어 있기 때문에 로드된 모듈에서 첫 바이트들을 패턴 스캔한 다음, 런타임에 반환값을 변경합니다.

// attach & locate libflutter.so
var flutter = Process.getModuleByName("libflutter.so");

// x86-64 pattern of the first 16 bytes of ssl_crypto_x509_session_verify_cert_chain
var sig = "55 41 57 41 56 41 55 41 54 53 48 83 EC 38 C6 02";

Memory.scan(flutter.base, flutter.size, sig, {
onMatch: function (addr) {
console.log("[+] found verifier at " + addr);
Interceptor.attach(addr, {
onLeave: function (retval) { retval.replace(0x1); }  // always 'true'
});
},
onComplete: function () { console.log("scan done"); }
});

I don’t have the file contents. Please paste the Markdown from src/mobile-pentesting/android-app-pentesting/flutter.md (or attach it) and I will translate the English text to Korean following the rules you gave.

frida -U -f com.example.app -l bypass.js

포팅 팁

  • arm64-v8a 또는 armv7의 경우, Ghidra에서 함수의 처음 약 32바이트를 가져와 공백으로 구분된 16진수 문자열로 변환한 후 sig를 교체하세요.
  • Flutter 릴리스당 패턴 하나를 유지하고, 빠른 재사용을 위해 치트시트에 저장하세요.

트래픽을 proxy로 강제 전송

Flutter 자체는 device proxy settings을 무시합니다. 가장 쉬운 옵션:

  • Android Studio emulator: Settings ▶ Proxy → manual.
  • Physical device: evil Wi-Fi AP + DNS spoofing, or Magisk module editing /etc/hosts.

빠른 Flutter TLS bypass 워크플로우 (Frida Codeshare + system CA)

핀된 Flutter API만 관찰하면 될 때, rooted/writable AVD, system-trusted proxy CA, 그리고 drop-in Frida script를 결합하는 것이 libflutter.so를 리버스엔지니어링하는 것보다 종종 빠릅니다:

  1. 시스템 스토어에 proxy CA를 설치하세요. Follow Install Burp Certificate to hash/rename Burp’s DER certificate and push it into /system/etc/security/cacerts/ (writable /system required).

  2. 일치하는 frida-server 바이너리를 배치하고 root로 실행하세요 so it can attach to the Flutter process:

adb push frida-server-17.0.5-android-x86_64 /data/local/tmp/frida-server
adb shell "su -c 'chmod 755 /data/local/tmp/frida-server && /data/local/tmp/frida-server &'"
  1. 호스트 측 도구를 설치하고 대상 패키지를 열거합니다.
pip3 install frida-tools --break-system-packages
adb shell pm list packages -f | grep target
  1. Flutter 앱을 Codeshare hook으로 실행해 BoringSSL pin checks를 무력화한다.
frida -U -f com.example.target --codeshare TheDauntless/disable-flutter-tls-v1 --no-pause

The Codeshare script overrides the Flutter TLS verifier so every certificate (including Burp’s dynamically generated ones) is accepted, side-stepping public-key pin comparisons.

  1. 프록시를 통해 트래픽을 라우팅하세요. 에뮬레이터 Wi-Fi 프록시 GUI를 구성하거나 adb shell settings put global http_proxy 10.0.2.2:8080로 강제 설정하세요; 직접 라우팅이 실패하면 adb reverse tcp:8080 tcp:8080 또는 호스트 전용 VPN으로 대체하세요.

  2. 앱이 OS 프록시 설정을 무시하면 Frida shim으로 소켓을 리다이렉트하세요. 도구들(예: frida4burp)은 dart:io/BoringSSL 소켓 생성에 훅을 걸어, 하드코딩된 HttpClient.findProxyFromEnvironment나 Wi‑Fi 우회가 있어도 아웃바운드 TCP 세션을 프록시로 강제합니다. 스크립트에 프록시 호스트/포트를 설정하고 TLS 우회와 함께 실행하세요:

frida -U -f com.example.target --no-pause \
--codeshare TheDauntless/disable-flutter-tls-v1 \
-l frida4burp.js

Works on iOS via a Frida gadget or USB frida-server; socket redirect와 TLS bypass를 연계하면 Burp/mitmproxy에 대한 라우팅과 인증서 수락이 모두 복원됩니다.

Once the CA is trusted at the OS layer and Frida quashes Flutter’s pinning logic (plus socket redirection if needed), Burp/mitmproxy regains full visibility for API fuzzing (BOLA, token tampering, etc.) without repacking the APK.

Offset 기반 훅 — BoringSSL 검증 (no signature scan)

패턴 기반 스크립트가 아키텍처 간(e.g., x86_64 vs ARM)에서 실패할 때, libflutter.so 내 절대 주소로 BoringSSL 체인 검증기를 직접 훅하세요. 작업 흐름:

  • Extract the right-ABI library from the APK: unzip -j app.apk "lib/*/libflutter.so" -d libs/ and pick the one matching the device (e.g., lib/x86_64/libflutter.so).
  • Ghidra/IDA에서 분석하고 검증기를 찾으세요:
  • Source: BoringSSL ssl_x509.cc function ssl_crypto_x509_session_verify_cert_chain (3 args, returns bool).
  • In stripped builds, use Search → For Strings → ssl_client → XREFs, then open each referenced FUN_... and pick the one with 3 pointer-like args and a boolean return.
  • Compute the runtime offset: take the function address shown by Ghidra and subtract the image base (e.g., Ghidra often shows 0x00100000 for PIE Android ELFs). Example: 0x02184644 - 0x00100000 = 0x02084644.
  • Hook at runtime by base + offset and force success:
// frida -U -f com.target.app -l bypass.js --no-pause
const base = Module.findBaseAddress('libflutter.so');
// Example offset from analysis. Recompute per build/arch.
const off  = ptr('0x02084644');
const addr = base.add(off);

// ssl_crypto_x509_session_verify_cert_chain: 3 args, bool return
Interceptor.replace(addr, new NativeCallback(function (a, b, c) {
return 1; // true
}, 'int', ['pointer', 'pointer', 'pointer']));

console.log('[+] Hooked BoringSSL verify_cert_chain at', addr);

참고

  • Signature scans은 ARM에서는 성공할 수 있지만 opcode 레이아웃이 변경되면 x86_64에서는 놓칠 수 있습니다; 이 오프셋 방법은 RVA를 다시 계산하는 한 아키텍처에 무관합니다.
  • 이 바이패스는 BoringSSL이 모든 체인을 수락하게 하여 Flutter 내부의 pins/CA trust와 관계없이 HTTPS MITM을 가능하게 합니다.
  • 디버깅 중에 TLS 차단을 확인하기 위해 트래픽을 강제로 라우팅하는 경우, 예:
iptables -t nat -A OUTPUT -p tcp -j DNAT --to-destination <Burp_IP>:<Burp_Port>

…여전히 위의 hook이 필요합니다. 검증은 libflutter.so 내부에서 이루어지며, Android의 system trust store에서는 이루어지지 않습니다.

참고자료

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 지원하기