-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrecvmsg.cpp
295 lines (248 loc) · 6.43 KB
/
recvmsg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#include "stdafx.h"
#include "mhook.h"
#include <tchar.h>
#include "weixin.h"
#include "sdk.h"
#include <map>
#include <string>
#pragma comment(lib, "User32.lib")
const SuppWxCfg g_Supported_wxTextMsg_Version[] = {
{ TEXT("2.6.7.40"), 0x2E7980 ,{0}}, //
};
const SuppWxCfg g_Supported_wxMoneyMsg_Version[] = {
//{ TEXT("2.6.7.40"), 0x235C30 ,{0}}, //voiicemsg
{ TEXT("2.6.7.40"), 0x180730 ,{0}}, //
};
typedef int(__stdcall* PFNVoiceDecode)(int a1, int a2, int voice);
typedef int(__stdcall* PFNVoiceDecodeInternal)(int voice, int size, int from, int a4);
//typedef void(__stdcall* PFNRecvMoney)(int a1, pwxmsg msg, int msg1);
typedef void(__stdcall* PFNRecvMoney)();
PFNRecvMoney pfnRecvMoneyMsg = NULL;
unsigned int pfnRecvTransferMsgClk = NULL;
unsigned int pfnRecvPayMsgClk = NULL;
//
//typedef struct _RECV_MSG
//{
// char unk[0x40];//
// wstring wxid1;//40
// wstring wxid2;//4c
// char unk1[0x10];//58
// wstring msg;//68
// char unk2[0x10];//74
// ;//84
//}
typedef struct _RECV_MSG_PACK
{
pwxmsg msg;
pwxmsg msg_end;
void* unk;
}RecvMsgPack, *PRecvMsgPack;
typedef int(__stdcall* PFNRecvMsg)(PRecvMsgPack msg);
PFNRecvMsg pfnRecvTextMsg = NULL;
unsigned int pfnRecvTextMsgClk = NULL;
int __stdcall fakeRecvTextMsg(PRecvMsgPack msg)
{
__asm {
pushad;
pushfd;
}
int this_ = 0;
__asm mov this_, ecx;
if (msg && msg->msg) {
if (pfnRecvTextMsgClk) {
CoreWSDKClkRecvTextMsg(
pfnRecvTextMsgClk,
msg->msg->wxid1.buf,
msg->msg->msg.buf
);
}
}
__asm {
popfd;
popad;
}
//__asm mov ecx, this_;
//int ret = pfnRecvTextMsg(msg);
int result = 0;
__asm {
mov eax, msg; //ERROR: lea eax, msg
push eax;
mov ecx, this_;
call pfnRecvTextMsg;
mov result, eax;
}
return result;
}
void fakeRecvMoneyInternal(pwxmsg msg)
{
//OutputDebugStringW(msg->msg.buf);
if (wcsstr(msg->msg.buf, L"![CDATA[΢ÐÅתÕË]]"))
{
wchar_t* money = SplitStr(msg->msg.buf,
L"![CDATA[΢ÐÅתÕË]]></title><des><![CDATA[",
L"¡£");
wchar_t* transferid = SplitStr(msg->msg.buf,
L"<transferid><![CDATA[",
L"]]></transferid>");
if (money) {
/*wchar_t recv_msg[4000] = { 0 };
wsprintfW(recv_msg, L"%ws: %ws", msg->wxid1.buf, money);
OutputDebugStringW(recv_msg);*/
if (pfnRecvTransferMsgClk) {
CoreWSDKClkRecvTransferMsg(
pfnRecvTransferMsgClk,
msg->wxid1.buf,
transferid,
money
);
}
delete[] money;
}
if (transferid) {
delete[] transferid;
}
}
else if (wcsstr(msg->msg.buf, L"<PayMsgType>9</PayMsgType>"))
{
wchar_t* tradeno = SplitStr(msg->msg.buf,
L"<outtradeno>",
L"</outtradeno>");
if (tradeno) {
wchar_t* username = SplitStr(msg->msg.buf,
L"<username><![CDATA[",
L"]]></username>");
wchar_t* money = SplitStr(msg->msg.buf,
L"<fee>",
L"</fee>");
//OutputDebugStringW(money);
wchar_t money1[100] = { 0 };
int mm = _wtoi(money);
double m = (double)mm / 100;
StringCbPrintfW(money1, 100, L"%.2f", m);
if (money && username) {
/*OutputDebugStringW(msg->msg.buf);
OutputDebugStringW(money1);
OutputDebugStringW(tradeno);
OutputDebugStringW(username);*/
if (pfnRecvPayMsgClk) {
CoreWSDKClkRecvPayMsg(
pfnRecvPayMsgClk,
username,
tradeno,
money1
);
}
delete[] username;
delete[] money;
}
}
}
}
// void __stdcall fakeRecvMoney(int a1, pwxmsg msg, int msg1) //0x235C30 2.6.7.40
void __stdcall fakeRecvMoney()
{
__asm {
pushad;
pushfd;
}
DWORD dwEcx = 0;
__asm mov dwEcx, ecx;
fakeRecvMoneyInternal((pwxmsg)dwEcx);
__asm {
popfd;
popad;
}
if (pfnRecvMoneyMsg) {
__asm mov ecx, dwEcx;
pfnRecvMoneyMsg();
}
}
int InitRecvTextMsg()
{
HMODULE hMod = GetModuleHandleA("WechatWin.dll");
if (hMod == NULL) {
return ERROR_NOT_ALL_ASSIGNED;
}
if (pfnRecvTextMsg) {
return ERROR_SUCCESS;
}
int ret = HookTemplate(hMod,
g_Supported_wxTextMsg_Version,
ARRAYSIZE(g_Supported_wxTextMsg_Version),
(PVOID*)&pfnRecvTextMsg,
fakeRecvTextMsg);
return ret;
}
void UnInitRecvTextMsg()
{
if (pfnRecvTextMsg) {
Mhook_Unhook((PVOID*)&pfnRecvTextMsg);
}
}
int InitRecvMoneyMsg()
{
HMODULE hMod = GetModuleHandleA("WechatWin.dll");
if (hMod == NULL) {
return ERROR_NOT_ALL_ASSIGNED;
}
if (pfnRecvMoneyMsg) {
return ERROR_SUCCESS;
}
int ret = HookTemplate(hMod,
g_Supported_wxMoneyMsg_Version,
ARRAYSIZE(g_Supported_wxMoneyMsg_Version),
(PVOID*)&pfnRecvMoneyMsg,
fakeRecvMoney);
return ret;
}
void UnInitRecvMoneyMsg()
{
if (pfnRecvMoneyMsg) {
Mhook_Unhook((PVOID*)&pfnRecvMoneyMsg);
}
}
int CoreRecvTextMsg(unsigned int funptr)
{
if (funptr) {
int ret = InitRecvTextMsg();
if (ret == ERROR_SUCCESS) {
pfnRecvTextMsgClk = funptr;
}
return ret;
}
else {
UnInitRecvTextMsg();
pfnRecvTextMsgClk = NULL;
return ERROR_SUCCESS;
}
}
int CoreRecvTransferMsg(unsigned int funptr)
{
if (funptr) {
int ret = InitRecvMoneyMsg();
if (ret == ERROR_SUCCESS) {
pfnRecvTransferMsgClk = funptr;
}
return ret;
}
else {
UnInitRecvMoneyMsg();
pfnRecvTransferMsgClk = NULL;
return ERROR_SUCCESS;
}
}
int CoreRecvPayMsg(unsigned int funptr)
{
if (funptr) {
int ret = InitRecvMoneyMsg();
if (ret == ERROR_SUCCESS) {
pfnRecvPayMsgClk = funptr;
}
return ret;
}
else {
UnInitRecvMoneyMsg();
pfnRecvPayMsgClk = NULL;
return ERROR_SUCCESS;
}
}