Files
workphone-sdk/test_frida_live_20260518.py

112 lines
3.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
工作手机SDK - Frida真机验证 v2
IP已修正为192.168.110.80
"""
import frida, time, sys, json, os
from datetime import datetime
PHONE_IP = "192.168.110.80"
FRIDA_PORT = 27042
WECHAT_PID = 16816
BASE = "/Users/karuo/Documents/开发/2、私域银行/工作手机"
HOOK_SCRIPT = BASE + "/sdk/agent/hook/wechat_hook_v2.js"
RESULT_FILE = BASE + "/verification_results_live_20260518.json"
print(f"[{datetime.now().strftime('%H:%M:%S')}] 连接Frida: {PHONE_IP}:{FRIDA_PORT}")
dm = frida.get_device_manager()
device = dm.add_remote_device(f"{PHONE_IP}:{FRIDA_PORT}")
print(f"[OK] 设备: {device.name}")
session = device.attach(WECHAT_PID)
print(f"[OK] 附加微信 PID={WECHAT_PID}")
with open(HOOK_SCRIPT, encoding="utf-8") as f:
src = f.read()
script = session.create_script(src)
script.on("message", lambda m, d: None)
script.load()
print("[OK] Hook已加载等待3秒...")
time.sleep(3)
rpc = script.exports_sync
TESTS = [
("ping", None),
("getHookStatus", None),
("getProcessInfo", None),
("getWechatVersion", None),
("getVersionCompat", None),
("getProfile", None),
("checkAccountStatus", None),
("checkLoginState", None),
("getDeviceInfo", None),
("getNetworkInfo", None),
("getContacts", {"limit": 5}),
("getContactInfo", {"wxid": "filehelper"}),
("searchContacts", {"keyword": "test", "limit": 3}),
("getLabels", None),
("getRecentMessages", {"limit": 3}),
("getMessages", {"conversation_id": "filehelper", "limit": 3}),
("getGroups", {"limit": 3}),
("getFriendRequests", {"limit": 3}),
("getMoments", {"limit": 3}),
("getFavorites", {"limit": 3}),
("globalSearch", {"keyword": "test", "limit": 3}),
("getRecentMiniPrograms", {}),
("getLoginDevices", {}),
("getOfficialAccounts", {"limit": 3}),
("browseChannels", {"limit": 3}),
("getTransactionHistory", {"limit": 3}),
("takeScreenshot", {"path": "/sdcard/sdk_live_test.png"}),
("getCurrentActivity", None),
("navigateToMain", None),
("sendMessage", {"to_id": "filehelper", "content": "[SDK verify] Frida live ok", "msg_type": "text"}),
("navigateToChat", {"wxid": "filehelper"}),
("simulateBack", None),
]
results = []
passed = failed = 0
for name, params in TESTS:
fn = getattr(rpc, name, None)
if fn is None:
results.append({"name": name, "status": "NOT_FOUND"})
failed += 1
print(f" [NOT_FOUND] {name}")
continue
try:
t0 = time.time()
r = fn(params) if params is not None else fn()
ms = int((time.time()-t0)*1000)
ok = r.get("success", True) if isinstance(r, dict) else True
if ok:
passed += 1
print(f" [PASS] {name} ({ms}ms)")
else:
failed += 1
err = str(r.get("error",""))[:80] if isinstance(r, dict) else ""
print(f" [FAIL] {name} ({ms}ms): {err}")
results.append({"name": name, "status": "PASS" if ok else "FAIL", "ms": ms, "data": r})
except Exception as e:
failed += 1
print(f" [ERROR] {name}: {str(e)[:80]}")
results.append({"name": name, "status": "ERROR", "error": str(e)[:150]})
time.sleep(0.3)
report = {
"title": "Frida live verify v2",
"device": PHONE_IP,
"time": datetime.now().isoformat(),
"total": len(results),
"passed": passed,
"failed": failed,
"pass_rate": f"{passed/len(results)*100:.1f}%" if results else "0%",
"results": results
}
with open(RESULT_FILE, "w", encoding="utf-8") as f:
json.dump(report, f, ensure_ascii=False, indent=2, default=str)
print(f"\nResult: {passed}/{len(results)} passed ({report['pass_rate']})")
print(f"Saved: {RESULT_FILE}")
script.unload()
session.detach()