59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
import json
|
|
import re
|
|
import urllib.error
|
|
import urllib.request
|
|
import paramiko
|
|
|
|
PASS = "Bbt9115xty9176!"
|
|
CF = "https://api.cloudflare.com/client/v4"
|
|
DOMAIN = "exposedgays.com"
|
|
|
|
|
|
def get_token():
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("10.10.0.1", username="admin", password=PASS, timeout=15)
|
|
_, o, e = c.exec_command("cat /usr/local/etc/wan-dns-failover.env", timeout=30)
|
|
o.channel.recv_exit_status()
|
|
text = (o.read() + e.read()).decode()
|
|
c.close()
|
|
return re.search(r"CLOUDFLARE_API_TOKEN=([^\s\"']+)", text).group(1)
|
|
|
|
|
|
def call(tok, path):
|
|
req = urllib.request.Request(
|
|
CF + path,
|
|
headers={"Authorization": f"Bearer {tok}", "Content-Type": "application/json"},
|
|
)
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=60) as r:
|
|
return json.load(r)
|
|
except urllib.error.HTTPError as e:
|
|
return json.loads(e.read().decode())
|
|
|
|
|
|
def main():
|
|
tok = get_token()
|
|
page = 1
|
|
all_zones = []
|
|
while page <= 20:
|
|
res = call(tok, f"/zones?per_page=50&page={page}")
|
|
batch = res.get("result") or []
|
|
all_zones.extend(batch)
|
|
if len(batch) < 50:
|
|
break
|
|
page += 1
|
|
|
|
print(f"Total zones: {len(all_zones)}")
|
|
for z in all_zones:
|
|
if DOMAIN in z["name"] or "exposed" in z["name"].lower():
|
|
print(f"MATCH: {z['name']} status={z['status']} id={z['id']}")
|
|
print(f" NS: {z.get('name_servers')}")
|
|
|
|
z = call(tok, f"/zones?name={DOMAIN}")
|
|
print(f"\nDirect lookup: success={z.get('success')} count={len(z.get('result') or [])}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |