From 9172bcc62179f8cc9b7633703d6eade1707d4780 Mon Sep 17 00:00:00 2001 From: Changhua Date: Mon, 10 Apr 2023 23:11:54 +0800 Subject: [PATCH 1/3] Add extra data --- rpc/pb_types.h | 2 +- rpc/proto/wcf.proto | 19 +------------------ spy/load_calls.cpp | 2 +- spy/receive_msg.cpp | 1 + spy/rpc_server.cpp | 1 + spy/spy_types.h | 2 +- 6 files changed, 6 insertions(+), 21 deletions(-) diff --git a/rpc/pb_types.h b/rpc/pb_types.h index 185ac6b..c614126 100644 --- a/rpc/pb_types.h +++ b/rpc/pb_types.h @@ -43,5 +43,5 @@ typedef struct { string sender; string roomid; string content; - string extra_data; + string extra; } WxMsg_t; diff --git a/rpc/proto/wcf.proto b/rpc/proto/wcf.proto index 7cf877c..f8cefa8 100644 --- a/rpc/proto/wcf.proto +++ b/rpc/proto/wcf.proto @@ -3,23 +3,6 @@ syntax = "proto3"; package wcf; option java_package = "com.iamteer"; -/* -service Wcf { - rpc RpcIsLogin(Empty) returns (Response) {} - rpc RpcGetSelfWxid(Empty) returns (String) {} - rpc RpcEnableRecvMsg(Empty) returns (stream WxMsg) {} - rpc RpcDisableRecvMsg(Empty) returns (Response) {} - rpc RpcSendTextMsg(TextMsg) returns (Response) {} - rpc RpcSendPathMsg(PathMsg) returns (Response) {} - rpc RpcGetMsgTypes(Empty) returns (MsgTypes) {} - rpc RpcGetContacts(Empty) returns (Contacts) {} - rpc RpcGetDbNames(Empty) returns (DbNames) {} - rpc RpcGetDbTables(String) returns (DbTables) {} - rpc RpcExecDbQuery(DbQuery) returns (DbRows) {} - rpc RpcAcceptNewFriend(Verification) returns (Response) {} -} -*/ - enum Functions { FUNC_RESERVED = 0x00; FUNC_IS_LOGIN = 0x01; @@ -84,7 +67,7 @@ message WxMsg string sender = 6; // 消息发送者 string roomid = 7; // 群 id(如果是群消息的话) string content = 8; // 消息内容 - string extra_data = 9; // 附加内容 + string extra = 9; // 附加内容 } message TextMsg diff --git a/spy/load_calls.cpp b/spy/load_calls.cpp index 277cb70..63f901c 100644 --- a/spy/load_calls.cpp +++ b/spy/load_calls.cpp @@ -9,7 +9,7 @@ WxCalls_t wxCalls = { { 0x236607C, 0x23660F4, 0x2366128 }, // User Info: wxid, nickname, mobile 0x521D30, // Send Message /* Receive Message: - Hook, call, type, self, id, msgXml, roomId, wxId, content, extra_data */ + Hook, call, type, self, id, msgXml, roomId, wxId, content, extra */ { 0x550F4C, 0xA96350, 0x38, 0x3C, 0x184, 0x1EC, 0x48, 0x170, 0x70, 0x1AC }, { 0xBD780, 0x771980, 0x521640 }, // Send Image Message { 0xC3B70, 0x771980, 0x3ED8C0 }, // Send File Message diff --git a/spy/receive_msg.cpp b/spy/receive_msg.cpp index 1cf55ad..669959c 100644 --- a/spy/receive_msg.cpp +++ b/spy/receive_msg.cpp @@ -89,6 +89,7 @@ void DispatchMsg(DWORD reg) wxMsg.sender = GetStringByAddress(*p + g_WxCalls.recvMsg.roomId); } wxMsg.content = GetStringByAddress(*p + g_WxCalls.recvMsg.content); + wxMsg.extra = GetStringByAddress(*p + g_WxCalls.recvMsg.extra); { unique_lock lock(gMutex); diff --git a/spy/rpc_server.cpp b/spy/rpc_server.cpp index 623c152..ffb9d04 100644 --- a/spy/rpc_server.cpp +++ b/spy/rpc_server.cpp @@ -330,6 +330,7 @@ static void PushMessage() rsp.msg.wxmsg.sender = (char *)wxmsg.sender.c_str(); rsp.msg.wxmsg.roomid = (char *)wxmsg.roomid.c_str(); rsp.msg.wxmsg.content = (char *)wxmsg.content.c_str(); + rsp.msg.wxmsg.extra = (char *)wxmsg.extra.c_str(); gMsgQueue.pop(); LOG_DEBUG("Recv msg: {}", wxmsg.content); pb_ostream_t stream = pb_ostream_from_buffer(buffer, G_BUF_SIZE); diff --git a/spy/spy_types.h b/spy/spy_types.h index c38fcb4..44aef68 100644 --- a/spy/spy_types.h +++ b/spy/spy_types.h @@ -18,7 +18,7 @@ typedef struct RecvMsg { DWORD roomId; // 群聊时,为群ID;私聊时,为微信ID DWORD wxId; // 私聊时,为空;群聊时,为发送者微信ID DWORD content; // 消息内容地址 - DWORD extra_data; // 附加数据 + DWORD extra; // 附加数据 } RecvMsg_t; typedef struct Sendfile { From 218a4e72bbc2f2be572124d06db3dd6df4b4a92f Mon Sep 17 00:00:00 2001 From: Changhua Date: Mon, 10 Apr 2023 23:39:57 +0800 Subject: [PATCH 2/3] Insert home path to extra data --- spy/load_calls.cpp | 2 +- spy/receive_msg.cpp | 4 ++++ spy/spy_types.h | 1 + spy/user_info.cpp | 4 +++- spy/user_info.h | 5 ++++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/spy/load_calls.cpp b/spy/load_calls.cpp index 63f901c..67fbf65 100644 --- a/spy/load_calls.cpp +++ b/spy/load_calls.cpp @@ -6,7 +6,7 @@ #define SUPPORT_VERSION L"3.7.0.30" WxCalls_t wxCalls = { 0x2366538, // Login Status - { 0x236607C, 0x23660F4, 0x2366128 }, // User Info: wxid, nickname, mobile + { 0x236607C, 0x23660F4, 0x2366128, 0x2386F7C }, // User Info: wxid, nickname, mobile, home 0x521D30, // Send Message /* Receive Message: Hook, call, type, self, id, msgXml, roomId, wxId, content, extra */ diff --git a/spy/receive_msg.cpp b/spy/receive_msg.cpp index 669959c..be24287 100644 --- a/spy/receive_msg.cpp +++ b/spy/receive_msg.cpp @@ -7,6 +7,7 @@ #include "load_calls.h" #include "receive_msg.h" +#include "user_info.h" #include "util.h" // Defined in rpc_server.cpp @@ -90,6 +91,9 @@ void DispatchMsg(DWORD reg) } wxMsg.content = GetStringByAddress(*p + g_WxCalls.recvMsg.content); wxMsg.extra = GetStringByAddress(*p + g_WxCalls.recvMsg.extra); + if (!wxMsg.extra.empty()) { + wxMsg.extra = GetHomePath() + "\\" + wxMsg.extra; + } { unique_lock lock(gMutex); diff --git a/spy/spy_types.h b/spy/spy_types.h index 44aef68..8e7f9ec 100644 --- a/spy/spy_types.h +++ b/spy/spy_types.h @@ -6,6 +6,7 @@ typedef struct UserInfoCall { DWORD wxid; DWORD nickName; DWORD mobile; + DWORD home; } UserInfoCall_t; typedef struct RecvMsg { diff --git a/spy/user_info.cpp b/spy/user_info.cpp index e2e69e1..68b6301 100644 --- a/spy/user_info.cpp +++ b/spy/user_info.cpp @@ -6,7 +6,9 @@ extern WxCalls_t g_WxCalls; extern DWORD g_WeChatWinDllAddr; -std::string GetSelfWxid() +string GetHomePath() { return GET_STRING(g_WeChatWinDllAddr + g_WxCalls.ui.home); } + +string GetSelfWxid() { DWORD wxidType = 0; try { diff --git a/spy/user_info.h b/spy/user_info.h index ce4aa31..8a7131f 100644 --- a/spy/user_info.h +++ b/spy/user_info.h @@ -2,4 +2,7 @@ #include -std::string GetSelfWxid(); +using namespace std; + +string GetHomePath(); +string GetSelfWxid(); From 480df4ddfbf445863b4a63fa923cdff2bee33c0e Mon Sep 17 00:00:00 2001 From: Changhua Date: Mon, 10 Apr 2023 23:40:58 +0800 Subject: [PATCH 3/3] Add extra data --- python/wcferry/client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/wcferry/client.py b/python/wcferry/client.py index 72ce2d6..eee4246 100644 --- a/python/wcferry/client.py +++ b/python/wcferry/client.py @@ -61,14 +61,13 @@ class Wcf(): self.sender = msg.sender self.roomid = msg.roomid self.content = msg.content - self.extra_data = msg.extra_data + self.extra = msg.extra def __str__(self) -> str: s = f"{'自己发的:' if self._is_self else ''}" s += f"{self.sender}[{self.roomid}]:{self.id}:{self.type}:{self.xml.replace(chr(10), '').replace(chr(9),'')}\n" s += self.content - s += "\n" - s += self.extra_data + s += f"\n{self.extra}" if self.extra else "" return s def from_self(self) -> bool: