Filter TCP packets in C #

I am writing an application in which all requests to the Internet have to come from it, like in a firewall. so that I can block the request for a specific website. In my case, the program will run on the same computer. I tried the promiscous method, but using that we can only capture all the packets coming in and out of the machine,

+1


source to share


2 answers


You have to push your code onto the TCP / IP stack, which, if I understand correctly, requires a Windows driver.

C # cannot compile native Windows drivers, so you will need to use a library or DLL to implement at least some of your functionality. Look for solutions using C ++.



-Adam

+1


source


The easiest way to do this is probably to write a Layered Service Provider (LSP) . There is an example of LSP development in the Microsoft SDK. Not as secure as setting up a driver type firewall, but much easier to implement.



There's a "possible" way to do it from C #, but I've never tried it. Something to see. If not, then just create your own C / C ++ DLL that implements the LSP and then link to your application.

+3


source







All Articles