hacking tutorials - Hack browser to block websites - hacker - ethical hacking - learn hacking - ethical hacking tutorials



  • Let’s see a virus program to block the listed websites in the companies. On execution of this exe file (Compiled C program), automatically the machine is locked for some of the websites which is listed in the code.
  • The below virus program makes you to write the list of websites to block in the hosts file located in system32 folder of windows operating system.

What is hosts file ?

  • Hosts file in windows helps the computer to identify which websites should be blocked and which websites should be permitted.

C programming Code :

#include
#include
#include
char website_list[6][30]={
“google.com”,
“www.google.com”,
“youtube.com”,
“www.youtube.com”,
“facebook.com”,
“www. facebook.com”
};
char ip[12]=”127.0.0.1″;
FILE *target;
int find_website_path(void);
void website_block(void);
int find_website_path()
{
int done;
struct ffblk ffblk;//File block structure
done=findfirst(”C:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done==0)
{
target=fopen(”C:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(”D:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done==0)
{
target=fopen(”D:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(”E:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done==0)
{
target=fopen(”E:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(”F:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done==0)
{
target=fopen(”F:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);
/*to open the file*/
return 1;
}
else return 0;
}
void website_block()
{
int i;
fseek(target,0,SEEK_END); /*to move to the end of the file*/
fprintf(target,”\n”);
for(i=0;i<6;i++)
fprintf(target,”%s\t%s\n”,ip,website_list[i]);
fclose(target);
}
void main()
{
int success=0;
success=find_website_path();
if(success)
website_block();
}



click below button to copy the code. By Ethical hacking tutorial team

Steps to execute the program

  • Save the above code as website_block.c Compile the above c programming code with the C/C++ compiler.
  • On Running this program (You should run as an administrator so that, modify the hosts needs administrator account). To test, run the code or execute the code exe (website_block.exe) file. It will block the sites that is listed in the above c program code.
hack browser

Learn ethical-hacking - ethical-hacking tutorial - hack browser - ethical-hacking examples - ethical-hacking programs

  • Once you run the file website_block.exe, restart your browser program.Then, type the URL of the blocked site and you’ll see the browser showing error “Page cannot displayed“.
  • To remove the virus type the following the Run. %windir%\system32\drivers\etc
  • There, open the file named “hosts” using the notepad. At the bottom of the opened file you’ll see something like this
    • 127.0.0.1---------google.com
Hack browser to block websites

Learn ethical-hacking - ethical-hacking tutorial - Hack browser to block websites - ethical-hacking examples - ethical-hacking programs

  • In case, if you want to revoke the changes. Delete all such entries which contain the names of blocked sites.

Related Searches to Hack browser to block websites