Created
June 30, 2018 22:54
-
-
Save fuzzysteve/971cd8807911a42c1ac8741ee4ecb01f to your computer and use it in GitHub Desktop.
dnspark dumper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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