Advertisement
Guest User

Untitled

a guest
Jul 31st, 2016
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $host_file_path = "C:\windows\system32\drivers\etc\hosts_tmp"
  2. $final_loc = "C:\windows\system32\drivers\etc\hosts"
  3. $tmp_file_holder = ".\current_list.bk"
  4. $reroute = "127.0.0.1"
  5.  
  6. $Host_File_header = "# Copyright (c) 1993-2009 Microsoft Corp.
  7. #
  8. # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
  9. #
  10. # This file contains the mappings of IP addresses to host names. Each
  11. # entry should be kept on an individual line. The IP address should
  12. # be placed in the first column followed by the corresponding host name.
  13. # The IP address and the host name should be separated by at least one
  14. # space.
  15. #
  16. # Additionally, comments (such as these) may be inserted on individual
  17. # lines or following the machine name denoted by a '#' symbol.
  18. #
  19. # For example:
  20. #
  21. #      102.54.94.97     rhino.acme.com          # source server
  22. #       38.25.63.10     x.acme.com              # x client host
  23.  
  24. # localhost name resolution is handled within DNS itself.
  25. #   127.0.0.1       localhost
  26. #   ::1             localhost"
  27.  
  28. echo "$Host_File_header" > $host_file_path
  29.  
  30. $domain_list = invoke-webrequest http://mirror1.malwaredomains.com/files/domains.txt | select -expandproperty content
  31. $domain_list -replace "`t", ";" -replace ";;" >  $tmp_file_holder
  32. $domain_content = get-content $tmp_file_holder
  33. foreach($line in $domain_content){
  34.     if(-not($line | select-string "#")) {
  35.     $line_tmp = $line -split ";"
  36.     $line = $line_tmp[0]
  37.     echo "$reroute        $line" >> $host_file_path
  38.     }
  39. }
  40.  
  41. move-item $host_file_path $final_loc -force
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement