120 lines
3.4 KiB
Python
Executable File
120 lines
3.4 KiB
Python
Executable File
import subprocess
|
|
import re # YAY REVERSE ENGINEER... wait its just regex
|
|
|
|
#Made this work with linux magic, test
|
|
|
|
inInput = ""
|
|
partDomain = ""
|
|
running = 1
|
|
pingOn = "P"
|
|
whoOn = "W"
|
|
phrases = ["ping", "whois", "quit", "clear", "help"]
|
|
|
|
def printHelp():
|
|
print "========================================================"
|
|
print "= help - This screen ="
|
|
print "= clear - Clears the screen ="
|
|
print "= ping - Enables/Disables pinging the IP Address ="
|
|
print "========================================================"
|
|
print "========================================================"
|
|
|
|
def checkPhrase(inputs):
|
|
for word in phrases:
|
|
if inputs == word:
|
|
options(inputs)
|
|
return 1
|
|
return 0
|
|
|
|
def options(inputs):
|
|
global whoOn
|
|
global pingOn
|
|
|
|
if inputs == "ping":
|
|
if pingOn == "P":
|
|
pingOn = "p"
|
|
else:
|
|
pingOn = "P"
|
|
if inputs == "whois":
|
|
if whoOn == "W":
|
|
whoOn = "w"
|
|
else:
|
|
whoOn = "W"
|
|
if inputs == "clear":
|
|
subprocess.call("clear")
|
|
if inputs == "help":
|
|
printHelp()
|
|
|
|
def iterate(inArray, pre):
|
|
count = 0
|
|
while count != len(inArray) - 1:
|
|
print pre, inArray[count]
|
|
count = count + 1
|
|
|
|
def whois(inDomain):
|
|
lookup = subprocess.check_output(["whois", inDomain])
|
|
print "========================================================"
|
|
test = lookup.split("\n")
|
|
iterate(test, "")
|
|
|
|
def dig(inDomain, record):
|
|
dig = subprocess.check_output(["dig", record, "+short", inDomain])
|
|
print "========================================================" #ADD REST OF DIGS
|
|
test = dig.split("\n")
|
|
#print record, test[0]
|
|
iterate(test, record) #fix up mutiple record types...
|
|
|
|
def ipLookup(inDomain):
|
|
host = "N/A"
|
|
ipLook = subprocess.check_output(["geoiplookup", inDomain])
|
|
try:
|
|
host = subprocess.check_output(["host", inDomain]) #Do exit status check...
|
|
returncode = 0
|
|
except subprocess.CalledProcessError as e:
|
|
output = e.output
|
|
returncode = e.returncode
|
|
|
|
print '\n', ipLook, '\n', "PTR: ", host
|
|
|
|
def ipPing(inDomain):
|
|
ping = subprocess.call(["ping", "-c 2", inDomain])
|
|
#iterate(ping, "")
|
|
|
|
def getInput():
|
|
global inInput
|
|
global partDomain
|
|
global running
|
|
inInput = raw_input("["+ pingOn +"][" + whoOn + "] Please enter a domain/IP: ")
|
|
partDomain = inInput.split(".")
|
|
if inInput == "quit":
|
|
running = 0
|
|
|
|
#Main Loop
|
|
while running == 1:
|
|
getInput()
|
|
if checkPhrase(inInput) == 1 or len(partDomain) == 1:
|
|
pass
|
|
else:
|
|
if running == 0:
|
|
pass
|
|
else:
|
|
if len(partDomain) == 4:
|
|
print "========================================================"
|
|
ipLookup(inInput)
|
|
if pingOn == "P":
|
|
print "========================================================"
|
|
ipPing(inInput)
|
|
else:
|
|
pass
|
|
else:
|
|
if whoOn == "W":
|
|
whois(inInput)
|
|
else:
|
|
pass
|
|
pass
|
|
#Condense dig calls
|
|
dig(inInput, "A")
|
|
dig(inInput, "MX")
|
|
dig(inInput, "TXT")
|
|
dig(inInput, "NS")
|
|
dig(inInput, "SRV")
|
|
dig(inInput, "SOA") |