From 3d8ed813bed327749f3b59c09b8163fd0f438852 Mon Sep 17 00:00:00 2001 From: hugy <504650082@qq.com> Date: Mon, 13 Feb 2023 11:30:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E6=98=B5?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 93 ++++++++++++++++++++++++++++++++++++++++++++---- src/api.cc | 15 +++++++- src/api.h | 1 + src/chat_room.cc | 63 ++++++++++++++++++++++++++++++++ src/chat_room.h | 2 ++ src/contact.cc | 37 ++++++++++++++++++- src/contact.h | 2 ++ 7 files changed, 205 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7165564..29d99ef 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ wechat hook 。PC端微信逆向学习。支持3.8.0.41,3.8.1.26,3.9.0.28版 本项目是个人学习学习逆向的项目,主要参考 https://github.com/ljc545w/ComWeChatRobot ,在此基础上实现了微信的的其它版本的部分内容。 #### 使用说明: -支持的版本3.8.0.41,3.8.1.26,3.9.0.28。 -src:主要的dll代码 -tool:简单的注入工具,一个是控制台,一个是图形界面。 -python: 简单的服务器,用以接收消息内容。 -release:编译好的dll。 +支持的版本3.8.0.41,3.8.1.26, 3.9.0.28。 +src:主要的dll代码 +tool:简单的注入工具,一个是控制台,一个是图形界面。 +python: 简单的服务器,用以接收hook的消息内容。 + 0.首先安装对应的微信版本,主分支是3.8.0.41版本,分支对应相应的微信版本号. 1.通过cmake构建成功后,将wxhelper.dll注入到微信,本地启动tcp server,监听19088端口。 @@ -99,7 +99,9 @@ vcpkg 2023-02-08 : 新增朋友圈消息。 -2023-02-09 : 新增3.9.0.28版本基础功能。 +2023-02-09 : 新增3.9.0.28版本基础功能。 + +2023-02-13 : 新增查询昵称功能。 #### 功能预览: 0.检查是否登录 @@ -543,6 +545,43 @@ vcpkg ``` +#### 26.获取群成员昵称** +###### 接口功能 +> 获取群成员群内昵称 + +###### 接口地址 +> [/api/?type=26](/api/?type=26) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|chatRoomId |true |string| 群id | +|memberId |true |string| 群成员id | + +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,1成功, 0失败| +|result|string|成功提示| +|nickname|string|昵称| + + +###### 接口示例 +入参: +``` javascript +{ + "chatRoomId":"123@chatroom", + "memberId":"wxid_123" +} +``` +响应: +``` javascript +{"code":1,"nickname":"昵称","result":"OK"} +``` + #### 27.删除群成员** ###### 接口功能 @@ -1241,6 +1280,48 @@ vcpkg {"code":1,"result":"OK"} ``` + +#### 55.获取联系人或者群名称** +###### 接口功能 +> 根据wxid,获取联系人微信名称,传入群id获取群名称,传入群内非好友获取的是微信名称不是群内昵称。 + +###### 接口地址 +> [/api/?type=55](/api/?type=55) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|id |true |string| wxid或者群id | + + + +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,1成功, -1失败| +|result|string|成功提示| +|name|string|名称| + + +###### 接口示例 +入参: +``` javascript +{ + "id":"wxid_123" + +} + +``` +响应: +``` javascript +{"code":1,"name":"文件助手","result":"OK"} +``` + + + #### 感谢 https://github.com/ljc545w/ComWeChatRobot diff --git a/src/api.cc b/src/api.cc index 37d6732..8e6a5c0 100644 --- a/src/api.cc +++ b/src/api.cc @@ -355,6 +355,12 @@ void api_handle(mg_http_message *hm, struct mg_connection *c, string &ret) { break; } case WECHAT_CHATROOM_GET_MEMBER_NICKNAME: { + wstring room_id = get_http_req_param(hm, j_param, "chatRoomId", is_post); + wstring member_id = get_http_req_param(hm, j_param, "memberId", is_post); + + wstring nickname = GetChatRoomMemberNickname(WS2LW(room_id),WS2LW(member_id)); + json ret_data = {{"code", 1}, {"result", "OK"},{"nickname",unicode_to_utf8(WS2LW(nickname))}}; + ret = ret_data.dump(); break; } case WECHAT_CHATROOM_DEL_MEMBER: { @@ -598,13 +604,20 @@ void api_handle(mg_http_message *hm, struct mg_connection *c, string &ret) { ret = ret_data.dump(); break; } - case WECHAT_SNS_GET_NEXT_PAGE:{ + case WECHAT_SNS_GET_NEXT_PAGE: { ULONG64 snsid = get_http_param_ulong64(hm, j_param, "snsId", is_post); int success = GetNextPage(snsid); json ret_data = {{"code", success}, {"result", "OK"}}; ret = ret_data.dump(); break; } + case WECHAT_CONTACT_NAME:{ + wstring pri_id = get_http_req_param(hm, j_param, "id", is_post); + wstring name =GetContactOrChatRoomNickname(WS2LW(pri_id)); + json ret_data = {{"code", 1}, {"result", "OK"},{"name",unicode_to_utf8(WS2LW(name))}}; + ret = ret_data.dump(); + break; + } default: break; } diff --git a/src/api.h b/src/api.h index 7c04269..970d9e0 100644 --- a/src/api.h +++ b/src/api.h @@ -69,6 +69,7 @@ typedef enum WECHAT_HTTP_APISTag WECHAT_REMOVE_TOP_MSG, WECHAT_SNS_GET_FIRST_PAGE, WECHAT_SNS_GET_NEXT_PAGE, + WECHAT_CONTACT_NAME, } WECHAT_HTTP_APIS, *PWECHAT_HTTP_APIS; diff --git a/src/chat_room.cc b/src/chat_room.cc index 51164e7..90ac7fb 100644 --- a/src/chat_room.cc +++ b/src/chat_room.cc @@ -23,6 +23,10 @@ using namespace std; #define WX_TOP_MSG_OFFSET 0xb727e0 #define WX_REMOVE_TOP_MSG_OFFSET 0xb725a0 #define WX_FREE_CHAT_MSG_INSTANCE_COUNTER_OFFSET 0x6f5370 +#define WX_GET_MEMBER_NICKNAME_OFFSET 0xb703f0 +#define WX_CONTACT_MGR_INSTANCE_OFFSET 0x6f8990 +#define WX_GET_CONTACT_OFFSET 0xb93b20 +#define WX_FREE_CONTACT_OFFSET 0xe23690 int GetChatRoomDetailInfo(wchar_t* chat_room_id, ChatRoomInfoInner& room_info) { int success = 0; @@ -352,4 +356,63 @@ int RemoveTopMsg(wchar_t* chat_room_id,ULONG64 msg_id){ } return success; +} + + + +std::wstring GetChatRoomMemberNickname(wchar_t* chat_room_id,wchar_t* wxid){ + WeChatString chat_room(chat_room_id); + WeChatString member_id(wxid); + WeChatString nickname(NULL); + DWORD base = GetWeChatWinBase(); + DWORD get_chat_room_mgr_addr = base + WX_CHAT_ROOM_MGR_OFFSET; + DWORD get_nickname_addr = base + WX_GET_MEMBER_NICKNAME_OFFSET; + DWORD contact_mgr_addr = base + WX_CONTACT_MGR_INSTANCE_OFFSET; + DWORD get_contact_addr = base + WX_GET_CONTACT_OFFSET; + DWORD free_contact_addr = base + WX_FREE_CONTACT_OFFSET; + __asm{ + PUSHAD + PUSHFD + CALL get_chat_room_mgr_addr + LEA ECX,nickname + PUSH ECX + LEA ECX,member_id + PUSH ECX + LEA ECX,chat_room + PUSH ECX + MOV ECX,EAX + CALL get_nickname_addr + POPFD + POPAD + } + wstring name = L""; + if (nickname.ptr) { + name += wstring(nickname.ptr); + }else { + char buff[0x440] = {0}; + __asm { + PUSHAD + PUSHFD + CALL contact_mgr_addr + LEA ECX,buff + PUSH ECX + LEA ECX,member_id + PUSH ECX + MOV ECX,EAX + CALL get_contact_addr + POPFD + POPAD + } + name += READ_WSTRING(buff, 0x6C); + + __asm{ + PUSHAD + PUSHFD + LEA ECX,buff + CALL free_contact_addr + POPFD + POPAD + } + } + return name; } \ No newline at end of file diff --git a/src/chat_room.h b/src/chat_room.h index e237b61..336aa0b 100644 --- a/src/chat_room.h +++ b/src/chat_room.h @@ -11,4 +11,6 @@ int ModChatRoomMemberNickName(wchar_t* chat_room_id,wchar_t* wxid,wchar_t * nick int SetTopMsg(wchar_t* wxid,ULONG64 msg_id); int RemoveTopMsg(wchar_t* chat_room_id,ULONG64 msg_id); + +std::wstring GetChatRoomMemberNickname(wchar_t* chat_room_id,wchar_t* wxid); #endif \ No newline at end of file diff --git a/src/contact.cc b/src/contact.cc index 43ccccf..0bf39fe 100644 --- a/src/contact.cc +++ b/src/contact.cc @@ -11,6 +11,9 @@ using namespace std; #define WX_SYNC_MGR_OFFSET 0xa87fd0 #define WX_SET_VALUE_OFFSET 0x1f80900 #define WX_DO_DEL_CONTACT_OFFSET 0xca6480 +#define WX_FREE_CONTACT_OFFSET 0xe23690 +#define WX_GET_CONTACT_OFFSET 0xb93b20 + int GetAllContact(vector &vec) { DWORD base = GetWeChatWinBase(); DWORD get_instance = base + WX_CONTACT_MGR_INSTANCE_OFFSET; @@ -100,4 +103,36 @@ int DelContact(wchar_t *wxid) { return success; } - +std::wstring GetContactOrChatRoomNickname(wchar_t *id) { + int success = -1; + char buff[0x440] = {0}; + WeChatString pri(id); + DWORD base = GetWeChatWinBase(); + DWORD contact_mgr_addr = base + WX_CONTACT_MGR_INSTANCE_OFFSET; + DWORD get_contact_addr = base + WX_GET_CONTACT_OFFSET; + DWORD free_contact_addr = base + WX_FREE_CONTACT_OFFSET; + wstring name = L""; + __asm { + PUSHAD + PUSHFD + CALL contact_mgr_addr + LEA ECX,buff + PUSH ECX + LEA ECX,pri + PUSH ECX + MOV ECX,EAX + CALL get_contact_addr + POPFD + POPAD + } + name += READ_WSTRING(buff, 0x6C); + __asm { + PUSHAD + PUSHFD + LEA ECX,buff + CALL free_contact_addr + POPFD + POPAD + } + return name; +} diff --git a/src/contact.h b/src/contact.h index 9ec6c76..0c1f981 100644 --- a/src/contact.h +++ b/src/contact.h @@ -8,4 +8,6 @@ int GetAllContact(std::vector &vec); int DelContact(wchar_t* wxid); + +std::wstring GetContactOrChatRoomNickname(wchar_t* id); #endif \ No newline at end of file