44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
import json
|
|
import re
|
|
import urllib.request
|
|
import paramiko
|
|
|
|
PASS = "Bbt9115xty9176!"
|
|
ZID = "b9e032992b315331c8b0571473fedc89"
|
|
CF = "https://api.cloudflare.com/client/v4"
|
|
|
|
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()
|
|
TOK = re.search(r"CLOUDFLARE_API_TOKEN=([^\s\"']+)", (o.read() + e.read()).decode()).group(1)
|
|
c.close()
|
|
|
|
req = urllib.request.Request(
|
|
CF + f"/zones/{ZID}/dns_records?per_page=100",
|
|
headers={"Authorization": f"Bearer {TOK}", "Content-Type": "application/json"},
|
|
)
|
|
with urllib.request.urlopen(req, timeout=30) as r:
|
|
recs = json.load(r)["result"]
|
|
|
|
print("All exposedgays apex/www records:")
|
|
for rec in recs:
|
|
if rec["name"] in ("exposedgays.com", "www.exposedgays.com"):
|
|
print(f" id={rec['id']} {rec['type']} {rec['name']} -> {rec['content']} proxied={rec.get('proxied')}")
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect("10.10.0.10", username="localadministrator", password=PASS, timeout=30)
|
|
for cmd in [
|
|
"dig @1.1.1.1 www.exposedgays.com A +short",
|
|
"dig @1.1.1.1 www.exposedgays.com CNAME +short",
|
|
"dig @annabel.ns.cloudflare.com www.exposedgays.com A +short",
|
|
"curl -sSI --max-time 15 https://www.exposedgays.com/ | head -6",
|
|
]:
|
|
print(f"\n$ {cmd}")
|
|
_, o, e = ssh.exec_command(cmd, timeout=30)
|
|
o.channel.recv_exit_status()
|
|
print((o.read() + e.read()).decode())
|
|
ssh.close() |