DNS-py/HTTPy.py
2017-06-21 08:07:07 +10:00

96 lines
2.5 KiB
Python
Executable File

import argparse
import subprocess
import re # YAY REVERSE ENGINEER... wait its just regex
#Made this work with linux magic
inInput = ""
partDomain = ""
running = 1
pingOn = "P"
whoOn = "W"
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
global pingOn
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 inInput == "ping":
if pingOn == "P":
pingOn = "p"
else:
pingOn = "P"
if inInput == "whois":
if pingOn == "W":
pingOn = "w"
else:
pingOn = "W"
if inInput == "" or inInput == "ping" or inInput == "whois":
pass
else:
if running == 0:
pass
else:
if len(partDomain) == 4:
ipLookup(inInput)
if pingOn == "P":
ipPing(inInput)
else:
pass
if whoOn == "W":
whois(inInput)
else:
pass
else:
#whois(inInput)
#Condense dig calls
dig(inInput, "A")
dig(inInput, "MX")
dig(inInput, "TXT")
dig(inInput, "NS")
dig(inInput, "SRV")
dig(inInput, "SOA")