Search code examples
proxyreverse-proxywiresharkcharles-proxy

Not able to receive and forward remote request using Charles Web Proxy as a Reverse Proxy


I am trying to capture an old application that didn't honour the system's proxy setting. The only config I can change is the server IP address.

Capturing the packets with Wireshark. Without the Charles reverse proxy, I can see requests after the first three handshake requests.

without reverse proxy

With the reverse proxy, the connection stuck after the handshake requests.

with reverse proxy

I notice that when Charles received a request and connecting to somewhere but it will just stuck there:

connecting

Following is the config of the reverse proxy (Remote host removed):

reverse proxy config

Any help, solution and workarounds would be appreciated!


Solution

  • First of all, your app uses neither HTTP nor HTTPS. Studying screen shot of successful connection gives some details on protocol used:

    • the first message after handhsake is originated by server contrary to common client-server approach, where client is responsible for sending query. This fact is enough to cross out HTTP and HTTPS.
    • payload data isn't human-readable, so it's a binary protocol.
    • based on PUSH flags, protocol is much more likely to be message-based rather than stream-based

    So client establishes connection, immediately gets some command from server and replies it. Then communication continues. I can't guess exact protocol. Port number might be irrelevant, but even if it's not, there are only few protocols using 4321 port by default. Anyway, it can always be custom private protocol.

    I'm not familiar with Charles, but forwarding arbitrary TCP stream is probably covered by its port forwarding feature rather than reverse proxy. However, I don't really see any benefits in sending traffic through Charles in this case, capturing data on your PC should be enough to study details.

    If you are looking for traffic manipulation, for arbitrary TCP stream it's not an easy task, but it must be possible. I'm not aware of suitable tools, quick googling shows lots of utils, but some of them looks applicable to text based stream only, so deeper study is required.