Send raw requests via sockets

I want to create a proxy server on sockets, ready-made solutions are unlikely to work because I already have a connection that is always open and which will receive raw requests like:

CONNECT www.example.com:443 HTTP/1.1
or

**GET** /search?q=test HTTP/2
Host: www.bing.com
User-Agent: curl/7.54.0
Accept: */*

To send raw requests via sockets I need to parse ip and port, even then I’m not sure it will work.
Are there any solutions to make this work?

Could you share a bit more about what you’re trying to build? What is going to be connecting to this server?

Edit: In the mean time, an article like this might give you a place to start? TCP/IP packets - 3 Manually create and send raw TCP/IP packets - inc0x0

Yeah, like @notaghost made a good point: we sort of need to know what kind of thing you’re trying to build to give more feedback. I think that you want to build a TCP proxy to intercept traffic and debug it? If so, there are a number of premade SOCKS proxies that you can use:

  • Geniar (2017) discusses using SSH to create a SOCKS5 route to (mainly to bypass web filtering but can maybe be applied to your situation).
  • Wireshark (n.d.) is a “go to” utility for intercepting network traffic and can be used to capture traffic flowing through your NIC.
  • This one’s a bit old, but nixbit (n.d.) lists the infamous SPIKE Proxy which is used to fuzz network-based software through (obviously) a proxy.

If you want to write your own SOCKS proxy, I recommend both Golubin (c.a. 2018)'s tutorial or Seitz & Arnold (2021, pp. 19-26)'s section in their book on their black hat Python book.

2 Likes

This topic was automatically closed after 121 days. New replies are no longer allowed.