DNS-py/HTTPy.py
2017-06-04 03:16:01 +10:00

78 lines
2.0 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
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 ipLook, "PTR: ", host
def ipPing(inDomain):
ping = subprocess.check_output(["ping", "-c 5", inDomain])
iterate(ping, "")
def getInput():
global inInput
global partDomain
global running
inInput = raw_input("Please enter a domain/IP: ")
partDomain = inInput.split(".")
if inInput == "quit":
running = 0
#Main Loop
while running == 1:
getInput()
if inInput == "":
pass
else:
if running == 0:
pass
else:
if len(partDomain) == 4:
ipLookup(inInput)
else:
whois(inInput)
#Condense dig calls
dig(inInput, "A")
dig(inInput, "MX")
dig(inInput, "TXT")
dig(inInput, "NS")
dig(inInput, "SRV")
dig(inInput, "SOA")
ipPing(inDomain)