From 486f9d1017e8224e2e52529e249192a42b3781d8 Mon Sep 17 00:00:00 2001 From: Benjamyn Love Date: Tue, 20 Mar 2018 03:42:07 +1100 Subject: [PATCH] added colours and made them configurable --- config.json | 6 +++++- libs/colours.py | 23 +++++++++++++++++++++++ libs/colours.pyc | Bin 0 -> 800 bytes main.py | 35 ++++++++++++++++++++++------------- 4 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 libs/colours.py create mode 100644 libs/colours.pyc diff --git a/config.json b/config.json index b626256..8ee6940 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,8 @@ { "subdomains":["www", "mail", "ftp"], - "dnsrecords":["A", "AAAA", "MX", "TXT", "NS", "SOA"] + "dnsrecords":["A", "AAAA", "MX", "TXT", "NS", "SOA"], + "colour_attn":"red", + "colour_good":"green", + "colour_pretty":"blue", + "colour_default":"reset" } diff --git a/libs/colours.py b/libs/colours.py new file mode 100644 index 0000000..757faf6 --- /dev/null +++ b/libs/colours.py @@ -0,0 +1,23 @@ +# Adds colours class + +class bcolours: + RED = "\033[1;31m" + BLUE = "\033[1;34m" + CYAN = "\033[1;36m" + GREEN = "\033[0;32m" + RESET = "\033[0;0m" + BOLD = "\033[;1m" + REVERSE = "\033[;7m" + +def getColour(colour): + colour = colour.lower() + if colour == "red": + return bcolours.RED + if colour == "blue": + return bcolours.BLUE + if colour == "cyan": + return bcolours.CYAN + if colour == "green": + return bcolours.GREEN + if colour == "reset": + return bcolours.RESET diff --git a/libs/colours.pyc b/libs/colours.pyc new file mode 100644 index 0000000000000000000000000000000000000000..59351a1c3b6357ae0e08ea9ac344ea423a6936c5 GIT binary patch literal 800 zcmaJ<-7dsH6h3XYUBpjB;>HD+y<#olVnwhfZe%4>gmKZ>?L^RSr866maK-z02Jhi5 zynu7gEGr_~p40Dqo%uTRoe4gsCf?p(RS$+&fbSg)vxF(brv{k^F96Q~=L&0|3gtl- zKoW;I$c|y^_R72*ROVa9LvjzpG%;y61G7(RDj*q!$^od5exV}BLQr+cB2Z%>lekWE zDJ@*Aw$@gQ5nlg+H@XxYp66|;qlZ_oVqtY2~vzrezgWkhspUt?cw05Y{MqBO| zf5^*wUGW|z+euzZvQLt%B(GxHp{3Hf^1ok}+IFRFn@`vz7G@q3c$0Y7e?`Y>k$r9r Yvxr9ejQ(m0AB!z_5VpBFBr!Ms3B1CAxBvhE literal 0 HcmV?d00001 diff --git a/main.py b/main.py index 560582b..35d3d9b 100755 --- a/main.py +++ b/main.py @@ -10,11 +10,24 @@ from ipwhois.net import Net from ipwhois.asn import IPASN from pprint import pprint from libs import config +from libs import colours as gc running = 1 prompt = ': ' indent = '~ ' -whoisrecs = ["NotFound", "DomainName", "Registrar", "Status", "UpdatedDate", "CreationDate", "ExpirationDate", "RegistrantName", "EligibilityName", "EligibilityType", "EligibilityID", "NameServer"] +whoisrecs = ["NotFound", "DomainName", "Registrar", "Status", "UpdatedDate", "CreationDate", "ExpirationDate", "RegistrantName", "RegistrantEmail", "EligibilityName", "EligibilityType", "EligibilityID", "NameServer"] + +# Loaded from the config file +jsonData = config.readConf() + +subdomains = jsonData["subdomains"] +dnsrecords = jsonData["dnsrecords"] +colour_attn = gc.getColour(jsonData["colour_attn"]) +colour_good = gc.getColour(jsonData["colour_good"]) +colour_pretty = gc.getColour(jsonData["colour_pretty"]) +colour_default = gc.getColour(jsonData["colour_default"]) + +# Endconfig block def domainWhois(inData): whoisData = whois.whois(inData).query() @@ -28,7 +41,13 @@ def printWhois(resultData): for x in range(0, len(whoisrecs)): try: for item in resultData[whoisrecs[x]]: - print(indent + '%s: %s' % (whoisrecs[x], item)) + if whoisrecs[x] == "Status": + if "ok" in item or "OK" in item: + print(indent + colour_good + '%s: %s' % (whoisrecs[x], item) + colour_default) + else: + print(indent + colour_attn + '%s: %s' % (whoisrecs[x], item) + colour_default) + else: + print(indent + '%s: %s' % (whoisrecs[x], item)) except Exception as e: pass @@ -57,7 +76,7 @@ def recLookup(inData): for dnsrec in dnsrecords: try: for rdata in dns.resolver.query(inData, dnsrec): - print( indent + "%s:\t%s" % (dnsrec, rdata)) + print( indent + colour_pretty + "%s:\t%s%s" % (dnsrec, colour_good, rdata) + colour_default) except Exception as e: pass @@ -88,15 +107,5 @@ def checkIfIP(in1): signal.signal(signal.SIGINT, signal_handler) -## -# Add more params to the config file -# Like indent/prompts etc -## - -jsonData = config.readConf() -#pprint(jsonData) -subdomains = jsonData["subdomains"] -dnsrecords = jsonData["dnsrecords"] - while running == 1: parseInput(raw_input("\nPlease Enter a domain" + prompt) )