daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top