From 518cee4ddaf01b6273c6dc8e590d1f01a47a4fa1 Mon Sep 17 00:00:00 2001 From: Changhua Date: Sat, 15 Mar 2025 10:31:39 +0800 Subject: [PATCH] feat(contact): impl new friend verification --- WeChatFerry/spy/contact_manager.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/WeChatFerry/spy/contact_manager.cpp b/WeChatFerry/spy/contact_manager.cpp index 64728ea..57ff600 100644 --- a/WeChatFerry/spy/contact_manager.cpp +++ b/WeChatFerry/spy/contact_manager.cpp @@ -17,6 +17,8 @@ namespace OsCon = Offsets::Contact; using get_contact_mgr_t = QWORD (*)(); using get_contact_list_t = QWORD (*)(QWORD, QWORD); +using func_verify_new_t = QWORD (*)(QWORD, WxString *); +using func_verify_ok_t = QWORD (*)(QWORD, WxString *, QWORD *, QWORD, QWORD, QWORD *, WxString *, QWORD *, WxString *); #define FEAT_LEN 5 static const uint8_t FEAT_COUNTRY[FEAT_LEN] = { 0xA4, 0xD9, 0x02, 0x4A, 0x18 }; @@ -90,8 +92,30 @@ vector get_contacts() int accept_new_friend(const std::string &v3, const std::string &v4, int scene) { - LOG_ERROR("技术太菜,实现不了。"); - return -1; // 成功返回 1 + // TODO: 处理来源、备注、标签等 + auto func_new = Spy::getFunction(OsCon::VERIFY_NEW); + auto func_verify = Spy::getFunction(OsCon::VERIFY_OK); + + QWORD helper = util::get_qword(Spy::WeChatDll.load() + OsCon::ADD_FRIEND_HELPER); + QWORD fvdf = util::get_qword(Spy::WeChatDll.load() + OsCon::FVDF); + QWORD mgr = util::get_qword(Spy::WeChatDll.load() + OsCon::VERIFY_MGR); + QWORD a8 = util::get_qword(Spy::WeChatDll.load() + OsCon::VERIFY_A8); + + auto pV3 = util::CreateWxString(v3); + auto pV4 = util::CreateWxString(v4); + + QWORD v4Array[4] = { 0 }; + QWORD p_v4Buff = func_new(reinterpret_cast(&v4Array), pV4); + + char buff[0x100] = { 0 }; + memcpy(buff, &helper, sizeof(&helper)); + QWORD a1 = reinterpret_cast(&buff); + + QWORD ret = func_verify(a1, pV3, &fvdf, 0x3A08A4, p_v4Buff, &mgr, pV4, &a8, pV4); + util::FreeWxString(pV3); + util::FreeWxString(pV4); + + return static_cast(ret); // 成功返回 1 } RpcContact_t get_contact_by_wxid(const string &wxid)