v2: ID verification by state, 15 photos/5 albums, 20 quick replies, logo, mobile polish
This commit is contained in:
104
deploy/cf-server-token-scan.py
Normal file
104
deploy/cf-server-token-scan.py
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Scan COOLIFY_01 for all cfut_ tokens and try zone create for exposedgays.com."""
|
||||
import json
|
||||
import re
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import paramiko
|
||||
|
||||
PASS = "Bbt9115xty9176!"
|
||||
CF = "https://api.cloudflare.com/client/v4"
|
||||
ACCOUNT = "2599c23bbb1255dbb73e8d34b4115fda"
|
||||
DOMAIN = "exposedgays.com"
|
||||
TUNNEL_CNAME = "03079a26-f14c-4622-b463-ba54a24f7472.cfargotunnel.com"
|
||||
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect("10.10.0.10", username="localadministrator", password=PASS, timeout=30)
|
||||
|
||||
_, o, e = ssh.exec_command(
|
||||
f"echo '{PASS}' | sudo -S bash -c \"grep -rho 'cfut_[A-Za-z0-9_-]\\{{20,\\}}' "
|
||||
"/etc/cloudflared /etc/infra /root /home/localadministrator 2>/dev/null | sort -u\"",
|
||||
timeout=180,
|
||||
)
|
||||
o.channel.recv_exit_status()
|
||||
tokens = sorted(set((o.read() + e.read()).decode().strip().splitlines()))
|
||||
print(f"Found {len(tokens)} tokens on server")
|
||||
ssh.close()
|
||||
|
||||
# Also include known tokens
|
||||
tokens += [
|
||||
"cfut_zlUt5lAKVsu7qIcRCHJnyhAvpJVF5jx24HlrIEn9a8fcd6a1",
|
||||
"cfut_IOm1DJW4pDkPCuQA6UoOjqO6Tcv2zU10y2PSw82m379f7db3f7",
|
||||
]
|
||||
tokens = sorted(set(tokens))
|
||||
|
||||
|
||||
def call(tok, path, method="GET", body=None):
|
||||
req = urllib.request.Request(
|
||||
CF + path,
|
||||
data=json.dumps(body).encode() if body else None,
|
||||
method=method,
|
||||
headers={"Authorization": f"Bearer {tok}", "Content-Type": "application/json"},
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=45) as r:
|
||||
return json.load(r)
|
||||
except urllib.error.HTTPError as e:
|
||||
return json.loads(e.read().decode())
|
||||
|
||||
|
||||
winner = None
|
||||
zone = None
|
||||
|
||||
for tok in tokens:
|
||||
v = call(tok, "/user/tokens/verify")
|
||||
if not v.get("success"):
|
||||
continue
|
||||
expired = any(m.get("code") == 10001 for m in v.get("messages", []))
|
||||
label = tok[:16] + "..."
|
||||
print(f"\n{label} verify OK expired={expired}")
|
||||
|
||||
z = call(tok, f"/zones?name={DOMAIN}")
|
||||
if z.get("result"):
|
||||
winner, zone = tok, z["result"][0]
|
||||
print(f" FOUND zone {zone['id']} status={zone['status']}")
|
||||
break
|
||||
|
||||
c = call(
|
||||
tok,
|
||||
"/zones",
|
||||
"POST",
|
||||
{"name": DOMAIN, "account": {"id": ACCOUNT}, "type": "full", "jump_start": False},
|
||||
)
|
||||
if c.get("success"):
|
||||
winner, zone = tok, c["result"]
|
||||
print(f" CREATED zone NS={zone.get('name_servers')}")
|
||||
break
|
||||
err = (c.get("errors") or [{}])[0].get("message", "")
|
||||
print(f" create fail: {err[:100]}")
|
||||
|
||||
if not zone:
|
||||
print("\nNo token could find or create zone")
|
||||
raise SystemExit(1)
|
||||
|
||||
zid = zone["id"]
|
||||
body_apex = {"type": "CNAME", "name": DOMAIN, "content": TUNNEL_CNAME, "ttl": 1, "proxied": True}
|
||||
body_www = {"type": "CNAME", "name": f"www.{DOMAIN}", "content": TUNNEL_CNAME, "ttl": 1, "proxied": True}
|
||||
|
||||
records = call(winner, f"/zones/{zid}/dns_records?per_page=100").get("result", [])
|
||||
for name, body in [(DOMAIN, body_apex), (f"www.{DOMAIN}", body_www)]:
|
||||
existing = next(
|
||||
(r for r in records if r["name"] == name and r["type"] in ("A", "CNAME", "AAAA")),
|
||||
None,
|
||||
)
|
||||
if existing:
|
||||
res = call(winner, f"/zones/{zid}/dns_records/{existing['id']}", "PATCH", body)
|
||||
else:
|
||||
res = call(winner, f"/zones/{zid}/dns_records", "POST", body)
|
||||
print(f"DNS {name}: success={res.get('success')} errors={res.get('errors')}")
|
||||
|
||||
print("\n=== Nameservers (update GoDaddy if status=pending) ===")
|
||||
for ns in zone.get("name_servers", []):
|
||||
print(f" {ns}")
|
||||
print(f"Zone status: {zone.get('status')}")
|
||||
Reference in New Issue
Block a user