Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fuzzysteve/971cd8807911a42c1ac8741ee4ecb01f to your computer and use it in GitHub Desktop.
Save fuzzysteve/971cd8807911a42c1ac8741ee4ecb01f to your computer and use it in GitHub Desktop.
dnspark dumper
from requests.auth import HTTPBasicAuth
import requests
import json
import time
auth=HTTPBasicAuth('firstbitgoeshere', 'secondbitgoeshere')
baseurl="https://api.dnspark.com/v2/dns/"
domains=requests.get('{}'.format(baseurl),auth=auth)
domainlist=domains.json()
for drecord in domainlist['records']:
domain=drecord['domain']
domaindetails=requests.get('{}{}'.format(baseurl,domain),auth=auth)
domainobject=domaindetails.json()
f = open('zones/zone-{}'.format(domain), 'w')
for record in domainobject['records']:
if record['rtype'] == 'SOA' or record['rtype'] == 'NS':
pass
else:
name=record['rname'].replace('.{}'.format(domain),'')
if name==domain:
name='@'
f.write("{}\t{}\t{}\t{}\n".format(name,record['ttl'],record['rtype'],record['rdata']))
f.close();
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment