repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
flutter.mdMarkdown248 lines15.4 KiBsource raw download

title: "Flutter" section: "Mobile" sectionSlug: "mobile-pentesting" sourcePath: "src/mobile-pentesting/android-app-pentesting/flutter.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/mobile-pentesting/android-app-pentesting/flutter.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Flutter#

Flutter is Google’s cross-platform UI toolkit that lets developers write a single Dart code-base which the Engine (native C/C++) turns into platform-specific machine code for Android & iOS.
The Engine bundles a Dart VM, BoringSSL, Skia, etc., and ships as the shared library libflutter.so (Android) or Flutter.framework (iOS). All actual networking (DNS, sockets, TLS) happens inside this library, not in the usual Java/Kotlin Swift/Obj-C layers. That siloed design is why the usual Java-level Frida hooks fail on Flutter apps.

Intercepting HTTPS traffic in Flutter#

This is a summary of this blog post.[1]

Why HTTPS interception is tricky in Flutter#

Fingerprint the exact Flutter stack#

When reFlutter cannot auto-patch the APK (unsupported engine hash, debug engine, missing libapp.so, newer release), avoid guessing offsets and derive the exact Flutter/BoringSSL pair first.[2]

Step Command / File Outcome
Check packaging `unzip -l app.apk grep -E "libapp.so
Get snapshot hash python3 get_snapshot_hash.py libapp.so Engine snapshot hash (use libapp.so, not libflutter.so)
Map hash → Engine curl -s https://raw.githubusercontent.com/Impact-I/reFlutter/refs/heads/main/enginehash.csv | grep <hash> Flutter version + engine commit
If hash is missing python3 gen_enginehash.py in reFlutter scripts/ Fresh local hash table for newer/debug builds
Pull dependent commits Flutter release DEPS file Exact dart_boringssl_rev / BoringSSL commit

Find get_snapshot_hash.py here. A bogus hash such as repeated 4 values usually means the script was run against libflutter.so instead of libapp.so.[2][3]

Target: ssl_crypto_x509_session_verify_cert_chain()#

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").
  3. Re-compile libflutter.so, drop it back into the APK/IPA, sign, install.
  4. Pre-patched builds for common versions are shipped in the reFlutter GitHub releases to save hours of build time.[3]

### Option B – Live hooking with Frida (the “hard-core” path)
Because the symbol is stripped, you pattern-scan the loaded module for its first bytes, then change the return value on the fly.

// 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"); }
});

Run it:

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

Porting tips

Forcing traffic through your proxy#

Flutter itself ignores device proxy settings. Easiest options:

Quick Flutter TLS bypass workflow (Frida Codeshare + system CA)#

When you only need to observe a pinned Flutter API, combining a rooted/writable AVD, a system-trusted proxy CA, and a drop-in Frida script is often faster than reverse-engineering libflutter.so:

  1. Install your proxy CA in the system store. Follow Install Burp Certificate to hash/rename Burp's DER certificate and push it into /system/etc/security/cacerts/ (writable /system required).[8]

  2. Drop a matching frida-server binary and run it as root so it can attach to the Flutter process:[8]

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. Install the host-side tooling and enumerate the target package.[8]
pip3 install frida-tools --break-system-packages
adb shell pm list packages -f | grep target
  1. Spawn the Flutter app with the Codeshare hook that neuters BoringSSL pin checks.[8]
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. Route traffic through your proxy. Configure the emulator Wi-Fi proxy GUI or enforce it via adb shell settings put global http_proxy 10.0.2.2:8080; if direct routing fails, fall back to adb reverse tcp:8080 tcp:8080 or a host-only VPN.

  2. If the app ignores OS proxy settings, redirect sockets with a Frida shim. Tools like frida4burp hook dart:io/BoringSSL socket creation to force outbound TCP sessions to your proxy, even with hardcoded HttpClient.findProxyFromEnvironment or Wi‑Fi bypasses. Set the proxy host/port in the script and run it alongside the TLS bypass:[9]

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; chaining the socket redirect with the TLS bypass restores both routing and certificate acceptance for 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-based hook of BoringSSL verification (no signature scan)#

When pattern-based scripts fail across architectures (e.g., x86_64 vs ARM), directly hook the BoringSSL chain verifier by absolute address within libflutter.so. A reliable workflow is:[2]

const module = Process.findModuleByName('libflutter.so');
const addr = module.base.add(ptr('0x00740950')); // recompute per build/arch
Interceptor.attach(addr, {
  onLeave(retval) {
    retval.replace(0x1);
  }
});

Notes

iptables -t nat -A OUTPUT -p tcp -j DNAT --to-destination <Burp_IP>:<Burp_Port>

…you will still need the hook above, since verification happens inside libflutter.so, not Android’s system trust store.

Reversing the Dart payload (libapp.so)#

Quick static triage#

Before rebuilding libflutter.so, spend two minutes identifying what is actually packaged inside the APK:

unzip -l target.apk | grep -E "(libflutter|libapp|flutter_assets|kernel_blob)"
unzip -j target.apk "lib/arm64-v8a/libapp.so" "lib/arm64-v8a/libflutter.so" -d extracted_libs/
strings extracted_libs/libflutter.so | grep -E "^[0-9]+\.[0-9]+\.[0-9]+" | head

A quick first pass that regularly pays off:

apktool d target.apk -o apktool-out
rg -n -a "(https?://|api[_-]?key|token|secret|BEGIN (RSA|EC|PRIVATE)|supabase|stripe|aws)" \
  apktool-out/assets/flutter_assets extracted_libs -S

Recovering symbols, strings and hook points with blutter#

For ARM64 targets, blutter is currently the most practical first step because it parses the Dart AOT snapshot, labels functions, dumps the object pool, and generates Frida hook stubs.[10] For generic ELF work after that, check Reversing Native Libraries.

python3 blutter.py extracted_libs/ blutter-out
rg -n -a "(https?://|api[_-]?key|token|secret|BEGIN (RSA|EC|PRIVATE)|supabase|stripe|aws)" \
  blutter-out/pp.txt blutter-out/asm -S
gitleaks detect -s blutter-out/pp.txt --no-git

Useful outputs:

If you want a fully static workflow or a fast diff between two releases, newer tools like unflutter and flutterdec are worth trying, but blutter remains the quickest route from APK → named functions → Frida hook points.

Platform / MethodChannel reconnaissance#

A lot of Flutter-specific attack surface is not in TLS at all but in the bridge between Dart and the Android host. The most valuable strings are often MethodChannel / EventChannel names because they point to privileged native actions (contacts, SMS, files, biometrics, device identifiers, push tokens, custom crypto helpers, etc.).

jadx -r target.apk -d jadx-out
rg -n "MethodChannel|EventChannel|BasicMessageChannel|plugins\\.flutter\\.io|setMethodCallHandler|invokeMethod" jadx-out -S

Frida can log channel creation names very early during startup:

Java.perform(function () {
  var MC = Java.use('io.flutter.plugin.common.MethodChannel');
  MC.$init.overload('io.flutter.plugin.common.BinaryMessenger', 'java.lang.String')
    .implementation = function (messenger, name) {
      console.log('[+] MethodChannel: ' + name);
      return this.$init(messenger, name);
    };
});

Once you know the channel name, pivot into the matching Java/Kotlin handler and the Dart caller in blutter-out/asm/ to trace how sensitive data moves across the bridge.

Obfuscation notes for pentesters#

Flutter obfuscation (--obfuscate --split-debug-info) only renames symbols and stores the symbol map externally so developers can later run flutter symbolize. It does not encrypt flutter_assets, prevent native disassembly of libapp.so, or stop runtime hooks.[11]

If your assessment includes CI/CD artifacts, crash-upload buckets, update infrastructure, or mobile build pipelines, search for accidentally exposed:

Those artifacts can turn a “hard to read” AOT binary back into a much friendlier target.

References#