Recording websocket messages

349 Views Asked by At

I need to extend a HTTP recorder to record websocket traffic. HTTP recorder is in C / unix platform.

I know HTTP traffic will be through port 80 or 443, hence I am able to record it. In HTTP message a new port is communicated, and through that port websocket traffic passes through. Since this port is dynamic, and HTTP messages will be different in different cases I can not parse and get port for websocket.

I think of below logic, not sure if that is going to work. Need your suggestion / pointers in this regard.

  • Make use of iptables
  • Forward all the traffic to a different port (where my application is listening) using iptable rules
  • Then my application should receive the data (hope it is possible)
  • Then my application should receive the destination information (when data is forwarded from iptables to my application, can I get actual destination ip/port).
  • Assuming, I get actual ip/port, then from my application, I can send data to actual destination.

    I know, its a long way to go, will this approach work.

  • 0

    There are 0 best solutions below