DNS-py/HTTPy.py

94 lines
2.3 KiB
Python
Executable File

#Lookup jsonWhois.com, easy json API for whois lookups ;D
#Might need to run this in windows/on laptop/ in VM
#git sublime test
import argparse
import subprocess
import re # YAY REVERSE ENGINEER... wait its just regex
#Made this work with linux magic
inInput = ""
partDomain = ""
running = 1
#URL https://www.whois.com/whois/benjamyn-testing.com
#class df-block-raw
def iterate(inArray):
count = 0
while count != len(inArray) - 1:
print count, inArray[count]
count = count + 1
def iterateDig(inArray, rec):
count = 0
while count != len(inArray) - 1:
print rec, 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]
iterateDig(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 getInput():
global inInput
global partDomain
global running
inInput = raw_input("Please enter a domain/IP: ")
partDomain = inInput.split(".")
if inInput == "quit":
running = 0
#if partDomain[2] != "":
#run code
#else tell user they suck :D
while running == 1:
getInput()
if running == 0:
pass
else:
if len(partDomain) == 4:
ipLookup(inInput)
else:
whois(inInput)
dig(inInput, "A")
dig(inInput, "MX")
dig(inInput, "TXT")
dig(inInput, "NS")
dig(inInput, "SRV")
dig(inInput, "SOA")
#whois(inInput)
# tmp = raw_input()
# whois(tmp)
# dig(tmp)
# Debugs
# print domain
# partDomain = domain.partition(".")
# print partDomain