Added blank lookup

This commit is contained in:
Benjamyn Love 2020-05-19 09:46:32 -04:00
parent 77662bdc3e
commit dbb8500e95
4 changed files with 56 additions and 12 deletions

View File

@ -1,8 +1,11 @@
from flask import Flask, request from flask import Flask, request
from flask_cors import CORS
from flask_restful import Resource, Api from flask_restful import Resource, Api
import json
import utils import utils
app = Flask(__name__) app = Flask(__name__)
CORS(app)
api = Api(app) api = Api(app)
@ -14,7 +17,7 @@ class Domain():
class DNSLookup(Resource): class DNSLookup(Resource):
def get(self, domain=None): def get(self, domain=None):
auth = request.headers.get('X-AUTH') auth = request.headers.get('X-AUTH') # This is inverted while in dev
if auth != None: if auth != None:
return [{'message': 'Please auth'}, 'error'] return [{'message': 'Please auth'}, 'error']
if domain == None: if domain == None:

View File

@ -1,3 +1,4 @@
flask flask
flask-cors flask-cors
flask-restful flask-restful
dnspython

View File

@ -1,12 +1,48 @@
import dns.resolver
from pprint import pprint
class DNS(): class DNS():
def __init__(self, domain): def __init__(self, domain):
self.domain = domain self.domain = domain
self.getRecords() self.a = []
self.aaaa = []
self.mx = []
self.txt = []
self.ns = []
self.soa = []
if domain != 'blank':
self.getRecords()
def getRecords(self): def getRecords(self):
self.a = '1.2.3.4' try:
self.aaaa = '2001:0db8:85a3:0000:0000:8a2e:0370:7334' for t in dns.resolver.query(self.domain, 'A'):
self.mx = {'mail.domain.tld': 10} self.a.append(str(t))
self.txt = 'v=spf1 +a +mx +include:spf.hostingplatform.net.au' except Exception as E:
self.ns = ['ns1.domain.tld', 'ns2.domain.tld'] print(E)
self.soa = 'ns1.domain.tld. webmaster.domain.tld. 310875860 900 900 1800 60' try:
for t in dns.resolver.query(self.domain, 'AAAA'):
self.aaaa.append(str(t))
except Exception as E:
print(E)
try:
for t in dns.resolver.query(self.domain, 'MX'):
self.mx.append(str(t).split())
except Exception as E:
print(E)
try:
for t in dns.resolver.query(self.domain, 'TXT'):
self.txt.append(str(t))
except Exception as E:
print(E)
try:
for t in dns.resolver.query(self.domain, 'NS'):
self.ns.append(str(t))
except Exception as E:
print(E)
try:
for t in dns.resolver.query(self.domain, 'SOA'):
self.soa.append(str(t))
except Exception as E:
print(E)

View File

@ -4,7 +4,8 @@ import whois
class WhoIS(): class WhoIS():
def __init__(self, domain): def __init__(self, domain):
self.domain = domain self.domain = domain
self.getWhois(domain) if domain != 'blank':
self.getWhois(domain)
def getWhois(self, domain): def getWhois(self, domain):
whoisData = whois.whois.Whois(domain).query() whoisData = whois.whois.Whois(domain).query()
@ -16,10 +17,11 @@ class WhoIS():
whoisData.get('NameServer')) whoisData.get('NameServer'))
self.createDate = whoisData.get('CreationDate') self.createDate = whoisData.get('CreationDate')
self.expireDate = whoisData.get('ExpirationDate') self.expireDate = whoisData.get('ExpirationDate')
# self.nameservers = whoisData.get('NameServer') print(whoisData)
# if self.status == None:
# self.status = "We blacklisted bois"
def buildRegistrantInfo(self, whoisData): def buildRegistrantInfo(self, whoisData):
print(whoisData)
ret = {} ret = {}
ret['registrantName'] = whoisData.get('RegistrantName') ret['registrantName'] = whoisData.get('RegistrantName')
ret['eligibilityType'] = whoisData.get('EligibilityType') ret['eligibilityType'] = whoisData.get('EligibilityType')
@ -28,6 +30,8 @@ class WhoIS():
# I hate this, kill me now # I hate this, kill me now
def splitNameservers(self, nameservers): def splitNameservers(self, nameservers):
if nameservers == None:
return
ret = [] ret = []
if '\n' in nameservers[0]: if '\n' in nameservers[0]:
nameservers = nameservers[0] nameservers = nameservers[0]