Redirecting network traffic (building a proxy)

I want to build a proxy, middleman between various client programs on my machine and servers outside, like this:

Client -> Proxy -> Server, Client <- Proxy <- Server.

OSes are Windows XP, 7 and 8.
Within that proxy I want to analyze data before it reaches it's destination and have full control over it to the point where I can prevent a packet from reaching it's destination if my program finds something suspisious going on. I need incoming and outgoing traffic of specific adresses and ports to be forwarded into my application on my client machine. My app then should deliver packets to their destination after they were analyzed.

The parts where data is received, analyzed, manipulated if needed, and sent is something I could code with no difficulty. But the concept of redirecting and forwarding is hard for me to grasp at the moment. A good example is always welcome, but I'd like to know at least what winsock functions I have to use.

If it's possible, I would like to use Windows libraries only, nothing from 3rd parties.
Last edited on
It sounds like what you want is a firewall with deep packet inspection.
I guess so. I beleive there should be plenty of this kind of software, but I want to try to code at least basic one for educational purposes. I can already inspect packets any way I want, so I'm looking for a way to redirect them at the moment.
Well, I've managed to create a sort of proxy, but that involved lots of sniffing, having to manually force an application to send packets to specific port and knowing original destination in advance. That's something, but it's really not the way I want my program to work.

Is there any way I can make it so my application monitors ports that I specify and if some other program tries to make a connection through these ports, redirect it to another port? And same for incoming connections.
Topic archived. No new replies allowed.