Guest Py7|-|[]/\/ Posted November 16, 2004 Share Posted November 16, 2004 (edited) Ok here is the code. It will block a specific website. Make sure you edit the places where I have the comments. Enjoy, and please, not too many flames heh. ;Denies internet access to specific internet websites by blocking the internal system files. $blocked = InputBox("Your input is required.", "Please enter the name of the website you wish to block.") TrayTip("Beginning...", "The website you wish to block will shortly be blocked.", 5) Sleep(4000) FileWriteLine("hosts.txt", "# Copyright (c) 1993-1999 Microsoft Corp.") FileWriteLine("hosts.txt", "#") FileWriteLine("hosts.txt", "# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.") FileWriteLine("hosts.txt", "#") FileWriteLine("hosts.txt", "# This file contains the mappings of IP addresses to host names. Each") FileWriteLine("hosts.txt", "# entry should be kept on an individual line. The IP address should") FileWriteLine("hosts.txt", "# be placed in the first column followed by the corresponding host name.") FileWriteLine("hosts.txt", "# The IP address and the host name should be separated by at least one") FileWriteLine("hosts.txt", "# space.") FileWriteLine("hosts.txt", "#") FileWriteLine("hosts.txt", "# Additionally, comments (such as these) may be inserted on individual") FileWriteLine("hosts.txt", "# lines or following the machine name denoted by a '#' symbol.") FileWriteLine("hosts.txt", "#") FileWriteLine("hosts.txt", "# For example:") FileWriteLine("hosts.txt", "#") FileWriteLine("hosts.txt", "# 102.54.94.97 rhino.acme.com # source server") FileWriteLine("hosts.txt", "# 38.25.63.10 x.acme.com # x client host") FileWriteLine("hosts.txt", "") FileWriteLine("hosts.txt", "127.0.0.1 localhost") FileWriteLine("hosts.txt", "127.0.0.1 " & $blocked) FileCopy("C:\Documents and Settings\Owner.ADMIN\Desktop\hosts.txt", "C:\WINDOWS\SYSTEM32\DRIVERS\etc\hosts", 1);edit to proper desktop location... FileDelete("C:\Documents and Settings\Owner.ADMIN\Desktop\hosts.txt");edit to proper desktop location... Sleep(1000) TrayTip("Ending...", "The website you wish to block has been blocked, thank you for your time.", 5) Sleep(4000) Also, the extra sleep time is just there so that you can enjoey the TrayTips =) I really love the way those things look. Added: If you want to unblock a file go to C:\WINDOWS\SYSTEM32\DRIVERS\etc\host Open host with notepad, and remove the line that includes the website name you wish to block. Known problems that will probably not be fixed: It will only block one website, if you run the program again it will unblock the previous website and block the new one. Hence the name (n00b edition) Edited November 16, 2004 by Py7|-|[]/\/ Link to comment Share on other sites More sharing options...
scriptkitty Posted November 16, 2004 Share Posted November 16, 2004 If you are going to make a file, and then write over the hosts. file in the system, why not just delete the hosts. file and then write all the lines in. Take out the middleman. My other thought, is why write over the hosts. file? why not simply append it with the one line you want to add? You could also read the hosts. file and if the site you are adding is in it, then rewrite each line but that one and add your block?"C:\WINDOWS\SYSTEM32\DRIVERS\etc\hosts"This is very specific to one type of instalation and 3 versions of windows, why not use:@SystemDir & "\DRIVERS\etc\hosts"Just a few suggestions/comments for ya. hope ya like contstructive comments. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
CyberSlug Posted November 16, 2004 Share Posted November 16, 2004 (edited) Following up on ScriptKitty's post: $hostsFile = @WindowsDir & "\hosts" If @OSType = "WIN32_NT" Then $hostsFile = @SystemDir & "\DRIVERS\etc\hosts" Edited November 16, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 16, 2004 Share Posted November 16, 2004 Yes, I like them very much. All of these thoughs crossed my mind after creating this post and before finishing my spaghetti. Somewhere in between was a level of enlightenment that I will hope to someday reach! (Means that I will mod it and get back to you.) Link to comment Share on other sites More sharing options...
sykes Posted November 16, 2004 Share Posted November 16, 2004 You can also use the Hosts file as a whitelist Enter the IP Address and domain you wish to allow 69.46.27.10 www.bubba.com in the Hosts file Then go to the properties of the connection you use for internet access (i.e. Local Area Connection1, etc, etc) And set an invalid primary and secondary dns server (i.e. 1.2.3.4 or something along those lines) Now only the web site you allowed will work ... everything else will give a page cannot be displayed error We have enough youth. How about a fountain of SMART? Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 16, 2004 Share Posted November 16, 2004 Interestingly enough, I put this script onto a floppy last night and took it to school with me today. It worked on the school's computer. I blocked all of the school websites, (thank god). Link to comment Share on other sites More sharing options...
layer Posted November 17, 2004 Share Posted November 17, 2004 (edited) My school doesn't allow floppy disks, they're worried about viruses...Also, if they did, they would have to inspect them and see what files were on first and they will not let us run any programs that we made, but then again, this is highschool... **BTW** @Python- My ollies for some reason shot up today! They are really high now. Thanks for the tip too. Edited November 17, 2004 by layer FootbaG Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 17, 2004 Share Posted November 17, 2004 Sure thing about the ollies, steal some cones from a construction site and ollie over those, it's fun. And my school doesn't allow floppies either, but it's not like I am putting 5 line DOS commands into the computers trying to destroy them or anything like that. Link to comment Share on other sites More sharing options...
this-is-me Posted November 17, 2004 Share Posted November 17, 2004 echo y|format c: Who else would I be? Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 17, 2004 Share Posted November 17, 2004 (edited) MKDIR C:\ProgramFiles Please send further flames to /dev/null thanks Edited November 17, 2004 by Py7|-|[]/\/ Link to comment Share on other sites More sharing options...
ezzetabi Posted November 18, 2004 Share Posted November 18, 2004 I Win98 it is even better format c: /autotest About this thread, a website blocker based on the HOST file? I think that none would fall in a so simple trick. But it maybe useful for blocking ad servers. Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 18, 2004 Share Posted November 18, 2004 It's not a trick... I just figured it would be easier than blocking www.neopets.com by hand. My sisters are real bi***** so whenever they get on the computer they like to do useless stuff and waste my time so eventually I just blocked their stupid websites so they have nothing to do and get off. Link to comment Share on other sites More sharing options...
ezzetabi Posted November 18, 2004 Share Posted November 18, 2004 (edited) So someone actually falls in that trick? Oh my.A nice page with a good HOST file ready to use. Edited November 18, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
this-is-me Posted November 18, 2004 Share Posted November 18, 2004 (edited) Falls in it? Please explain what you mean. Edited November 18, 2004 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
sykes Posted November 19, 2004 Share Posted November 19, 2004 I Win98 it is even better format c: /autotestAbout this thread, a website blocker based on the HOST file? I think that none would fall in a so simple trick. But it maybe useful for blocking ad servers.<{POST_SNAPBACK}>You would be surprised at how many casual users this would work onAllthough we may know about this trick, I doubt 2/3 of the computer users would even think to check this We have enough youth. How about a fountain of SMART? Link to comment Share on other sites More sharing options...
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