Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import sys
- number_of_args = len(sys.argv)
- f = open("/etc/hosts", "a+")
- for i in range(number_of_args - 1):
- f.write("127.0.0.1 %s\n" % sys.argv[i + 1])
- # To use:
- # 1. Add this code to a file
- # 2. Make executable: `chmod +x your-file-name`
- # 3. Run as sudo and provide all sites you want to block
- # as space separated arguments
- # e.g. `sudo ./modify_hosts twitter.com facebook.com reddit.com`
- # To disable:
- # 1. Manually edit /etc/hosts and comment out the lines that include
- # the hostnames you provided in the setup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement