Showing posts with label NETWORK HACKS. Show all posts

Friday, August 16, 2013

MAC Address (Media Access Control)

MAC Address (Media Access Control)



MAC (Media Access Control) addresses are permanent by design, several mechanisms allow modification, or "spoofing", of the MAC address that is reported by the operating system. This can be useful for privacy reasons, for instance when connecting to a Wi-Fi hotspot, or to ensure interoperability. Some internet service providers bind their service to a specific MAC address; if the user then changes their network card or intends to install a router, the service won't work anymore. Changing the MAC address of the new interface will solve the problem. Similarly, some software licenses are bound to a specific MAC address. Changing the MAC address in this way is not permanent: after a reboot, it will revert to the MAC address physically stored in the card. A MAC address is 48 bits in length.

A MAC address is a physical hardware address assigned to each device that has the capability of connecting to a network. The internet is nothing more than a large network. The MAC address is something that is assigned in the chip on the device and is not something the user can change.

As a MAC address can be changed, it can be unwise to rely on this as a single method of authentication. IEEE 802.1x is an emerging standard better suited to authenticating devices at a low level.

Types of MAC address: 
Unicast address : An address for a specific computer.
Multicast address : An address for a specific group of computers in
network.
Broadcast address : An address for all computers in network.


HOw Can U Change MAC Address:

Windows


Under Windows XP, the MAC address can be changed in the Ethernet adapter's Properties menu, in the Advanced tab, as "MAC Address", "Locally Administered Address", "Ethernet Address" or "Network Address". The exact name depends on the Ethernet driver used; not all drivers support changing the MAC address in this way.

However, a better solution - requiring Administrative User Rights - is to pass over the System Registry Keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}. Here settings for each network interface can be found. The contents of the string value called 'NetworkAddress' will be used to set the MAC address of the adapter when next it is enabled. Resetting the adapter can be accomplished in script with the freely available command line utility devcon from Microsoft, or from the adapters context menu in the Network Connections control panel applet.

There is a nice tool to change the MAC address for all cards (even those that can't be changed through the adapter's Properties menu): SMAC MAC Address Changer

Note: to check your MAC address easily on a Windows XP box, go to Run, type CMD, then type "ipconfig /all" without quotation in the command prompt. The number under physical address is the MAC address. If multiple IP are displayed, you should look under the label "Ethernet adapter x", where x is the name of your connection (which is Local Area Connection by default).

Windows

Under Windows XP, the MAC address can be changed in the Ethernet adapter's Properties menu, in the Advanced tab, as "MAC Address", "Locally Administered Address", "Ethernet Address" or "Network Address". The exact name depends on the Ethernet driver used; not all drivers support changing the MAC address in this way.

However, a better solution - requiring Administrative User Rights - is to pass over the System Registry Keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}. Here settings for each network interface can be found. The contents of the string value called 'NetworkAddress' will be used to set the MAC address of the adapter when next it is enabled. Resetting the adapter can be accomplished in script with the freely available command line utility devcon from Microsoft, or from the adapters context menu in the Network Connections control panel applet.

There is a nice tool to change the MAC address for all cards (even those that can't be changed through the adapter's Properties menu): SMAC MAC Address Changer

Note: to check your MAC address easily on a Windows XP box, go to Run, type CMD, then type "ipconfig /all" without quotation in the command prompt. The number under physical address is the MAC address. If multiple IP are displayed, you should look under the label "Ethernet adapter x", where x is the name of your connection (which is Local Area Connection by default).

Router

The method to change the MAC address of a router varies with the router. Not all routers have the ability to change their MAC address. The feature is often referred to as "clone MAC address". This take the MAC address of one of the machine on your network and replaces the router's existing MAC address with it. Some support the option to manually enter the MAC address.

How to change a MAC address in Linux


To change your MAC address in Linux (and most *nix system) is easy. All it takes is two easy to script commands:

    ifconfig eth0 down hw ether 00:00:00:00:00:01

    ifconfig eth0 up

These two little commands would set your eth0 interface to use the MAC 00:00:00:00:00:01. Just plug in the NIC you want to set and the MAC address you want to use into the commands above and your done. Changing your MAC address is one of those things that is much easier to do in Linux then under Windows.
Read More

Intrusion Detection System (IDS)

Intrusion Detection System (IDS)

Photobucket
 
 
      

>>Intrusion Detection System (IDS):

A system that tries to identify attempts to hack or break into a computer system or to misuse it. IDSs may monitor packets passing over the network, monitor system files, monitor log files, or set up deception systems that attempt to trap hackers.

Computer systems have become more vulnerable to intrusions than ever. Intrusion Detection is a security technology that allows not only the detection of attacks, but
 also attempts to provide notification of new attacks unforeseen by other
 components. Intrusion detection is an important component of a security system,
and it complements other security technologies.

>>How does an IDS work?

While there are several types of IDSs, the most common types work the same.
They analyze network traffic and log files for certain patterns. What kind of
patterns you may ask? While a firewall will continually block a hacker from connecting to a network, most firewalls never alert an administrator.

The administrator may notice if he/she checks the access log of the firewall, but
that could be weeks or even months after the attack. This is where an IDS comes
into play. The attempts to pass through the firewall are logged, and IDS will analyze its log. At some point in the log there will be a large number of request-reject
entries. An IDS will flag the events and alert an administrator. The administrator
can then see what is happening right after or even while the attacks are still taking place. This gives an administrator the advantage of being able to analyze the techniques being used, source of attacks, and methods used by the hacker.

>>Following are the types of intrusion detection systems :-

1)Host-Based Intrusion Detection System (HIDS): Host-based intrusion detection
systems or HIDS are installed as agents on a host. These intrusion detection systems can look into system and application log files to detect any intruder activity.

2)Network-Based Intrusion Detection System (NIDS): These IDSs detect attacks by capturing and analyzing network packets. Listening on a network segment or
switch, one network-based IDS can monitor the network traffic affecting multiple
hosts that are connected to the network segment, thereby protecting those hosts. Network-based IDSs often consist of a set of single-purpose sensors or hosts placed
at various points in a network. These units monitor network traffic, performing local analysis of that traffic and reporting attacks to a central management console.

 >>Some important topics comes under intrusion detection are as follows :-


1)Signatures: Signature is the pattern that you look for inside a data packet. A signature is used to detect one or multiple types of attacks. For example, the
presence of “scripts/iisadmin” in a packet going to your web server may indicate
an intruder activity. Signatures may be present in different parts of a data packet depending upon the nature of the attack.

2)Alerts: Alerts are any sort of user notification of an intruder activity. When an IDS detects an intruder, it has to inform security administrator about this using alerts.
Alerts may be in the form of pop-up windows, logging to a console, sending e-mail and so on. Alerts are also stored in log files or databases where they can be viewed later on by security experts.

3)Logs: The log messages are usually saved in file.Log messages can be saved
either in text or binary format.

4)False Alarms: False alarms are alerts generated due to an indication that is not
an intruder activity. For example, misconfigured internal hosts may sometimes broadcast messages that trigger a rule resulting in generation of a false alert.
Some routers, like Linksys home routers, generate lots of UPnP related alerts. To
avoid false alarms, you have to modify and tune different default rules. In some
cases you may need to disable some of the rules to avoid false alarms.

5)Sensor: The machine on which an intrusion detection system is running is also called the sensor in the literature because it is used to “sense” the network.


>>SNORT:  


Snort is a very flexible network intrusion detection system that has a large set of pre-configured rules. Snort also allows you to write your own rule set. There are several mailing lists on the internet where people share new snort rules that can counter the latest attacks.

Snort is a modern security application that can perform the following three functions :

* It can serve as a packet sniffer.
* It can work as a packet logger.

* It can work as a Network-Based Intrusion Detection System (NIDS).

TOOLS:
Smooth-Sec 3.0 Intrusion Detection System

Smooth-Sec is a lightweight and fully-ready IDS/IPS (Intrusion Detection/Prevention System) Linux distribution based on Debian 7 (wheezy), available for 32 and 64 bit architecture. The distribution includes the latest version of Snorby, Snort, Suricata, PulledPork and Pigsty. An easy setup process allows to deploy a complete IDS/IPS System within minutes, even for security beginners with minimal Linux experience.
  •     Debian 7 Wheezy based
  •     32 and 64 bit iso available. Snorby V 2.6.2
  •     Snort V 2.9.4.6
  •     Suricata V 1.4.3
  •     Pigsty V 0.1.0
  •     PulledPork V 0.6.1

Download:

32-Bit – smoothsec-3.0-i386.iso
64-Bit – smoothsec-3.0-amd64.iso
Read More

Monday, July 08, 2013

Beginners Guide To Hacking Wireless Networks

Hacking WEP wifi passwords by Nishanth Singamala
Basic Entry into a WEP Encrypted Network

This Tutorial explains EVERYTHING in detail So, it is quite long. Enjoy.

1. Getting the right tools
This Tutorial is in Bt3 But Download The Latest Release Bt4.

Download Backtrack 4. It can be found here:

http://www.backtrack-linux.org/downloads/

 I downloaded the Dvd iso and burned it to a Dvd. Insert your BT4 Dvd/usb drive and reboot your computer into BT4. I always load into the 3rd boot option from the boot menu. (VESA/KDE) You only have a few seconds before it auto-boots into the 1st option so be ready. The 1st option boots too slowly or not at all so always boot from the 2nd or 3rd. Experiment to see what works best for you.

2. Preparing the slave network for attack

Once in BT4, click the tiny black box in the lower left corner to load up a "Konsole" window. Now we must prep your wireless card. 
Type:

airmon-ng

You will see the name of your wireless card. (mine is named "ath0") From here on out, replace "ath0" with the name of your card. 
Now type:

airmon-ng stop ath0

then type:

ifconfig wifi0 down

then:

macchanger --mac 00:11:22:33:44:55 wifi0

then:

airmon-ng start wifi0

What these steps did was to spoof (fake) your mac address so that JUST IN CASE your computeris discovered by someone as you are breaking in, they will not see your REAL mac address. Moving on...
Now it's time to discover some networks to break into.

Type:

airodump-ng ath0

Now you will see a list of wireless networks start to populate. Some will have a better signal than others and it is a good idea to pick one that has a decent signal otherwise it will take forever to crack or you may not be able to crack it at all. 
Once you see the network that you want to crack, do this:

hold down ctrl and type c

This will stop airodump from populating networks and will freeze the screen so that you can see the info that you need.

**Now from here on out, when I tell you to type a command, you need to replace whatever is in parenthesis with what I tell you to from your screen. For example: if i say to type: 
-c (channel) 
then dont actually type in 
-c (channel)
Instead, replace that with whatever the channel number is...so, for example you would type:
-c 6
Can't be much clearer than that...lets continue...

Now find the network that you want to crack and MAKE SURE that it says the encryption for that network is WEP. If it says WPA or any variation of WPA then move on...you can still crack WPA with backtrack and some other tools but it is a whole other ball game and you need to master WEP first.

[Image: airodump.jpg]

Once you've decided on a network, take note of its channel number and bssid. The bssid will look something like this --> 05:gk:30:fo:s9:2n
The Channel number will be under a heading that says "CH".
Now, in the same Konsole window, type:

airodump-ng -c (channel) -w (file name) --bssid (bssid) ath0

the FILE NAME can be whatever you want. This is simply the place that airodump is going to store the packets of info that you receive to later crack. You don't even put in an extension...just pick a random word that you will remember. I usually make mine "wepkey" because I can always remember it. 

**Side Note: if you crack more than one network in the same session, you must have different file names for each one or it won't work. I usually just name them wepkey1, wepkey2, etc.

Once you typed in that last command, the screen of airodump will change and start to show your computer gathering packets. You will also see a heading marked "IV" with a number underneath it. This stands for "Initialization Vector" but in noob terms all this means is "packets of info that contain clues to the password." Once you gain a minimum of 5,000 of these IV's, you can try to crack the password. I've cracked some right at 5,000 and others have taken over 60,000. It just depends on how long and difficult they made the password. 

Now you are thinking, "I'm screwed because my IV's are going up really slowly." Well, don't worry, now we are going to trick the router into giving us HUNDREDS of IV's per second. 

3. Actually cracking the WEP password

Now leave this Konsole window up and running and open up a 2nd Konsole window. In this one type:

aireplay-ng -1 0 -a (bssid) -h 00:11:22:33:44:55 ath0

http://i574.photobucket.com/albums/ss184...eplay1.jpg

This will send some commands to the router that basically cause it to associate with your computer even though you are not officially connected with the password. If this command is successful, you should see about 4 lines of text print out with the last one saying something similar to "Association Successful :-)" If this happens, then good! You are almost there. Now type:

aireplay-ng -3 -b (bssid) -h 00:11:22:33:44:55 ath0

http://i574.photobucket.com/albums/ss184...eplay2.jpg

This will generate a bunch of text and then you will see a line where your computer is gathering a bunch of packets and waiting on ARP and ACK. Don't worry about what these mean...just know that these are your meal tickets. Now you just sit and wait. Once your computer finally gathers an ARP request, it will send it back to the router and begin to generate hundreds of ARP and ACK per second. Sometimes this starts to happen within seconds...sometimes you have to wait up to a few minutes. Just be patient. When it finally does happen, switch back to your first Konsole window and you should see the number underneath the IV starting to rise rapidly. This is great! It means you are almost finished! When this number reaches AT LEAST 5,000 then you can start your password crack. It will probably take more than this but I always start my password cracking at 5,000 just in case they have a really weak password. 

Now you need to open up a 3rd and final Konsole window. This will be where we actually crack the password. Type:

aircrack-ng -b (bssid) (filename)-01.cap

Remember the filename you made up earlier? Mine was "wepkey". Don't put a space in between it and -01.cap here. Type it as you see it. So for me, I would type wepkey-01.cap
Once you have done this you will see aircrack fire up and begin to crack the password. typically you have to wait for more like 10,000 to 20,000 IV's before it will crack. If this is the case, aircrack will test what you've got so far and then it will say something like "not enough IV's. Retry at 10,000." DON'T DO ANYTHING! It will stay running...it is just letting you know that it is on pause until more IV's are gathered. Once you pass the 10,000 mark it will automatically fire up again and try to crack it. If this fails it will say "not enough IV's. Retry at 15,000." and so on until it finally gets it. 

http://i574.photobucket.com/albums/ss184...crack1.jpg

If you do everything correctly up to this point, before too long you will have the password! now if the password looks goofy, dont worry, it will still work. some passwords are saved in ASCII format, in which case, aircrack will show you exactly what characters they typed in for their password. Sometimes, though, the password is saved in HEX format in which case the computer will show you the HEX encryption of the password. It doesn't matter either way, because you can type in either one and it will connect you to the network. 

Take note, though, that the password will always be displayed in aircrack with a colon after every 2 characters. So for instance if the password was "secret", it would be displayed as:
se:cr:et
This would obviously be the ASCII format. If it was a HEX encrypted password that was something like "0FKW9427VF" then it would still display as:
0F:KW:94:27:VF
Just omit the colons from the password, boot back into whatever operating system you use, try to connect to the network and type in the password without the colons and presto! You are in!

It may seem like a lot to deal with if you have never done it, but after a few successful attempts, you will get very quick with it. If I am near a WEP encrypted router with a good signal, I can often crack the password in just a couple of minutes. 

I am not responsible for what you do with this information. Any malicious/illegal activity that you do, falls completely on you because...technically...this is just for you to test the security of your own network. :-)

I will gladly answer any legitimate questions anyone has to the best of my ability.
HOWEVER, I WILL NOT ANSWER ANYONE THAT IS TOO LAZY TO READ THE WHOLE TUT AND JUST ASKS ME SOME QUESTION THAT I CLEARLY ANSWERED. No one wants to hold your hand through this...read the tut and go experiment until you get it right.

There are rare occasions where someone will use WEP encryption with SKA as well. (Shared Key Authentication) If this is the case, additional steps are needed to associate with the router and therefore, the steps I lined out here will not work. I've only seen this once or twice, though, so you probably won't run into it. If I get motivated, I may throw up a tut on how to crack this in the future.
Hacking WEP wifi passwords
By Nishanth Singamala
Read More

Thursday, July 04, 2013

C Program to Print its Own Source Code

C Program to Print its Own Source Code


C Program to Print its Own Source CodeEver wondered how to write a C program to print its own source code? Well, here is the source code of a C program that when executed will print its own source code. In other words, the output of this program is exactly same as its source code.
Here’s the program:
#include<stdio.h>
char *program=”#include<stdio.h>%cchar *program=%c%s%c;%cvoid main()%c{%cprintf(program,10,34,program,34,10, 10,10,10);%c}”;
void main()
{
printf(program,10,34,program,34,10,10,10,10);

}
Read More

Monday, March 25, 2013

How to Hack Windows Administrator Password


How to Hack Windows Administrator Password


How to Hack Windows Admin PasswordThis post will show you how to hack Windows administrator password at times when you forget it or when you want to gain access to a computer for which you do not know the password.
Most of us have experienced a situation where in we need to gain access to a computer which is password protected or at times we may forget the administrator password without which it becomes impossible to log in to the computer. So, if you are somewhat in a same kind of situation, here is an excellent hack using which you can reset the password or make the password empty (remove the password) so that you can gain administrator access to the computer.

Hacking the Windows Admin Password:

You can do this with a small tool called  Offline NT Password & Registry Editor. This utility works offline, that means you need to shut down your computer and boot off your using a floppy disk, CD or USB device (such as pen drive). The tool has the following features:
  • You do not need to know the old password to set a new one.
  • This tool can detect and unlock locked or disabled out user accounts!
  • There is also a registry editor and other registry utilities that works under linux/unix, and can be used for other things than password editing.

How it Works?

Most Windows operating systems stores the login passwords and other encrypted passwords in a file calledsam (Security Accounts Manager). This file can be usually found in \windows\system32\config. This file is a part of Windows registry and remains inaccessible as long as the OS is active. Hence, it is necessary that you boot off your computer and access this sam file via the boot menu. This tool intelligently gains access to this file and will reset/remove the password associated with administrator or any other account.
The download link for both CD and floppy drives along with the complete instructions is given below:
It is recommended that you download the CD version of the tool since the floppy drive is outdated or doesn’t exist in today’s computer. After the download, you’ll get a bootable image which you need to burn it onto a blank CD. Now, boot your computer from this CD and follow the screen instructions to reset the password.

Another Simple Way to Reset Non-Administrator Account Passwords:

Here is another simple way through which you can reset the password of any non-administrator accounts. The only requirement for this is that you need to have administrator privileges. Here is a step-by-step instruction to accomplish this task:
  1. Open the command prompt (Start -> Run -> type cmd -> Enter)
  2. Now type net user and hit Enter
  3. Now the system will show you a list of user accounts on the computer. Say for example, you need to reset the password of the account by name John, then do as follows:
  4. Type net user John * and hit Enter. Now, the system will ask you to enter the new password for the account. That’s it. Now you’ve successfully reset the password for John without knowing his old password.
So, in this way you can reset the password of any Windows account at times when you forget it so that you need not re-install your OS for any reason. I hope this helps
.
Read More

How to Know if Someone Accessed My Computer When I am Away


How to Know if Someone Accessed My Computer When I am Away


Do you have a feeling that someone tried to access your computer when you stepped out for a lunch or quick coffee break? Perhaps your colleague or the person sitting in the next desk tried to log in or play something wicked on your computer while you were away for a quick session.
So, how do you know if someone tried to access your computer in your absence? Well, here is a way by which you get notified every time when such an attempt is made.
MouseLock
The website called MouseLock.co gives a solution here. All you have to do is visit the site’s homepage, sign in to your Gmail account and select your secret point (unlock code) from the screen. Once you do this, you will have to place your mouse cursor into the slot shown and click on it. This will activate the mouse lock feature on your computer screen.
MouseLockED
So, when an unauthorized person tries to move the mouse in your absence, he will be given just a few seconds to select the unlock code. Upon failure to do so, you will get an instant notification about the intrusion in your mailbox.
Email Notification from MouseLock
If you have a webcam attached to your computer, you can even get the photo of the person trying to intrude. This will make it easy for you to figure out who actually was the person.
As this is an easy to use web application, you can use it any time just by loading the MouseLock website without the need to install anything on your computer. Even though MouseLock does not manage to prevent the intrusion, it will give you an instant notification about it, so that you aware of what is happening at your desk when you are away.

How it Works?

MouseLock operates by using the “mouseLeaveEvent” from JQuery to track the mouse movements. On the other hand, it uses the “getUserMedia()” API that is supported by Chrome and Firefox to capture the webcam photographs
.
Read More

How to Hack an Ethernet ADSL Router


How to Hack an Ethernet ADSL Router


Hack ADSL RoutersAlmost half of the Internet users across the globe use ADSL routers/modems to connect to the Internet. However, most of them are unaware of the fact that it has a serious vulnerability in it which can easily be exploited by anyone with a basic knowledge of computer. In this post, I will show you how to hack an Ethernet ADSL router by exploiting the common vulnerability that lies in it.
Every router comes with a username and password using which it is possible to gain access to the router settings and configure the device. The vulnerability actually lies in the Default username and password that comes with the factory settings. Usually the routers come preconfigured from the Internet Service provider and hence the users do not bother to change the password later.
This makes it possible for the attackers to gain unauthorized access to the router and modify its settings using a common set of default usernames and passwords. Here is how you can do it. Before you proceed, you need the following tool in the process:

Hacking the ADSL Router:

Here is a detailed information on how to exploit the vulnerability of an ADSL router:
  1. Go to www.whatismyipaddress.com. Once the page is loaded, you will find your IP address. Note it down.
  2. Open Angry IP Scanner, here you will see an option called IP Range: where you need to enter the range of IP address to scan for.
  3. Suppose your IP is 117.192.195.101, you can set the range something as 117.192.194.0 to 117.192.200.255so that there exists at least 200-300 IP addresses in the range.
  4. Go to Tools->Preferences and select the Ports tab. Under Port selection enter 80 (we need to scan for port 80). Now switch to the Display tab, select the option “Hosts with open ports only” and click on OK.
  5. IP Scanner Settings
    I have used Angry IP Scanner v3.0 beta-4. If you are using a different version, you need to Go to Optionsinstead of Tools
  6. Now click on Start. After a few minutes, the IP scanner will show a list of IPs with Port 80 open as shown in the below image:
  7. Angry IP Scanner
  8. Now copy any of the IP from the list, paste it in your browser’s address bar and hit enter. A window will popup asking for username and password. Since most users do not change the passwords, it should most likely work with the default username and password. For most routers the default username-passwordpair will be admin-admin or admin-password.
Just enter the username-password as specified above and hit enter. If you are lucky you should gain access to the router settings page where you can modify any of the router settings. The settings page can vary from router to router. A sample router settings page is shown below:
Router Settings Page Hacked!
If you do not succeed to gain access, select another IP from the list and repeat the step-5. At least 1 out of 5 IPs will have a default password and hence you will surely be able to gain access.

What can a Hacker do by Gaining Access to the Router Settings?

By gaining access to the router settings, it is possible for an attacker to modify any of the router settings which results in the malfunction of the router. As a result the target user’s computer will be disconnected from the Internet. In the worst case the attacker can copy the ISP login details from the router to steal the Internet connection or even hijack the DNS by pointing it at a rouge DNS server. If this happens, the victim will have to reconfigure/reset the router settings in order to bring it back to normal.

The Verdict:

If you are using an ADSL router to connect to the Internet, it is highly recommended that you immediately change your password to prevent any such attacks in the future. Who knows, you may be the next victim of such an attack.
Since the configuration varies from router to router, you need to contact your ISP for details on how to change the password for your model.
Warning!
All the information provided in this post are for educational purposes only. Please do not use this information for illegal purposes
.
Read More

Block or Redirect Unwanted Websites Using HOSTS File


Block or Redirect Unwanted Websites Using HOSTS File


Block Websites Using Hosts FileThe hosts file is one of the interesting and useful feature of both Windows and Linux operating systems that provides many handy options in addressing network nodes. For instance, you can use the hosts file to block annoying ads, pop-ups, banners, porn sites, or even redirect one website to another.
In this post I will show you how to play around with the hosts file to accomplish some of the above mentioned jobs.

What is a hosts File?

The hosts file is just like any other computer file that is used by the operating system to map hostnames and domain names on to their corresponding IP addresses.
In other words, when you type “google.com” on your browser’s address bar, your computer will look for thehosts file to see if it contains the corresponding IP address for the domain name you typed (google.com). In case if no entry is present in the hosts file, the request is then passed on to the DNS (Domain Name System) server to obtain the IP address.

hosts File vs. DNS

When it comes to resolving the hostnames, the hosts file is given the first priority over the Domain Name System. In most cases, the hosts file remains unconfigured on the operating system and hence the DNS is used by the computer to resolve the domain names to their corresponding IP addresses.
However, if the hosts file is found to contain a valid entry for a given hostname or domain name, then this is picked up and used by the operating system.

Where is the hosts File Located?

Windows: In case of the Windows operating system, the hosts file is located at:
%systemroot%\system32\drivers\etc\hosts
NOTE: In most cases this should be: C:\Windows\System32\drivers\etc\hosts
Unix/Linux: In case of Linux it is located at:
/etc/hosts

How to Block a Website?

To block a specific website, all you have to do is just add a new entry for that site in the hosts file. I would prefer to backup the original file and create a new one instead of modifying it. So, if something goes wrong, you can just delete it and restore the original one! Well, here is a step-by-step procedure on how to create a new hostsfile on Windows:
  1. Go to “My Computer” and you should see the “Menu bar” on top. In case of Vista and Win 7, just click “Alt” to unhide the “Menu bar”.
  2. Now in the menu bar, click on “Tools -> Folder Options”. In the “View” tab uncheck the option that says: “Hide extensions for known file types” and click on “OK”.
Windows Folder Options
  1. Open a new text pad (New Text Document.txt) and rename it to: hosts. You will get a pop-up message with a warning. Just click on “Yes”.
    Please note that the renamed file hosts should not have any extension such as hosts.txt.
  2. Open the hosts file using the notepad. Now let us assume that you want to block the sites Facebook andYoutube on your computer. For this all you have to do is add the following lines to your hosts file:
    127.0.0.1       facebook.com
    127.0.0.1       www.facebook.com
    127.0.0.1       youtube.com
    127.0.0.1       www.youtube.com
    Each entry should be placed on an individual line. The IP address and the hostname should be separated by a space or a tab. In this way, you can block any given website by just pointing it to the IP address 127.0.0.1.
  3. Navigate to %systemroot%\system32\drivers\etc. Here you should see the original hosts file, rename it to hosts_bak. Just copy and paste the new hosts file that you have created. That’s it. You’ve now successfully blocked those websites from loading on your computer.
    If you are using Vista/Win 7 you may have to take ownership of the original hosts file before renaming it.

How to Redirect a Website?

Suppose you want to redirect Friendster.com to Google.com, all you have to do is just add the following lines to your hosts file:
74.125.236.72       friendster.com
74.125.236.72       www.friendster.com
Here 74.125.236.72 is the IP address of Google.com. To find out the IP address of any given website, just go to command prompt and ping it. For example: ping google.com. You should get a ping response that displays the IP address as shown below:
Ping Test
From now on, whenever you type “friendster.com” on your browser, you will be redirected to “google.com”.

How does a hosts File work?

Whenever you block a website using the hosts file, you point it to the IP address 127.0.0.1 which in fact is the IP address of your own computer. In other words, the IP 127.0.0.1 points to your own computer and doesn’t exist outside.
So, whenever you type the URL of a website for which an entry is present in the hosts file, your computer will load the IP as 127.0.0.1 instead of the actual one and tries to establish a connection with this IP address (127.0.0.1) but fails. As a result the website doesn’t load at all.
The redirection of the website works by pointing the domain name of one website to the IP address of another website (as configured by the hosts file) instead of its original IP address. So, whenever you type friendster.com, it is pointed to Google.com’s IP address and thus, the Google page loads up instead of the actual page from friendster.com.

How to Block the Annoying Ads?

I have found a great solution to keep all the annoying ads, banners, pop-ups and other parasites at bay by using a pre-configured hosts called MVPS hosts file. This hosts file contains a long list of entries to block all those annoying ads and pop-ups that usually load while you are surfing the Internet. You can also receive regular updates on this to stay up-to-date. You can download MVPS hosts file from the link below:
If you are playing around with the hosts file and something goes wrong, just delete the hosts file itself and rename the original file from hosts_bak to hosts. This should bring back everything to normal. I hope this post on hosts file will help you block unwanted websites on your computer. Waiting for your comments.
:)
Read More