er453r Posted January 7, 2007 Posted January 7, 2007 I want to write a script which would block some programs from connecting to the Internet, like a firewall. Any ideas?
Developers Jos Posted January 7, 2007 Developers Posted January 7, 2007 (edited) I want to write a script which would block some programs from connecting to the Internet, like a firewall. Any ideas?Why not use a firewall program to make live easy ? Edited January 7, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
er453r Posted January 7, 2007 Author Posted January 7, 2007 I just don't trust programs not written by me... Nah, I just need this to block one application and I don't want any firewall to do this.
James Posted January 7, 2007 Posted January 7, 2007 This will block any web browsers: While 1 If WinExists("- Mozilla FireFox") Then ProcessClose("FireFox.exe") EndIf If Win Exists("- Microsoft Internet Explorer") Then ProcessClose("IEXPLORE.EXE") EndIf WEnd Just keep adding them for browsers. It's a long way of doing it but it will work. Secure Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Developers Jos Posted January 7, 2007 Developers Posted January 7, 2007 This will block any web browsers: While 1 If WinExists("- Mozilla FireFox") Then ProcessClose("FireFox.exe") EndIf If Win Exists("- Microsoft Internet Explorer") Then ProcessClose("IEXPLORE.EXE") EndIf WEnd Just keep adding them for browsers. It's a long way of doing it but it will work. Secure This doesn't block the traffic but Kills the programs ... By the way ... its easier to test for for a program with ProcessExists() SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Developers Jos Posted January 7, 2007 Developers Posted January 7, 2007 I just don't trust programs not written by me... Nah, I just need this to block one application and I don't want any firewall to do this.Why are you running Windows ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
er453r Posted January 7, 2007 Author Posted January 7, 2007 I just kill every precess and service I don't use Blocking WebBrowsers isn't a problem, I need to block only Internet connection, without killing the program. The program should work as usual, but without access to the Internet.
James Posted January 7, 2007 Posted January 7, 2007 Hmm.. Why would you want to? Are you making a firewall? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
BALA Posted January 7, 2007 Posted January 7, 2007 (edited) If you're blocking Internet access, then using a web browser seems pointless... Unless if you want to block it for another program. I'd say find the program that gives you Internet access (i.e. your router) and kill that. Though again that will be no Internet for all programs... Edited January 7, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
er453r Posted January 7, 2007 Author Posted January 7, 2007 Something like a *lite* firewall. Easiest way I can do it, is just disconnect connection from the Control Panel with a script. But that kills Internet for all programs
BALA Posted January 7, 2007 Posted January 7, 2007 Hmm... Your *lite* firewall sorta remembers me of ZoneAlarm's firewall: how it can block access to certain programs and such. Perhaps one of us should research how a firewall actually works, then try to create an AutoIt script that will do that. [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Darkinspiration Posted January 8, 2007 Posted January 8, 2007 Okay what do you have at your disposition now. Do you have a router (something like a d-link or a linksys)? Your routeur can block specific port from accessing your wan (internet and isp) Do you have windows XP There is a firewall build-in windows XP sp2 that can be used to block programs from accessing the lan. (the network betewen you and your routeur ) This will also prevent them from accessing the internet. it's controled by the control pannel in the windows firewall control. Now if you don't have any of those thing, it becoming complicated. There is a belive two ways to do this. The simplest would be to close the required port your application use. I'm not sure it how it can be done however. The other way would be to use a autoit script as a local proxy server. All application requiring internet access use the proxy except those that do not. There is a autoit webserver somewhere on the forum. There must be a proxy as well....
Erik. Posted January 8, 2007 Posted January 8, 2007 I just don't trust programs not written by me... Nah, I just need this to block one application and I don't want any firewall to do this.Windows is not written by you, don't trust it need to say that sorry I little problem, hard to find and fix
sneakysmith12 Posted January 9, 2007 Posted January 9, 2007 (edited) Here would be a great place to demostrate some programs I'm creating. This is a beta version of a Web Blocker I am creating, along with a few other programs. Some controls don't work (such as the delete command) although if you know how to find the file you can delete it manually. It uses a file called hosts, which will allow you to block ALL connects by simply entering in a URL or an IP. expandcollapse popup#include <GUIconstants.au3> #include <XSkin.au3> #include <Guilist.au3> #include <File.au3> #include <array.au3> $Skin_Folder = @ScriptDir & "\xskin\Skins" $XSkinGui = XSkinGUICreate( "WebBlocker", 350, 350, $Skin_Folder) $Icon_Folder = @ScriptDir & "\xskin\skins" $XIcon = XSkinIcon($XSkinGui, 2) ;Active Objects $DeleteObject = XSkinButton("Delete URL",20,300,75,20,"Delete") $AddObject = XSkinButton("Add URL",100,300,75,20,"Add") $AddBlockLabel = GUICtrlCreateLabel("Blocked URLs:",20,30) $BlockedSitesList = GUICtrlCreateList("",20,50,120,200) $ListUpDown = GUICtrlCreateUpDown($BlockedSitesList) $Limit = GUICtrlSetLimit($BlockedSitesList,500,0) if @OSTYPE = "Win32_Windows" Then $search = @windowsdir & "\hosts" Else $search = @systemdir & "\drivers\etc\hosts" EndIf if $search = -1 then msgbox(0,"error","No files/directories matched the search pattern") Exit endif while 1 $file = filefindnextfile($search) if @error then ExitLoop WEnd fileclose($search) $File = $search GUISetState() ReadFile() While 1 $msg = GUIGetMsg() If $msg = $XIcon[1] Then Exit If $msg = $XIcon[2] Then GUISetState(@SW_MINIMIZE) MouseOver() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd GUIDelete() Exit Func Add() $Add = XSkinInputBox("Add URL","Type the URL","www.likethis.com") _GUICtrlListAddItem($BlockedSitesList,$Add) FileOpen($File,1) $IpAdd = "127.0.0.1" $FileAdd = $IpAdd & " " & $Add FileWriteLine($File,$FileAdd) FileClose($File) EndFunc Func Delete() $ItemToRemove = XSkinInputBox("Delete URL","Type the URL","www.likethis.com") $Remove = _GuiCtrlListFindString($BlockedSitesList,$ItemToRemove) _GUICtrlListDeleteItem($BlockedSitesList,$Remove) FileOpen($File,1) $IpRem = "127.0.0.1" $FileRemove = $IpRem & " " & $Remove _ReplaceStringInFile($File,$FileRemove," ",0,1) FileClose($File) EndFunc Func ReadFile() $FileCount = _FileCountLines($File) For $Counter = 20 to $FileCount $Add = FileReadLine($File,$Counter) if $Add = "" or $Add = " " then $Add = "" _GUICtrlListAddItem($BlockedSitesList,$Add) Next FileClose($File) EndFunc[b][/b] Please note that this uses xskin, so you must have that if you want to complie the code. I will include the executable if you wish to ignore setting up the files. Each time you wish to block a site you need to restart your web browser / program. Other than that it works flawlessly. Please comment if you like it. [EDIT] I had to make a zip file of the program. Don't worry about the installer. Like I said I have full intentions of developing this into a software package. Of course freeware.WebBlockerInstall.zip Edited January 9, 2007 by sneakysmith12 Yeah I'm not the greatest at DarkBasic either, but I'm good enough for a link :D A Thread of a W.I.P. that im making
er453r Posted January 9, 2007 Author Posted January 9, 2007 I know this method, but it requires you to know what to block Maybe there is a method to intercept connection request by a program? ps. Erik: I don't know anyone who trusts Windows...
Westi Posted February 20, 2007 Posted February 20, 2007 Check the application with netstat -b and create an unreachable route with route.exe ADD but do it very fast
tAKTelapis Posted February 20, 2007 Posted February 20, 2007 Hmm, it seems you are talking about wanting to give everything on the computer access, except for one program.. but you dont know what the program is. this is where your whole situation gets reversed. so far, everyone has suggested black listing.. ie: DENY access for program X what you might be after, is a WHITE list, ie: ALLOW these Applications, DENY all others Whitelists can get hairy at the best of times, perhaps what you are really after is a Microsoft ISA server, but if you are determined to block a particular URL / PORT or access to a particular IP address (on windows XP pro) you could look into IP security policies thats how i do it anyways, then again, i know what i want to block.
Shevilie Posted February 20, 2007 Posted February 20, 2007 If you know the URL the program will connect to you can do some fun in the c:\WINDOWS\system32\drivers\etc\hosts Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
locomaestro Posted February 21, 2007 Posted February 21, 2007 If you know the URL the program will connect to you can do some fun in the c:\WINDOWS\system32\drivers\etc\hostsjust use a freaking rootkit to do that its not that hard go fetch for a rootkit it can block internet access from any program you want.
dirty Posted October 16, 2011 Posted October 16, 2011 Wow this is getting so complicated LOL Its hard sometomes to see how other people instead of giving answers asking questions. I too want to make a script to block all connection made by any application except those i define. Editing hosts is useless in this case and use of firewall is also not the way to go since i cant automate it and i have it completely disabled because it slows down traffic by70% instead of just filtering it. If have a host editor made long time ago to block URL's IP's quickly and it does not require anything. Hopefully someone will find this relative or helpfull at all. I didQuick HOSTS Editor.au3
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now