Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using C#/C++, is it possible to limit network traffic?

I'm developing a parental monitoring/tracking application that has a feature to lock down all internet activity. While disabling the network adapter would seem like a simple solution, the application must have the ability to turn the internet back on remotely -- so the network needs to remain enabled, to a certain limit.

Unfortunately, I haven't found a suitable way to achieve this in practice. Without this feature, the application is pretty much dead in the water. So I've hit a huge road block, and I'm open to any suggestions.

With my application, I need to achieve two requirements:

  1. Drop all internet activity. and then
  2. Turn on only internet activity to a specified port and IP address. (my service, which will be polled)

Simple goal, right? Not so much lately.

While I am looking to achieve this in C#, I understand that may be a long-shot and I am open to C++ solutions that could be called as a resource through my application.

Also note, I cannot install any third-party software on the user's system, as this solution needs to be all-encompassing.

Thanks in advance!

like image 230
George Johnston Avatar asked Jan 26 '10 21:01

George Johnston


1 Answers

You need to inject a custom layer into the IP stack, using Windows Filtering Platform. This SDK targets specifically parental control programs and such. Needless to say, as any kernel module, it has to be developed in C and you must have expert knowledge of Windows internals:

The Windows Filtering Platform API is designed for use by programmers using C/C++ development software. Programmers should be familiar with networking concepts and design of systems using user-mode and kernel-mode components.

like image 167
Remus Rusanu Avatar answered Oct 26 '22 09:10

Remus Rusanu