WeChatFerry/spy/send_msg.cpp

125 lines
3.2 KiB
C++
Raw Normal View History

#include <sstream>
2021-02-12 23:21:57 +08:00
#include <string>
2022-08-20 17:39:21 +08:00
#include <vector>
2021-02-12 23:21:57 +08:00
2022-10-15 20:25:42 +08:00
#include "send_msg.h"
2022-10-16 22:14:06 +08:00
#include "spy_types.h"
2021-02-12 23:21:57 +08:00
extern HANDLE g_hEvent;
extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr;
2022-08-20 17:39:21 +08:00
typedef struct AtList {
DWORD start;
DWORD end1;
DWORD end2;
} AtList_t;
void SendTextMessage(wstring wxid, wstring msg, wstring atWxids)
2021-02-12 23:21:57 +08:00
{
2022-08-20 17:39:21 +08:00
char buffer[0x3B0] = { 0 };
AtList_t atList = { 0 };
TextStruct_t txtMsg = { 0 };
TextStruct_t txtWxid = { 0 };
TextStruct_t *tsArray = NULL;
2021-02-12 23:21:57 +08:00
// 发送消息Call地址 = 微信基址 + 偏移
DWORD sendCallAddress = g_WeChatWinDllAddr + g_WxCalls.sendTextMsg;
txtMsg.text = (wchar_t *)msg.c_str();
txtMsg.size = msg.size();
txtMsg.capacity = msg.capacity();
2022-08-20 17:39:21 +08:00
txtWxid.text = (wchar_t *)wxid.c_str();
txtWxid.size = wxid.size();
txtWxid.capacity = wxid.capacity();
2021-02-12 23:21:57 +08:00
2022-08-20 17:39:21 +08:00
wstring tmp = atWxids;
if (!tmp.empty()) {
int i = 0;
wstring wstr;
vector<wstring> vAtWxids;
wstringstream wss(tmp);
while (wss.good()) {
getline(wss, wstr, L',');
vAtWxids.push_back(wstr);
}
tsArray = new TextStruct_t[vAtWxids.size() + 1];
// memset(tsArray, 0, (vAtWxids.size() + 1) * sizeof(TextStruct_t));
for (auto it = vAtWxids.begin(); it != vAtWxids.end(); it++) {
tsArray[i].text = (wchar_t *)it->c_str();
tsArray[i].size = it->size();
tsArray[i].capacity = it->capacity();
i++;
}
2021-02-12 23:21:57 +08:00
2022-08-20 17:39:21 +08:00
atList.start = (DWORD)tsArray;
atList.end1 = (DWORD)&tsArray[i];
atList.end2 = (DWORD)&tsArray[i];
}
__asm
{
lea eax, atList;
push 0x01;
push eax;
lea edi, txtMsg;
push edi;
lea edx, txtWxid;
2021-02-12 23:21:57 +08:00
lea ecx, buffer;
2022-08-20 17:39:21 +08:00
call sendCallAddress;
add esp, 0xC;
}
if (tsArray)
{
delete[] tsArray;
tsArray = NULL;
2021-02-12 23:21:57 +08:00
}
}
2021-08-22 21:57:16 +08:00
void SendImageMessage(wstring wxid, wstring path)
2021-08-22 21:57:16 +08:00
{
if (g_WeChatWinDllAddr == 0) {
return;
2022-08-20 17:39:21 +08:00
}
2022-08-06 21:44:59 +08:00
DWORD tmpEAX = 0;
2022-08-06 21:44:26 +08:00
char buf1[0x48] = { 0 };
char buf2[0x3B0] = { 0 };
2021-08-22 21:57:16 +08:00
TextStruct_t imgWxid = { 0 };
TextStruct_t imgPath = { 0 };
imgWxid.text = (wchar_t *)wxid.c_str();
imgWxid.size = wxid.size();
imgWxid.capacity = wxid.capacity();
2021-08-22 21:57:16 +08:00
imgPath.text = (wchar_t *)path.c_str();
imgPath.size = path.size();
imgPath.capacity = path.capacity();
2021-08-22 21:57:16 +08:00
// 发送图片Call地址 = 微信基址 + 偏移
DWORD sendCall1 = g_WeChatWinDllAddr + g_WxCalls.sendImg.call1;
DWORD sendCall2 = g_WeChatWinDllAddr + g_WxCalls.sendImg.call2;
DWORD sendCall3 = g_WeChatWinDllAddr + g_WxCalls.sendImg.call3;
__asm {
pushad
2022-08-20 17:39:21 +08:00
call sendCall1
sub esp, 0x14
mov tmpEAX, eax
lea eax, buf1
mov ecx, esp
lea edi, imgPath
push eax
call sendCall2
mov ecx, dword ptr[tmpEAX]
lea eax, imgWxid
push edi
push eax
lea eax, buf2
push eax
call sendCall3
2022-08-06 21:44:26 +08:00
popad
2021-08-22 21:57:16 +08:00
}
}