Skip to content

Instantly share code, notes, and snippets.

@greenmind-sec
Created April 15, 2020 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenmind-sec/beb8b25ba526bbd3053b998e2f967bc8 to your computer and use it in GitHub Desktop.
Save greenmind-sec/beb8b25ba526bbd3053b998e2f967bc8 to your computer and use it in GitHub Desktop.
Test auto /etc/hosts
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