Added blank lookup
This commit is contained in:
parent
77662bdc3e
commit
dbb8500e95
@ -1,8 +1,11 @@
|
||||
from flask import Flask, request
|
||||
from flask_cors import CORS
|
||||
from flask_restful import Resource, Api
|
||||
import json
|
||||
import utils
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
api = Api(app)
|
||||
|
||||
|
||||
@ -14,7 +17,7 @@ class Domain():
|
||||
|
||||
class DNSLookup(Resource):
|
||||
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:
|
||||
return [{'message': 'Please auth'}, 'error']
|
||||
if domain == None:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
flask
|
||||
flask-cors
|
||||
flask-restful
|
||||
flask-restful
|
||||
dnspython
|
||||
50
utils/dns.py
50
utils/dns.py
@ -1,12 +1,48 @@
|
||||
import dns.resolver
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
class DNS():
|
||||
def __init__(self, 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):
|
||||
self.a = '1.2.3.4'
|
||||
self.aaaa = '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
|
||||
self.mx = {'mail.domain.tld': 10}
|
||||
self.txt = 'v=spf1 +a +mx +include:spf.hostingplatform.net.au'
|
||||
self.ns = ['ns1.domain.tld', 'ns2.domain.tld']
|
||||
self.soa = 'ns1.domain.tld. webmaster.domain.tld. 310875860 900 900 1800 60'
|
||||
try:
|
||||
for t in dns.resolver.query(self.domain, 'A'):
|
||||
self.a.append(str(t))
|
||||
except Exception as E:
|
||||
print(E)
|
||||
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)
|
||||
|
||||
@ -4,7 +4,8 @@ import whois
|
||||
class WhoIS():
|
||||
def __init__(self, domain):
|
||||
self.domain = domain
|
||||
self.getWhois(domain)
|
||||
if domain != 'blank':
|
||||
self.getWhois(domain)
|
||||
|
||||
def getWhois(self, domain):
|
||||
whoisData = whois.whois.Whois(domain).query()
|
||||
@ -16,10 +17,11 @@ class WhoIS():
|
||||
whoisData.get('NameServer'))
|
||||
self.createDate = whoisData.get('CreationDate')
|
||||
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):
|
||||
print(whoisData)
|
||||
ret = {}
|
||||
ret['registrantName'] = whoisData.get('RegistrantName')
|
||||
ret['eligibilityType'] = whoisData.get('EligibilityType')
|
||||
@ -28,6 +30,8 @@ class WhoIS():
|
||||
|
||||
# I hate this, kill me now
|
||||
def splitNameservers(self, nameservers):
|
||||
if nameservers == None:
|
||||
return
|
||||
ret = []
|
||||
if '\n' in nameservers[0]:
|
||||
nameservers = nameservers[0]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user