DNS-py/HTTPy.py
2017-05-26 23:15:53 +10:00

92 lines
2.0 KiB
Python

#!/bin/python2.7
#Lookup jsonWhois.com, easy json API for whois lookups ;D
#Might need to run this in windows/on laptop/ in VM
from HTMLParser import HTMLParser
import httplib
import argparse
import subprocess
import re # YAY REVERSE ENGINEER... wait its just regex
#Made this work with linux magic
# OLD SHIT PLZ REMOVE <FUCK WANDOWS>
currtag = ""
conf_temp = "pre"
inInput = ""
#URL https://www.whois.com/whois/benjamyn-testing.com
#class df-block-raw
print("Domain: ")
class MyHTMLParser(HTMLParser):
def handle_starttag(self, tag, attrs):
global conf_temp
global currtag
if tag == conf_temp:
# starttag = tag
for name, value in attrs:
if name == "class" and value == "df-raw":
print tag
currtag = tag
# pass
#print starttag
def handle_endtag(self, tag):
global currtag
if tag == "pre":
currtag = ""
def handle_data(self, data):
#print starttagmgfk
if currtag == conf_temp:
print data
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):
dig = subprocess.check_output(["dig", "A", "+short", inDomain])
print "========================================================" #ADD REST OF DIGS
test = dig.split("\n")
iterate(test)
def getInput():
global inInput
inInput = raw_input()
#if partDomain[2] != "":
#run code
#else tell user they suck :D
print "Domain: "
getInput()
whois(inInput)
# tmp = raw_input()
# whois(tmp)
# dig(tmp)
#conn = httplib.HTTPSConnection("www.whois.com")
#conn.request("GET", "/whois/" + domain)
#r1 = conn.getresponse()
#parser = MyHTMLParser()
#parser.feed(r1.read())
# Debugs
# print domain
# partDomain = domain.partition(".")
# print partDomain