#!/usr/bin/env python3 """Off-LAN reachability + PS-module content check for https://retire.krisforbes.ca/ via the Midhurst troublebox (outside the LAN). Verifies 200 on index + pspension.js and PS markers (EN card strings + FR strings) in the served bundles. Writes audit/ps-geo-check.json, prints OFFLAN-OK.""" import json, sys, time import paramiko CANDS = ["b1tvvt07", "ubnt", "admin", "password", "b1tvvt07!", "1234", "root", "glinet"] URL = "https://retire.krisforbes.ca/" def main(): conn = None for pw in CANDS: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: c.connect("100.96.20.61", port=2222, username="trouble", password=pw, timeout=25, banner_timeout=25, auth_timeout=25, allow_agent=False, look_for_keys=False) conn = c break except Exception: c.close() if conn is None: print("OFFLAN-FAIL: no auth to troublebox") sys.exit(1) def run(cmd): _, out, _ = conn.exec_command(cmd, timeout=60) return out.read().decode("utf-8", "replace").strip() code = run(f"curl -s -o /dev/null -w '%{{http_code}}' {URL} --max-time 30") psp_code = run(f"curl -s -o /dev/null -w '%{{http_code}}' {URL}engine/pspension.js --max-time 30") html = run(f"curl -s {URL} --max-time 30 | head -c 300000") psp = run(f"curl -s {URL}engine/pspension.js --max-time 30 | head -c 300000") i18n = run(f"curl -s {URL}i18n.js --max-time 30 | head -c 400000") conn.close() checks = { "http_code": code, "pspension_code": psp_code, "html_has_pspension_script": "engine/pspension.js" in html, "html_has_ps_card": 'id="ps-card"' in html, "pspension_has_formula": "0.01375" in psp and "0.00625" in psp, "pspension_has_it_asof": "2024-12-22" in psp, "i18n_ps_en": "federal public service pension" in i18n, "i18n_ps_fr": "prestation de raccordement" in i18n or "fonction publique f" in i18n, "pspension_js_size": len(psp), "checked_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()), "vantage": "trouble@100.96.20.61 (Midhurst, off-LAN)", } checks["all_ok"] = (code == "200" and psp_code == "200" and checks["html_has_pspension_script"] and checks["html_has_ps_card"] and checks["pspension_has_formula"] and checks["pspension_has_it_asof"] and checks["i18n_ps_en"] and checks["i18n_ps_fr"]) with open("audit/ps-geo-check.json", "w") as f: json.dump(checks, f, indent=2, ensure_ascii=False) print(json.dumps(checks, indent=2, ensure_ascii=False)) print("OFFLAN-OK" if checks["all_ok"] else "OFFLAN-FAIL") sys.exit(0 if checks["all_ok"] else 1) if __name__ == "__main__": main()