Files
SnarfCode/scripts/check_technitium_zones.py

35 lines
1.2 KiB
Python

import urllib.request
import ssl
import json
import sys
sys.stdout.reconfigure(encoding='utf-8')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
# Technitium admin password is snarfnetadmin
def get_tech_zones(host):
print(f"\n--- Checking Technitium on {host} ---")
login_url = f"https://{host}/api/user/login?user=admin&pass=snarfnetadmin&includeInfo=true"
req = urllib.request.Request(login_url)
try:
with urllib.request.urlopen(req, context=ctx, timeout=8) as resp:
data = json.loads(resp.read().decode())
token = data.get('token')
print(f"Logged into {host}, token acquired.")
zones_url = f"https://{host}/api/zones/list?token={token}"
with urllib.request.urlopen(urllib.request.Request(zones_url), context=ctx, timeout=8) as z_resp:
z_data = json.loads(z_resp.read().decode())
print(f"Zones on {host}:")
for z in z_data.get('response', {}).get('zones', []):
print(f" - {z['name']} ({z.get('type')})")
except Exception as e:
print(f"Error checking {host}: {e}")
get_tech_zones("dns1.snarfnet.net")
get_tech_zones("dns2.snarfnet.net")