#!/usr/bin/env python3 """Read leftover hotspot/SaaS traces from the LAN MikroTik via Tailscale jump host.""" from __future__ import annotations import paramiko import time JUMP = ("100.80.255.113", "otantik", "DeararbsFr2@") MK = ("172.30.0.1", "admin", "demopass") COMMANDS = [ "/system identity print", "/ip cloud print", "/ip hotspot print detail", "/ip hotspot profile print detail", "/ip hotspot walled-garden print detail", "/ip hotspot walled-garden ip print detail", "/ip hotspot user profile print", "/ip dns print", "/ip dns static print", "/ip firewall address-list print", "/interface wireguard print detail", "/interface wireguard peers print detail", "/system script print detail", "/system scheduler print detail", "/system note print", "/file print", "/ip hotspot walled-garden export", "/ip hotspot export", "/system script export", "/ip firewall nat export", "/ip firewall filter export", "/ip proxy print", "/ip hotspot active print", "/ip service print", ] def wait_prompt(shell, timeout=12) -> str: buf = b"" end = time.time() + timeout while time.time() < end: time.sleep(0.2) if shell.recv_ready(): buf += shell.recv(65535) end = time.time() + 2.5 if b"> " in buf[-80:]: break return buf.decode("utf-8", "replace") def main() -> None: jump = paramiko.SSHClient() jump.set_missing_host_key_policy(paramiko.AutoAddPolicy()) jump.connect( JUMP[0], username=JUMP[1], password=JUMP[2], timeout=20, allow_agent=False, look_for_keys=False, banner_timeout=25, ) chan = jump.get_transport().open_channel("direct-tcpip", (MK[0], 22), ("127.0.0.1", 0)) mk = paramiko.SSHClient() mk.set_missing_host_key_policy(paramiko.AutoAddPolicy()) mk.connect( MK[0], username=MK[1], password=MK[2], sock=chan, timeout=20, allow_agent=False, look_for_keys=False, banner_timeout=25, ) shell = mk.invoke_shell(width=240, height=80) print(wait_prompt(shell, 15)) chunks = [] for cmd in COMMANDS: shell.send(cmd + "\r") out = wait_prompt(shell, 20) chunks.append("\n===== " + cmd + " =====\n" + out) print("got", cmd, "len", len(out)) text = "\n".join(chunks) out_path = r"c:\laragon\www\light-otantik-nux\scripts\_mk_traces.txt" with open(out_path, "w", encoding="utf-8", errors="replace") as f: f.write(text) print("WROTE", out_path, "chars", len(text)) mk.close() jump.close() if __name__ == "__main__": main()