Created
April 15, 2020 02:21
-
-
Save greenmind-sec/beb8b25ba526bbd3053b998e2f967bc8 to your computer and use it in GitHub Desktop.
Test auto /etc/hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from python_hosts import Hosts, HostsEntry | |
hosts = Hosts(path='/etc/hosts') | |
- 'ipv4','10.10.10.10','wiki.hackerlab.com' | |
- 'ipv4','10.10.10.11','blog.hackerlab.com' | |
- 'ipv4','10.10.10.12','www.hackerlab.com' | |
- 'ipv4','10.10.10.13','db.hackerlab.com' | |
- 'ipv4','10.10.10.14','mail.hackerlab.com' | |
#entry_type='ipv4', address='10.10.10.10', names=['wiki.hackerlab.com'] | |
def add_host(type,address,names): | |
new_entry = HostsEntry(entry_type=type, address=address, names=[names]) | |
hosts.add([new_entry]) | |
hosts.write() | |
def del_host(address): | |
hosts.remove_all_matching(address=address) | |
hosts.write() | |
#add_host(type,address,names) | |
#del_host(address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment