"""列出内核发现的工具 + 试跑 probe_perm 看真实异常。""" import json import sys import urllib.request import urllib.error try: sys.stdout.reconfigure(encoding="utf-8", errors="replace") except Exception: pass URL = "http://127.0.0.1:15199" def call(path, payload=None, method="POST", timeout=120): data = json.dumps(payload, ensure_ascii=False).encode("utf-8") if payload is not None else None req = urllib.request.Request( URL + path, data=data, method=method, headers={"Content-Type": "application/json; charset=utf-8"}, ) try: with urllib.request.urlopen(req, timeout=timeout) as r: return json.loads(r.read().decode("utf-8")) except urllib.error.HTTPError as e: body = e.read().decode("utf-8", "replace") return {"__http_error": e.code, "__body": body[:2000]} tools = call("/api/tools", None, "GET") py = tools.get("python") or tools.get("tools") or [] if isinstance(py, dict): py = py.get("python") or [] names = sorted(t.get("name") for t in py if isinstance(t, dict)) print("内核发现的工具(%d 个):" % len(names)) print(" ", names) print() for probe in ("probe_perm", "probe_seed", "probe_loaded"): print(f"{probe} 在列表里:", probe in names) print() print("=== 试跑 probe_perm ===") r = call("/api/tools/run", {"name": "probe_perm", "args": {}}) print(json.dumps(r, ensure_ascii=False)[:2500])