Can not use Fiddler proxy with Android Emulator

Viewed 1089

I want to capture all the traffic from the emulated device by the Fiddler app on the host machine. After all my tries, I ended up with the infinite number of timed-out CONNECT requests even on HTTP (non HTTPS) requests.

What I did:

Android Emulator proxy setup:

android emulator proxy setup

Fiddler setup:

fiddler options

Added the following lines to the host machine hosts file: 127.0.0.1 local.test and to the Android device hosts file: 10.0.2.2 local.test. This is done to 1) prevent Chrome to force switching to HTTPS 2) point this name to correct IP addresses as it's different on the host machine and on the Android system.

Converted FiddlerRoot certificate from the DER format to PEM (begins with the BEGIN CERTIFICATE line) and stored it to the phone file system: /system/etc/security/cacerts/c8450d0d.0 with correct rights:

root cert on the device

Additions to Android were made using the Google-API image (Android 9) with the writable file system.

This root certificate appears in the system root certificates list:

system root cert list

FiddlerRoot certificate also successfully installed on the host machine and decrypts HTTPS traffic with no problems:

https decryption on host

In the result:

When I turn off proxy in the android emulator, I can access a local app using the custom domain name local.test:3200. I also can access internet sites with no problems.

When I turn on proxy in the android emulator, I see a lot of CONNECT requests that all times out:

CONNECT requests

When I try to access my local HTTP app http://local.test:3200 I receive the HTTPS CONNECT request to the specified port:

CONNECT on 3200

local on android

Why it tries to connect by HTTPS to the port 3200??? This issue only happens when the Android Emulator proxy is turned on. When turned off, I can successfully access my local page by HTTP. Is it the emulator app that tries to switch to HTTPS? Or what I'm doing wrong?

Currently, I can't capture and decode any traffic from the emulated device. Could anyone help me, please?

1 Answers

I also ran into this problem. Fiddler handles and intercepts HTTP requests to port 80 correctly, but not with HTTP requests to other ports nor HTTPS requests.

It turned out to be a bug of Android Emulator (which should be fixed in 2014 but the patch never goes into dev branch, so it is never fixed). It does not work well with HTTP proxy server that adds extra header(s) like Proxy-Agent: xxx or FiddlerGateway: Direct after HTTP/1.1 200 Connection Established in proxy response.

Try my header-less fork of gost, which acts as a proxy server and is able to forward to other proxy server: https://github.com/shunf4/gost/releases/tag/v2.11.1-without-header

You just run it like

gost(.exe) -L :8090 -F (Upstream HTTP proxy server address, e.g. http://127.0.0.1:3408)

to convert your HTTP proxy to one without extra headers. Then, set the proxy server to be 127.0.0.1:8090 in Android Emulator. And bang, everything works!

Related