Jump to content

Block internet connection for a program


 Share

Recommended Posts

  • Developers

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 ?

:P

Edited 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.
  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Developers

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()

:P

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.
  :)

Link to comment
Share on other sites

  • Developers

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 ? :P

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.
  :)

Link to comment
Share on other sites

I just kill every precess and service I don't use :P

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.

Link to comment
Share on other sites

If you're blocking Internet access, then using a web browser seems pointless...:P

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 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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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 :D:P need to say that sorry

I little problem, hard to find and fix

Link to comment
Share on other sites

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.

#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 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

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

  • 4 years later...

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 did

Quick HOSTS Editor.au3

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...