Files
workphone-sdk/test_frida_final.py.bak

77 lines
2.4 KiB
Python

import frida, time, sys, json
d = frida.get_device_manager().add_remote_device("192.168.0.12:27042")
s = d.attach(16816)
with open("/Users/karuo/Documents/GitHub/workphone-sdk/sdk/agent/hook/wechat_hook_v2.js") as f:
src = f.read()
sc = s.create_script(src)
sc.on("message", lambda m, d: None)
sc.load()
time.sleep(3)
e = sc.exports_sync
out = open("/tmp/frida_results.txt", "w")
tests = [
("ping", None),
("getHookStatus", None),
("getProcessInfo", None),
("getWechatVersion", None),
("getConnectionStatus", None),
("getCurrentActivity", None),
("getDeviceInfo", None),
("getNetworkInfo", None),
("getStorageInfo", None),
("getProfile", None),
("checkAccountStatus", None),
("checkLoginState", None),
("getSimPhone", None),
("getWalletBalance", None),
("generateMyQrCode", None),
("getLabels", None),
("getVersionCompat", None),
("navigateToMain", None),
("getContacts", {"limit": 3}),
("getContactInfo", {"wxid": "filehelper"}),
("searchContacts", {"keyword": "test", "limit": 3}),
("sendMessage", {"to_id": "filehelper", "content": "SDK Verify OK", "msg_type": "text"}),
("getRecentMessages", {"limit": 3}),
("getMessages", {"conversation_id": "filehelper", "limit": 3}),
("searchMessages", {"keyword": "test", "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_test.png"}),
("navigateToChat", {"wxid": "filehelper"}),
("simulateBack", None),
("batchExecute", {"actions": [{"action": "ping"}, {"action": "getHookStatus"}]}),
]
for name, params in tests:
fn = getattr(e, name, None)
if not fn:
out.write(f"{name}: NOT_FOUND\n")
continue
try:
if params is None:
r = fn()
else:
r = fn(params)
rstr = json.dumps(r, ensure_ascii=False, default=str)[:150]
out.write(f"{name}: OK -> {rstr}\n")
except Exception as ex:
out.write(f"{name}: ERROR -> {str(ex)[:100]}\n")
out.write("\nDONE\n")
out.close()
sc.unload()
s.detach()
print("FINISHED")