This really needs to be refactored, completely. I will start work on DNS-py2: Electric Boogaloo on my nightshifts

This commit is contained in:
Benjamyn Love 2018-02-25 14:50:07 +11:00
parent dc5769a819
commit 1b26c0f7b1
3 changed files with 25 additions and 6 deletions

Binary file not shown.

View File

@ -137,18 +137,19 @@ def options(inputs):
def iterate(inArray, pre): def iterate(inArray, pre):
count = 0 count = 0
while count != len(inArray) - 1: while count != len(inArray) - 1:
print pre
#print checkIfIP(inArray[count].split('.')) #print checkIfIP(inArray[count].split('.'))
if pre == "TXT" or pre == "SOA": if pre == "TXT" or pre == "SOA":
print indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET print indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET
else: else:
if checkIfIP(inArray[count].split('.')) == 0: if checkIfIP(inArray[count].split('.')) == 0:
tmpVal = isCNAME(inArray[count]) tmpVal = isCNAME(inArray[count])
recordDict[pre] = pre, inArray[count], tmpVal[0] recordDict[pre + str(count)] = pre, inArray[count], tmpVal[0]
#recordDict[pre] = indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET + " -> " + bcolors.GREEN + tmpVal[0] + bcolors.RESET #recordDict[pre] = indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET + " -> " + bcolors.GREEN + tmpVal[0] + bcolors.RESET
#print indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET + " -> " + bcolors.GREEN + tmpVal[0] + bcolors.RESET #print indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET + " -> " + bcolors.GREEN + tmpVal[0] + bcolors.RESET
else: else:
recordDict[pre] = pre, inArray[count] recordDict[pre + str(count)] = pre, inArray[count]
#recordDict[pre] = indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET #recordDict[pre] = indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET
#print indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET #print indent + bcolors.CYAN + pre, bcolors.GREEN + inArray[count] + bcolors.RESET
count = count + 1 count = count + 1
@ -208,7 +209,7 @@ def dig(inDomain, record):
#print str(e) #print str(e)
print "========================================================" print "========================================================"
test = dig.split("\n") test = dig.split("\n")
iterate(test, record) #iterate(test, record)
return test return test
def newdig(inDomain, record, sub=""): def newdig(inDomain, record, sub=""):
@ -298,7 +299,7 @@ while running == 1:
if sub != "": if sub != "":
tmpDom = sub + "." + inInput tmpDom = sub + "." + inInput
subRec, subType, subDomain = newdig(tmpDom, "A", sub) subRec, subType, subDomain = newdig(tmpDom, "A", sub)
iterate(subRec, subDomain) #iterate(subRec, subDomain)
for rec in rec2check: for rec in rec2check:
if rec != "": if rec != "":
if rec == "MX": if rec == "MX":
@ -307,8 +308,8 @@ while running == 1:
else: else:
dnsRec, dnsType, blank = newdig(inInput, rec) dnsRec, dnsType, blank = newdig(inInput, rec)
iterate(dnsRec, dnsType) iterate(dnsRec, dnsType)
#pprint(recordDict) print(recordDict)
#for data in recordDict: #for data in recordDict:
# print recordDict[data] # print recordDict[data]
printDict(recordDict) #printDict(recordDict)
print '\n' print '\n'

18
notes.txt Normal file
View File

@ -0,0 +1,18 @@
## NOTES
# I am an idiot
# {'A': ('A', '172.217.25.142'), 'mail': ('mail', '172.217.25.133'), 'www': ('www', '172.217.25.132')}
# ~ MX 10 aspmx.l.google.com. -> 108.177.97.26
# ~ MX 30 alt2.aspmx.l.google.com. -> 74.125.201.26
# ~ MX 50 alt4.aspmx.l.google.com. -> 173.194.175.26
# ~ MX 20 alt1.aspmx.l.google.com. -> 64.233.168.26
# ~ MX 40 alt3.aspmx.l.google.com. -> 173.194.219.27
# ~ TXT "docusign=05958488-4752-4ef2-95eb-aa7ba8a3bd0e"
# ~ TXT "v=spf1 include:_spf.google.com ~all"
# {'A': ('A', '172.217.25.142'), 'mail': ('mail', '172.217.25.133'), 'www': ('www', '172.217.25.132')}
# {'A': ('A', '172.217.25.142'), 'mail': ('mail', '172.217.25.133'), 'www': ('www', '172.217.25.132'), 'NS': ('NS', 'ns3.google.com.', '216.239.36.10')}
# {'A': ('A', '172.217.25.142'), 'mail': ('mail', '172.217.25.133'), 'www': ('www', '172.217.25.132'), 'NS': ('NS', 'ns3.google.com.', '216.239.36.10')}
# ~ SOA ns1.google.com. dns-admin.google.com. 186901781 900 900 1800 60
# {'A': ('A', '172.217.25.142'), 'mail': ('mail', '172.217.25.133'), 'www': ('www', '172.217.25.132'), 'NS': ('NS', 'ns3.google.com.', '216.239.36.10')}
There are mutiple records added, i need a unique indentifier :(
Maybe just a counter or something #nfi