tags:

views:

58

answers:

3

Hi

I am planning to develop a windows application in .net which will act like a firewall/proxy server. But I have no iea where to start. Any help?

Basically I want to monitor all outgoing HTTP traffic through my computer.

A: 

The namespace System.Net is probably a good place to start.

Andrew Cox
+3  A: 

I may be wrong, as your definition of what you need to do is somehow vague, but I'm afraid you'll be disappointed by .NET: you'll have to put your hands in the dirty world of unmanaged code, as afaik there's no .NET wrapping of the needed functionalities.

Actually, it's far more bad than that: there's no "official" win32 wrapping of the needed functionalities; you'll have to either do some ugly/risky mangling on the system calls or use a third party tool which does the ugly/risky mangling on the system calls on your behalf (and I am talking of going on where the system calls' addresses are stored and change the address to point to your function).

I've been long looking for stuff like iptables for windows, and found none; I've looked into the code of both free and of commercial software (of course, I've not tried all available software, but I spent quite a fairly long time looking), and they all implement hooks by doing filthy things.

giorgian
The best explaination on how to do this is in "Network Programming for Microsoft Windows" by Anthony Jones and Jim Ohlund (Anthony is the current winsock dev lead at MS). It's out of print but you can still find copies: http://www.amazon.com/Network-Programming-Microsoft-Windows-Professional/dp/0735605602The example code has a skeleton LSP implementation that you can hack to your own purposes since that's what most people do.
Jeff Tucker
A: 

To monitor all the traffic you have to insert a layered service provider (LSP) that has the functionality that you want. You write one in C and even a well-written LSP looks like garbage. I've heard people on the winsock team complain about these things too. I know that System.Net doesn't really have anything that will directly let you do this (I'm on the team that writes System.Net so trust me on this one). You can query the system for network information like connections open, addresses in use, enumeration of network interfaces, etc. using System.Net.NetworkInformation but this won't let you monitor traffic.

If you just want to write a proxy server then System.Net will probably be as useful as anything else you can find but you're going to have to implement all proxy functionality beyond reading requests and writing responses yourself.

Jeff Tucker