Sign in to follow this  
Followers 0
Guest Py7|-|[]/\/

Website Blocker (n00b edition)

15 posts in this topic

#1 ·  Posted (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 by Py7|-|[]/\/

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by layer

FootbaG

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

echo y|format c:


Who else would I be?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

MKDIR C:\ProgramFiles

Please send further flames to /dev/null thanks :)

Edited by Py7|-|[]/\/

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Falls in it? Please explain what you mean.

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

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.

<{POST_SNAPBACK}>

You would be surprised at how many casual users this would work on

Allthough 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?

Share this post


Link to post
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
Sign in to follow this  
Followers 0