Skip to content

Commit

Permalink
creates a way to clean duplicate IP's out of the hosts file from the …
Browse files Browse the repository at this point in the history
…terminal
  • Loading branch information
Ekultek committed Apr 30, 2019
1 parent 5f5954a commit aea40a7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 0 additions & 1 deletion api_calls/honeyscore_hook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import requests
from bs4 import BeautifulSoup


class HoneyHook(object):
Expand Down
2 changes: 1 addition & 1 deletion lib/banner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import random

VERSION = "3.1.2"
VERSION = "3.1.3"


def banner_1(line_sep="#--", space=" " * 30):
Expand Down
1 change: 1 addition & 0 deletions lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def complete_text(self, text, state):
tokens/reset Reset API tokens if needed
external View loaded external commands
ver[sion] View the current version of the program
clean/clear Clean the hosts.txt file of duplicate IP addresses
help/? Display this help
"""

Expand Down
23 changes: 23 additions & 0 deletions lib/term/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class object for the main terminal of the program
"reset", "tokens",
# show the version number
"ver", "version",
# clean the hosts file of duplicate IP's
"clean", "clear",
# easter eggs!
"idkwhatimdoing", "ethics", "skid"
]
Expand Down Expand Up @@ -148,6 +150,25 @@ def do_terminal_command(self, command):
"""
lib.settings.cmdline(command, is_msf=False)

def do_clean_hosts(self):
"""
Clean the hosts.txt file of any duplicate IP addresses
"""
retval = set()
current_size = len(self.loaded_hosts)
for host in self.loaded_hosts:
retval.add(host)
cleaned_size = len(retval)
with open(lib.settings.HOST_FILE, 'w') as hosts:
for item in list(retval):
hosts.write(item)
if current_size != cleaned_size:
lib.output.info("cleaned {} duplicate IP address(es) (total of {})".format(
current_size - cleaned_size, cleaned_size
)
)
self.__reload()

def do_token_reset(self, api, token, username):
"""
Explanation:
Expand Down Expand Up @@ -475,6 +496,8 @@ def terminal_main_display(self, tokens, extra_commands=None, save_history=True):
self.do_view_gathered()
elif any(c in choice for c in ("ver", "version")):
self.do_show_version_number()
elif any(c in choice for c in ("clean", "clear")):
self.do_clean_hosts()
elif "single" in choice:
try:
if "help" in choice_data_list:
Expand Down

0 comments on commit aea40a7

Please sign in to comment.