Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import sys
  3.  
  4. number_of_args = len(sys.argv)
  5. f = open("/etc/hosts", "a+")
  6.  
  7. for i in range(number_of_args - 1):
  8. f.write("127.0.0.1 %s\n" % sys.argv[i + 1])
  9.  
  10. # To use:
  11. # 1. Add this code to a file
  12. # 2. Make executable: `chmod +x your-file-name`
  13. # 3. Run as sudo and provide all sites you want to block
  14. # as space separated arguments
  15. # e.g. `sudo ./modify_hosts twitter.com facebook.com reddit.com`
  16.  
  17. # To disable:
  18. # 1. Manually edit /etc/hosts and comment out the lines that include
  19. # the hostnames you provided in the setup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement