Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if args.output:
# If output directory is mentioned...
try:
if not os.path.exists(args.output+tld.get_fld(config.SITE_URL)):
os.makedirs(args.output+tld.get_fld(config.SITE_URL))
except FileExistsError:
pass
config.OUTPUT_DIR = args.output+tld.get_fld(config.SITE_URL) + '/'
else:
try:
os.makedirs('xsrfprobe-output/'+tld.get_fld(config.SITE_URL))
except FileExistsError:
pass
config.OUTPUT_DIR = 'xsrfprobe-output/'+tld.get_fld(config.SITE_URL) + '/'
# When this exception turns out, we know the user has supplied a IP not domain
except tld.exceptions.TldDomainNotFound:
direc = re.search(IP, config.SITE_URL).group(0)
if args.output:
# If output directory is mentioned...
try:
if not os.path.exists(args.output+direc):
os.makedirs(args.output+direc)
except FileExistsError:
pass
config.OUTPUT_DIR = args.output+direc + '/'
else:
try:
os.makedirs('xsrfprobe-output/'+direc)
except FileExistsError:
pass
config.OUTPUT_DIR = 'xsrfprobe-output/'+direc + '/'
def canonicalize(host):
if not host:
raise HostValidateException('Hosts cannot be None')
if not isinstance(host, str) and not isinstance(host, unicode):
raise HostValidateException('Hosts must be strings')
host = host.strip().lower()
try:
tld.get_tld('http://{}'.format(host))
except tld.exceptions.TldDomainNotFound:
raise HostValidateException('Invalid tld for host {}'.format(host))
return host
if args.output:
# If output directory is mentioned...
try:
if not os.path.exists(args.output+tld.get_fld(config.SITE_URL)):
os.makedirs(args.output+tld.get_fld(config.SITE_URL))
except FileExistsError:
pass
config.OUTPUT_DIR = args.output+tld.get_fld(config.SITE_URL) + '/'
else:
try:
os.makedirs('output/'+tld.get_fld(config.SITE_URL))
except FileExistsError:
pass
config.OUTPUT_DIR = 'output/'+tld.get_fld(config.SITE_URL) + '/'
# When this exception turns out, we know the user has supplied a IP not domain
except tld.exceptions.TldDomainNotFound:
direc = re.search(IP, config.SITE_URL).group(0)
if args.output:
# If output directory is mentioned...
try:
if not os.path.exists(args.output+direc):
os.makedirs(args.output+direc)
except FileExistsError:
pass
config.OUTPUT_DIR = args.output+direc + '/'
else:
try:
os.makedirs('output/'+direc)
except FileExistsError:
pass
config.OUTPUT_DIR = 'output/'+direc + '/'
def post_auth_ns():
domain = request.forms.get("domain")
if domain is None:
return jsonify(status=400, message="Param domain missing.")
try:
nameserver_list = get_authoritative_nameserver(domain)
except exceptions.TldDomainNotFound as e:
print("TldDomainNotFound", e)
return jsonify(status=400, message=str(e))
except exceptions.TldBadUrl as e:
print("TldBadUrl", e)
return jsonify(status=400, message=str(e))
return jsonify(status=200, message=nameserver_list)
def index():
domain = request.forms.get("domain")
dns_server = request.forms.get("dns_server")
if domain is None:
return jsonify(status=400, message="Param domain missing.")
if dns_server is None:
return jsonify(status=400, message="Param dns_server missing.")
try:
domain = validate_domain(domain)
dns_results = resolve_domain(domain, dns_server=dns_server)
return jsonify(status=200, data=dns_results)
except exceptions.TldDomainNotFound as e:
print("TldDomainNotFound", e)
return jsonify(status=400, message=str(e))
except exceptions.TldBadUrl as e:
print("TldBadUrl", e)
return jsonify(status=400, message=str(e))
except dns.resolver.NXDOMAIN as e:
print("NXDOMAIN", e)
return jsonify(status=404, message=e.msg)
except dns.resolver.NoAnswer as e:
print("NoAnswer", e)
return jsonify(status=500, message=e.msg)
except dns.resolver.NoNameservers as e:
print("NoNameservers", e)
return jsonify(status=500, message=e.msg)
except Timeout as e:
print("Timeout", e)
dns_server = request.forms.get("dns_server")
if domain is None:
return jsonify(status=400, message="Param domain missing.")
if dns_server is None:
return jsonify(status=400, message="Param dns_server missing.")
try:
domain = validate_domain(domain)
dns_results = resolve_domain(domain, dns_server=dns_server)
return jsonify(status=200, data=dns_results)
except exceptions.TldDomainNotFound as e:
print("TldDomainNotFound", e)
return jsonify(status=400, message=str(e))
except exceptions.TldBadUrl as e:
print("TldBadUrl", e)
return jsonify(status=400, message=str(e))
except dns.resolver.NXDOMAIN as e:
print("NXDOMAIN", e)
return jsonify(status=404, message=e.msg)
except dns.resolver.NoAnswer as e:
print("NoAnswer", e)
return jsonify(status=500, message=e.msg)
except dns.resolver.NoNameservers as e:
print("NoNameservers", e)
return jsonify(status=500, message=e.msg)
except Timeout as e:
print("Timeout", e)
return jsonify(
status=504,
message="{} A common reason for this is an invalid DNS server.".format(