added colours and made them configurable
This commit is contained in:
parent
dc51287f7b
commit
486f9d1017
@ -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"
|
||||
}
|
||||
|
||||
23
libs/colours.py
Normal file
23
libs/colours.py
Normal file
@ -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
|
||||
BIN
libs/colours.pyc
Normal file
BIN
libs/colours.pyc
Normal file
Binary file not shown.
35
main.py
35
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) )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user