Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you block selected applications from accessing the internet (C++, Win32)

I want to have an application or service that is running that, on some schedule, can disable access to the internet for all applications except for specific ones.

I'm trying to create a filter that can be turned on or off under programmatic control. Not just IP addresses and ports, but I want to be able to block specific applications as well, much like Zone Alarm and other software firewalls let you block.

For example, iexplore.exe, skype.exe, firefox.exe, aim.exe. But still need to allow other applications to connect as needed.

It has to work on Vista as well as XP, but I kind of expect that the method will be different on each of those platforms.

Basically, the filter has to tie the network communication back to the executable that is making the request and then allow or deny it.

Update:

On Vista at least, it looks like I want to use filters in the ALE layers of the WFP.

On XP, I'm still looking for the best way to do it. Do I really need to be writing device drivers and dealing with kernel stuff? I'm just a lowly application developer. Kill me now.

Update 2:

Currently looking at the PfCreateInterface and related Pf* API's for pre-Vista systems.

like image 485
Monkey47 Avatar asked Jan 08 '09 05:01

Monkey47


People also ask

How do I restrict internet access on Windows?

Open Windows Firewall settings.Open the "Exceptions" tab. Un-check the program for which you want to block access to the internet. Click "OK" when prompted.


3 Answers

You can change both Vista and XP's firewall policies dynamically using the INetFwAuthorizedApplications interface from the Windows Firewall API.

Also see this question.

like image 174
Max Caceres Avatar answered Oct 18 '22 22:10

Max Caceres


You'll have to write a device driver that filters traffic based on the executable requesting the traffic.

like image 1
Paul Whitehurst Avatar answered Oct 18 '22 21:10

Paul Whitehurst


by limiting its access to internet using firewall. go to firewall setting advanced tab (win 7) and do that

like image 1
2001 Avatar answered Oct 18 '22 22:10

2001