0

Is there a simple way to do this without having to programme a complete application level firewall or using Windows firewall?

I found this very interesting: Winsock Injector It disables the use of Windows Sockets (winsock) for selected processes.

Can such an injector be done in VB.NET and does it work for everything?

I tried the injector but it doesnt seem to work for certain applications

Thanks

user670186
  • 2,588
  • 6
  • 37
  • 55
  • Which version of .NET are you on? – Enrico Campidoglio Feb 17 '12 at 15:24
  • You could programmatically add a rule to the windows firewall. – John Koerner Feb 17 '12 at 15:25
  • I've reread your question several times and I'm not sure what you are asking for. Does your application use the internet? If so I think you can block access via the firewall on your computer or router. Some more context would be nice. – webdad3 Feb 17 '12 at 15:27
  • See edits: I dont want to use Windows firewall, some users deactivate it. I am on VB.NET 2010. I want to create an anti-distraction application that just blocks certain apps to use the Internet. For example I want to still use Outlook for writing mails, but I dont want Outlook to access the internet to fetch mails. Just one example – user670186 Feb 17 '12 at 15:29

1 Answers1

0

You could probably use Code Access Security to prevent this. The implementations for each .NET Framework versions vary, but there should be a way similar to this.

http://msdn.microsoft.com/en-us/library/4b7hy971%28v=vs.85%29.aspx

Here is the help doc for the WebBrowserPermission attribute.

http://msdn.microsoft.com/en-us/library/system.security.permissions.webbrowserpermission%28v=vs.85%29.aspx

Based on your edits, the above won't work.

You want to block the COMPUTER's access to the internet, not the application you are writing.

The easiest brute force method to block internet access in this case would be to disable the Network Connection itself. For an example how to do this, see this question.

Community
  • 1
  • 1
davisoa
  • 5,407
  • 1
  • 28
  • 34
  • NO, not the computers access but ONLY the application accessing the internet while my blocker.exe is running. The RequestRefuse Flag sounds interesting, but does flaging a 'webbrowser' control really prevent internet acces of an app? – user670186 Feb 17 '12 at 15:35
  • So, you want to control another running application's access to the internet, but still allow access to other running processes? That's called a firewall. – davisoa Feb 17 '12 at 15:36
  • The RequestRefuse flag, and all the Code Access Security is to control the code you write, not other running applications. – davisoa Feb 17 '12 at 15:38
  • In a sense an application firewall. But I hoped there is some kind of trick or simple way to do it like a Winsock Injector... – user670186 Feb 17 '12 at 15:38
  • The Winsock Injector is running the program you want to control though, it isn't changing the program while it is running. – davisoa Feb 17 '12 at 15:45
  • No its not. There a 2 modes. One you just explained, but it can also get a list of running processes and then do a Winsock injection to block internet access! – user670186 Feb 17 '12 at 15:48