diff --git a/README.md b/README.md index a813e39..9d31abc 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,12 @@ 10.取消hook消息 11.hook图片 12.取消hook图片 -13.hook语音 +13.hook语音(不推荐) 14.取消hook语音 19.通过手机或qq查找微信 - +20.通过wxid添加好友 +23.通过好友申请 25.获取群成员 26.获取群成员昵称 27.删除群成员 @@ -597,7 +598,42 @@ |参数|必选|类型|说明| |---|---|---|---| |wxid |true |string| 好友wxid | +|msg |true |string| 验证消息 | +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,1成功, -1失败| +|result|string|成功提示| + + +###### 接口示例 +入参: +``` javascript +{ + "wxid":"wxid_o1112222" +} +``` +响应: +``` javascript +{"code":1,"result":"OK"} +``` + +#### 23.通过好友申请** +###### 接口功能 +> 通过好友的申请 + +###### 接口地址 +> [/api/?type=23](/api/?type=23) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|v3 |true |string| 添加好友消息内容里的encryptusername| +|v4 |true |string| 添加好友消息内容里的ticket| ###### 返回字段 |返回字段|字段类型|说明 | diff --git a/src/contact_mgr.cc b/src/contact_mgr.cc index 4b2582a..9525e41 100644 --- a/src/contact_mgr.cc +++ b/src/contact_mgr.cc @@ -129,17 +129,22 @@ int ContactMgr::AddFriendByWxid(wchar_t *wxid,wchar_t* msg) { DWORD fn1_addr = base_addr_ + 0x758720; WeChatString user_id(wxid); WeChatString w_msg(msg); - DWORD null_ptr = 0; DWORD instance =0; - Unkown null_obj={}; - null_obj.field6 = 0xF; + Unkown null_obj={0,0,0,0,0,0xF}; __asm{ PUSHAD PUSHFD CALL contact_mgr_addr - MOV dword ptr [instance],EAX + MOV dword ptr [instance],EAX + MOV EDI,0x6 + MOV ESI,0 + MOV EAX,0x2 SUB ESP,0x18 MOV EAX,ESP + MOV dword ptr ds:[EAX],0 + MOV dword ptr ds:[EAX+0x14],0xF + MOV dword ptr ds:[EAX+0x10],0 + MOV byte ptr ds:[EAX],0 SUB ESP,0x18 LEA EAX,null_obj MOV ECX,ESP @@ -147,7 +152,8 @@ int ContactMgr::AddFriendByWxid(wchar_t *wxid,wchar_t* msg) { CALL fn1_addr PUSH 0x0 PUSH 0x6 - MOV EAX,w_msg + MOV EAX,w_msg + SUB ESP,0x14 MOV ECX,ESP PUSH -0x1 @@ -155,6 +161,7 @@ int ContactMgr::AddFriendByWxid(wchar_t *wxid,wchar_t* msg) { CALL verify_msg_addr PUSH 0x2 LEA EAX,user_id + SUB ESP,0x14 MOV ECX,ESP PUSH EAX @@ -165,29 +172,48 @@ int ContactMgr::AddFriendByWxid(wchar_t *wxid,wchar_t* msg) { POPFD POPAD } - - // __asm { - // PUSHAD - // PUSHFD - // SUB ESP,0x14 - // MOV ECX,ESP - // PUSH -0x1 - // PUSH w_msg - // CALL verify_msg_addr - // PUSH 0x2 - // LEA EAX,user_id - // SUB ESP,0x14 - // MOV ECX,ESP - // PUSH EAX - // CALL set_value_addr - // CALL contact_mgr_addr - // MOV ECX,EAX - // CALL do_verify_user_addr - // MOV success,EAX - // POPFD - // POPAD - // } return success; } + int ContactMgr::VerifyApply(wchar_t *v3, wchar_t *v4){ + int success = -1; + DWORD set_value_addr = base_addr_ + WX_INIT_CHAT_MSG_OFFSET; + DWORD verify_addr = base_addr_ + WX_VERIFY_OK_OFFSET; + DWORD new_helper_addr = base_addr_ + WX_NEW_ADD_FRIEND_HELPER_OFFSET; + DWORD free_helper_addr = base_addr_ + WX_FREE_ADD_FRIEND_HELPER_OFFSET; + + WeChatString v4_str(v4); + WeChatString v3_str(v3); + char helper_obj[0x40] = {0}; + char nullbuffer[0x3CC] = {0}; + __asm { + PUSHAD + PUSHFD + LEA ECX,helper_obj + CALL new_helper_addr + MOV ESI,0x0 + MOV EDI,0x6 + PUSH ESI + PUSH EDI + SUB ESP,0x14 + MOV ECX,ESP + LEA EAX,v4_str + PUSH EAX + CALL set_value_addr + SUB ESP,0x8 + PUSH 0x0 + LEA EAX, nullbuffer + PUSH EAX + LEA EAX,v3_str + PUSH EAX + LEA ECX,helper_obj + CALL verify_addr + MOV success,EAX + LEA ECX,helper_obj + CALL free_helper_addr + POPFD + POPAD + } + return success; + } } // namespace wxhelper \ No newline at end of file diff --git a/src/contact_mgr.h b/src/contact_mgr.h index b522427..677d564 100644 --- a/src/contact_mgr.h +++ b/src/contact_mgr.h @@ -14,6 +14,7 @@ class ContactMgr : public BaseMgr { int DelContact(wchar_t* wxid); std::wstring GetContactOrChatRoomNickname(wchar_t* id); int AddFriendByWxid(wchar_t* wxid,wchar_t* msg); + int VerifyApply(wchar_t *v3, wchar_t *v4); }; } // namespace wxhelper diff --git a/src/http_handler.cc b/src/http_handler.cc index 84458b7..1b94fdc 100644 --- a/src/http_handler.cc +++ b/src/http_handler.cc @@ -237,11 +237,11 @@ string Dispatch(struct mg_connection *c, struct mg_http_message *hm) { break; } case WECHAT_CONTACT_ADD_BY_WXID: { - // wstring user_id = GetWStringParam(j_param, "wxid"); - // wstring msg = GetWStringParam(j_param, "msg"); - // int success = g_context.contact_mgr->AddFriendByWxid(WS2LPWS(user_id),WS2LPWS(msg)); - // json ret_data = {{"code", success}, {"result", "OK"}}; - // ret = ret_data.dump(); + wstring user_id = GetWStringParam(j_param, "wxid"); + wstring msg = GetWStringParam(j_param, "msg"); + int success = g_context.contact_mgr->AddFriendByWxid(WS2LPWS(user_id),WS2LPWS(msg)); + json ret_data = {{"code", success}, {"result", "OK"}}; + ret = ret_data.dump(); break; } case WECHAT_CONTACT_ADD_BY_V3: { @@ -251,6 +251,11 @@ string Dispatch(struct mg_connection *c, struct mg_http_message *hm) { break; } case WECHAT_CONTACT_VERIFY_APPLY: { + wstring v3 = GetWStringParam(j_param, "v3"); + wstring v4 = GetWStringParam(j_param, "v4"); + int success = g_context.contact_mgr->VerifyApply(WS2LPWS(v3),WS2LPWS(v4)); + json ret_data = {{"code", success}, {"result", "OK"}}; + ret = ret_data.dump(); break; } case WECHAT_CONTACT_EDIT_REMARK: { diff --git a/src/wechat_function.h b/src/wechat_function.h index 9db923f..59ee100 100644 --- a/src/wechat_function.h +++ b/src/wechat_function.h @@ -79,7 +79,9 @@ #define WX_GET_CONTACT_OFFSET 0xc04e00 #define WX_DO_VERIFY_USER_OFFSET 0xc02100 #define WX_VERIFY_MSG_OFFSET 0xf59d40 - +#define WX_VERIFY_OK_OFFSET 0xa18bd0 +#define WX_NEW_ADD_FRIEND_HELPER_OFFSET 0xa17d50 +#define WX_FREE_ADD_FRIEND_HELPER_OFFSET 0xa17e70 // pushAttachTask