DNS-py/HTTPy.py
2017-06-02 02:38:07 +10:00

80 lines
1.8 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
import argparse
import subprocess
import re # YAY REVERSE ENGINEER... wait its just regex
#Made this work with linux magic
inInput = ""
partDomain = ""
#URL https://www.whois.com/whois/benjamyn-testing.com
#class df-block-raw
print("Domain: ")
def iterate(inArray):
count = 0
while count != len(inArray):
print count, 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]
print len(test) #fix up mutiple record types...
def ipLookup(inDomain):
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
inInput = raw_input()
partDomain = inInput.split(".")
#if partDomain[2] != "":
#run code
#else tell user they suck :D
print "Domain: "
getInput()
if len(partDomain) == 4:
ipLookup(inInput)
else:
#whois(inInput)
dig(inInput, "A")
dig(inInput, "MX")
dig(inInput, "TXT")
#whois(inInput)
# tmp = raw_input()
# whois(tmp)
# dig(tmp)
# Debugs
# print domain
# partDomain = domain.partition(".")
# print partDomain