The task of sniffing traffic from an app on Android x86 ranges from trivial, to very complicated. The difference comes down to the various anti-sniffing techniques employed by the app and or the Android OS itself. This guide will walk you through the process starting with the most trivial scenario, all the way to the most complex.
Scenario 1: ProxyDroid
Before diving into the complexities of sniffing encrypted HTTPs traffic, it’s always good to do a sanity check to make sure that the packets are flowing into BurpSuite
- Install ProxyDroid app on Android. In case you are wondering why not use built in proxy settings, it’s because some apps ignore the built in proxy setting. By using ProxyDroid, it eliminates the guesswork and every single request is proxied
- Set host and port in ProxyDroid to match settings in BurpSuite
- Sniff HTTP traffic, it should be successful
- Sniffing HTTPs traffic will fail at this point, but you should at least see connection attempt errors showing up in BurpSuite event log. Those prove that it’s trying. See Scenario 2 on how to fix this.
Scenario 2: Simple HTTPs
When the application established HTTPs connection, the minimum it needs is a valid SSL certificate to prevent man in the middle attacks. By installing BurpSuite root certificate on Android, most applications will accept BurpSuite proxy as a trustworthy server.
- Download BurpSuite cert to Android by visiting http://burpsuiteproxyip:8080
- Steps to install it depend on exact Android version and sometimes the certificate has to be converted from der format to cer
- Sniff HTTPs
traffic in BurpSuite
- If it works, congratulations!
- If you get other errors try Scenario 3
Scenario 3: HTTPs protected with pinning
Some applications aren’t satisfied with any old valid certificate, they are pinned to a specific certificate. Luckily there is a way to bypass this
- Android: Install frida-server on Android in /data/local/tmp
- Android: Run frida-server -l IPofAndroid (ex. 192.168.1.100)
- Windows: Run frida-ps -aiH IpofAndoid to find out application identifier ex: com.company.myapp
- Windows: download bypass.js into current directory
- Windows: frida -H IpofAndroid -f com.company.myapp -l bypass.js –no-pause (this will start the app)
- Windows: Watch HTTPs requests come in in plain text into BurpSuite, if you’re still gettting errors, especially “Remote host terminated the handshake” in BurpSuite and “CERTIFICATE_VERIFY_FAILED: self signed certificate in certificate chain” in logcat chances are you need to go deeper and look at Scenario 4 (if the app is build on Flutter)
Scenario 4: HTTPs inside Flutter
- Android: find /data/ | grep libflutter.so
- Android: upload for analysis in Ghidra
- Ghidra: search for “ssl_client” string
- Ghidra: from here find the function that contains “ssl_client”,“ssl_server” and takes long,long,char* as it’s 3 arguments. In my version I had a single match, so I there was no trial and error required to narrow things down.
- Ghidra: get the function’s signature by copying the first several bytes
- Ghidra: If you have trouble, here is a more detailed write up https://blog.nviso.eu/2019/08/13/intercepting-traffic-from-android-flutter-applications/ , just note the differences between ARM and x86, but the process is very similar.
- Windows: incorporate the bytes into flutter-addr.js script
- Windows: frida -H IpOfAndroid -f com.company.myapp -l flutter-addr.js –no-pause
- Windows: you should see the application start and then as the requests are being sent you should see
- Disabling SSL validation
- Retval: 0x0
- If you don’t see retval 0x0 try playing around with “add(0x1)” to address
- Windows: you should also see plan text requests coming into BurpSuite now