Implemented ip address lookups
Fixed some crappy code TODO: Clean up current code Fixed input not being stripped Moved the dns lookup code Moved the whois lookup code Cleaned everythin up
This commit is contained in:
parent
8727e66ffb
commit
003a2cd29f
58
main.py
58
main.py
@ -4,6 +4,10 @@ import readline
|
||||
import signal
|
||||
import dns.resolver
|
||||
import json
|
||||
import warnings
|
||||
from dns import reversename
|
||||
from ipwhois.net import Net
|
||||
from ipwhois.asn import IPASN
|
||||
from pprint import pprint
|
||||
from libs import config
|
||||
|
||||
@ -30,17 +34,24 @@ def printWhois(resultData):
|
||||
|
||||
def parseInput(inData):
|
||||
tmpInData = inData.lower()
|
||||
tmpInData = tmpInData.strip()
|
||||
if tmpInData == "quit":
|
||||
quit()
|
||||
try:
|
||||
result = domainWhois(inData)
|
||||
except Exception as E:
|
||||
print('%s : TLD most likely needs configuring' % (E))
|
||||
result = "Error"
|
||||
print("\nWhos Info")
|
||||
printWhois(result)
|
||||
print("\nDNS Records")
|
||||
recLookup(inData)
|
||||
if checkIfIP(tmpInData):
|
||||
##IP lookup code
|
||||
print("Got IP address")
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings("ignore", category=UserWarning)
|
||||
ipnet = Net(tmpInData)
|
||||
ipobj = IPASN(ipnet)
|
||||
results = ipobj.lookup()
|
||||
for key,value in results.iteritems():
|
||||
print('%s: %s' % (key, value))
|
||||
rev_name = reversename.from_address(tmpInData)
|
||||
reverseName = str(dns.resolver.query(rev_name, "PTR")[0])
|
||||
print('\nPTR: %s' % (reverseName))
|
||||
else:
|
||||
lookupDomain(tmpInData)
|
||||
|
||||
def recLookup(inData):
|
||||
for dnsrec in dnsrecords:
|
||||
@ -50,9 +61,38 @@ def recLookup(inData):
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
def lookupDomain(inData):
|
||||
try:
|
||||
result = domainWhois(inData)
|
||||
except Exception as E:
|
||||
print('%s : TLD most likely needs to be configured' % (E))
|
||||
result = "Error"
|
||||
print("\nWhois Information")
|
||||
printWhois(result)
|
||||
print("\nDNS Records")
|
||||
recLookup(inData)
|
||||
|
||||
# Taken and modified from DNSpy 1, I am not asahmed it works
|
||||
def checkIfIP(in1):
|
||||
count = 0
|
||||
inSplit = in1.split('.')
|
||||
if len(inSplit) != 4:
|
||||
return False
|
||||
for part in inSplit:
|
||||
if part.isdigit():
|
||||
count += 1
|
||||
else:
|
||||
return False
|
||||
if count == 4:
|
||||
return True
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
##
|
||||
# Add more params to the config file
|
||||
# Like indent/prompts etc
|
||||
##
|
||||
|
||||
jsonData = config.readConf()
|
||||
#pprint(jsonData)
|
||||
subdomains = jsonData["subdomains"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user