fixes an issue where if you run in verbose mode with whois lookup it will error out if certain information is not found (issue #128), it will now display the JSON data if you run in verbose mode

This commit is contained in:
ekultek 2017-10-31 09:47:49 -05:00
parent 04cd49e722
commit 99575425f1
3 changed files with 33 additions and 63 deletions

View file

@ -1,4 +1,4 @@
1627b4ccf4cbc52b7408d7cde3c2a5e1 ./zeus.py
7997f139b079d2ba625f7fdd79a82ca4 ./zeus.py
6ad5f22ec4a6f8324bfb1b01ab6d51ec ./etc/scripts/cleanup.sh
155c9482f690f1482f324a7ffd8b8098 ./etc/scripts/fix_pie.sh
0e435c641bc636ac0b3d54e032d9cf6a ./etc/scripts/install_nmap.sh
@ -35,7 +35,7 @@ d41d8cd98f00b204e9800998ecf8427e ./lib/attacks/__init__.py
d93cf7cdeabe951251f2f4d56687b5f4 ./lib/attacks/sqlmap_scan/__init__.py
5e5bb575014ebe613db6bf671d008cf8 ./lib/attacks/sqlmap_scan/sqlmap_opts.py
d41d8cd98f00b204e9800998ecf8427e ./lib/attacks/whois_lookup/__init__.py
f27322b9716e1a2b0b0b0487f3149474 ./lib/attacks/whois_lookup/whois.py
82afab0e65ac90cfcde4bd274066939e ./lib/attacks/whois_lookup/whois.py
96fc5b718e60e5e9c82b1a0e38170d29 ./lib/attacks/admin_panel_finder/__init__.py
23c1e5e934029f9acc89d2c95e7748e7 ./lib/attacks/xss_scan/__init__.py
27358f26bda30d7356143c3ea1fa99c5 ./lib/attacks/nmap_scan/__init__.py

View file

@ -9,7 +9,7 @@ from lib.core.settings import (
write_to_log_file,
WHOIS_RESULTS_LOG_PATH,
logger, set_color,
replace_http
replace_http, prompt
)
@ -52,54 +52,51 @@ def gather_raw_whois_info(domain):
return _json_data
def _pretty_print_json(data, sort=True, indentation=4):
return json.dumps(data, sort_keys=sort, indent=indentation)
def get_interesting(raw_json):
"""
return the interesting aspects of the whois lookup from the raw JSON data
"""
nameservers = raw_json["nameservers"]
user_contact = raw_json["contacts"]
admin_info = raw_json["contacts"]["admin"]
reg_info = raw_json["registrar"]
return nameservers, user_contact, admin_info, reg_info
return nameservers, user_contact, reg_info
def human_readable_display(domain, interesting, raw, show_readable=False):
def human_readable_display(domain, interesting):
"""
create a human readable display from the given whois lookup
"""
if show_readable:
contact_dict = dict(interesting[1])
print(" |--[!] Domain: {} (organization '{}')".format(domain, contact_dict["owner"][0]["organization"]))
print(" | |--[!] Found nameservers (total {})".format(len(interesting[0])))
if len(interesting[0]) > 1:
for i, server in enumerate(interesting[0], start=1):
print(" | | |--[{}]--- {}".format(i, server))
else:
print(" | | |--{}".format("".join(interesting[0])))
if contact_dict["owner"][0]["name"] is not None or "":
print(" | |--[!] Contact name found: {}".format(contact_dict["owner"][0]["name"]))
if contact_dict["owner"][0]["phone"] != "" or None:
print(" | | |-- Phone number: {}".format(contact_dict["owner"][0]["phone"]))
else:
print(" | | |-- No phone number revealed")
else:
print(" [x] No contact owner revealed")
if len(contact_dict["admin"]) > 0:
print(" | |--[!] Total admins found {}".format(len(contact_dict["admin"])))
for i, admin in enumerate(contact_dict["admin"]):
print(" | | |--[{}]--- {}".format(i, admin))
else:
print(" | |--[x] No administrators revealed")
return write_to_log_file(raw, WHOIS_RESULTS_LOG_PATH, "whois-log-{}.json")
data_sep = "-" * 30
servers, contact, reg = interesting
total_servers, total_contact, total_reg = len(servers), len(contact), len(reg)
print(data_sep)
print("[!] Domain {}".format(domain))
if total_servers > 0:
print("[!] Found a total of {} servers".format(total_servers))
print(_pretty_print_json(servers))
else:
return write_to_log_file(raw, WHOIS_RESULTS_LOG_PATH, "whois-log-{}.json")
print("[x] No server information found")
if total_contact > 0:
print("[!] Found contact information")
print(_pretty_print_json(contact))
else:
print("[x] No contact information found")
if total_reg > 0:
print("[!] Found register information")
print(_pretty_print_json(reg))
else:
print("[x] No register information found")
print(data_sep)
def whois_lookup_main(domain, **kwargs):
"""
main function
"""
readable = kwargs.get("readable", False)
verbose = kwargs.get("verbose", False)
domain = replace_http(domain)
logger.info(set_color(
@ -113,36 +110,11 @@ def whois_lookup_main(domain, **kwargs):
"gathering interesting information..."
))
interesting_data = get_interesting(raw_information)
if readable:
if verbose:
for data in interesting_data:
if len(data) != 0 or None:
logger.debug(set_color(
"found '{}'...".format(data), level=10
))
if verbose:
try:
return human_readable_display(domain, interesting_data, raw_information, show_readable=True)
human_readable_display(domain, interesting_data)
except (ValueError, Exception):
logger.fatal(set_color(
"unable to display any information from WhoIs lookup on domain '{}'...".format(domain), level=50
))
else:
if verbose:
for data in interesting_data:
if isinstance(data, dict):
for v in data.itervalues():
if len(v) != 0 or v is not None:
logger.debug(set_color(
"found '{}'...".format(v), level=10
))
elif isinstance(data, list):
if len(data) != 0:
logger.debug(set_color(
"found '{}'...".format(data), level=10
))
try:
return human_readable_display(domain, interesting_data, raw_information)
except (ValueError, Exception):
logger.fatal(set_color(
"unable to find any information on '{}' from WhoIs lookup...".format(domain), level=50
))
write_to_log_file(raw_information, WHOIS_RESULTS_LOG_PATH, "{}-whois.json".format(domain))

View file

@ -92,8 +92,6 @@ if __name__ == "__main__":
help="Run an XSS scan on the found URL's")
attacks.add_option("-w", "--whois-lookup", dest="performWhoisLookup", action="store_true",
help="Perform a WhoIs lookup on the provided domain")
attacks.add_option("--show-readable", dest="showReadableOutput", action="store_true",
help="Show human readable output from the WhoIs lookup")
attacks.add_option("--sqlmap-args", dest="sqlmapArguments", metavar="SQLMAP-ARGS",
help="Pass the arguments to send to the sqlmap API within quotes & "
"separated by a comma. IE 'dbms mysql, verbose 3, level 5'")
@ -330,7 +328,7 @@ if __name__ == "__main__":
)
elif whois:
whois_lookup_main(
url, verbose=opt.runInVerbose, readable=opt.showReadableOutput
url, verbose=opt.runInVerbose
)
else:
pass