Impl accept new friend application

This commit is contained in:
Changhua 2022-08-21 08:45:16 +08:00
parent 1fb486ea62
commit 3fd3e589e7
14 changed files with 126 additions and 17 deletions

View File

@ -66,6 +66,7 @@ interface ISpy
int ExecDbQuery([ in, string ] const wchar_t *db,
[ in, string ] const wchar_t *sql, [out] int *pRow, [out] int *pCol,
[ out, size_is(, *pRow, *pCol) ] PPPRpcSqlResult *ret);
BOOL AcceptNewFriend([in, string] const wchar_t *v3, [in, string] const wchar_t *v4);
void EnableReceiveMsg();
void DisableReceiveMsg();

View File

@ -233,6 +233,22 @@ PPPRpcSqlResult RpcExecDbQuery(const wchar_t *db, const wchar_t *sql, int *pRow,
return pppRpcSqlResult;
}
BOOL AcceptNewFriend(const wchar_t *v3, const wchar_t *v4)
{
BOOL ret = 0;
unsigned long ulCode = 0;
RpcTryExcept { ret = client_AcceptNewFriend(v3, v4); }
RpcExcept(1)
{
ulCode = RpcExceptionCode();
printf("AcceptNewFriend exception 0x%lx = %ld\n", ulCode, ulCode);
}
RpcEndExcept;
return ret;
}
int server_ReceiveMsg(RpcMessage_t rpcMsg)
{
WxMessage_t msg;

View File

@ -15,3 +15,4 @@ PPRpcContact RpcGetContacts(int *pNum);
BSTR *RpcGetDbNames(int *pNum);
PPRpcTables RpcGetDbTables(const wchar_t *db, int *pNum);
PPPRpcSqlResult RpcExecDbQuery(const wchar_t *db, const wchar_t *sql, int *row, int *col);
BOOL AcceptNewFriend(const wchar_t *v3, const wchar_t *v4);

View File

@ -262,3 +262,5 @@ SqlRetVector_t WxExecDbQuery(wstring db, wstring sql)
return vvResults;
}
BOOL WxAcceptNewFriend(wstring v3, wstring v4) { return AcceptNewFriend(v3.c_str(), v4.c_str()); }

View File

@ -10,3 +10,4 @@
WxGetDbNames
WxGetDbTables
WxExecDbQuery
WxAcceptNewFriend

View File

@ -1,5 +1,6 @@
#pragma once
#include "framework.h"
#include <functional>
#include <map>
#include <string>
@ -55,3 +56,4 @@ MsgTypesMap_t WxGetMsgTypes();
vector<wstring> WxGetDbNames();
DbTableVector_t WxGetDbTables(wstring db);
SqlRetVector_t WxExecDbQuery(wstring db, wstring sql);
BOOL WxAcceptNewFriend(wstring v3, wstring v4);

View File

@ -1,4 +1,4 @@
#include <pybind11/functional.h>
#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
@ -81,6 +81,7 @@ PYBIND11_MODULE(wcferry, m)
m.def("WxGetDbTables", &WxGetDbTables, py::return_value_policy::reference, "Get DB tables.", py::arg("db"));
m.def("WxExecDbQuery", &WxExecDbQueryPy, py::return_value_policy::reference, "Get DB tables.", py::arg("db"),
py::arg("sql"));
m.def("WxAcceptNewFriend", &WxAcceptNewFriend, "Accept new friend application.", py::arg("v3"), py::arg("v4"));
#ifdef VERSION_INFO
m.attr("__version__") = VERSION_INFO;

View File

@ -166,6 +166,7 @@
<ItemGroup>
<ClInclude Include="..\Rpc\rpc_h.h" />
<ClInclude Include="..\SDK\util.h" />
<ClInclude Include="accept_new_friend.h" />
<ClInclude Include="exec_sql.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="get_contacts.h" />
@ -180,6 +181,7 @@
<ClCompile Include="..\Rpc\rpc_memory.cpp" />
<ClCompile Include="..\Rpc\rpc_s.c" />
<ClCompile Include="..\SDK\util.cpp" />
<ClCompile Include="accept_new_friend.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="exec_sql.cpp" />
<ClCompile Include="get_contacts.cpp" />

View File

@ -51,6 +51,9 @@
<ClInclude Include="spy.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="accept_new_friend.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@ -86,6 +89,9 @@
<ClCompile Include="spy.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="accept_new_friend.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="..\Rpc\rpc.idl">

57
Spy/accept_new_friend.cpp Normal file
View File

@ -0,0 +1,57 @@
#include "accept_new_friend.h"
#include "load_calls.h"
typedef struct NewFriendParam {
DWORD handle;
DWORD *status;
DWORD statusEnd1;
DWORD statusEnd2;
char buffer[0x3C];
} NewFriendParam_t;
extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr;
BOOL AcceptNewFriend(std::wstring v3, std::wstring v4)
{
BOOL isSucceeded = false;
DWORD acceptNewFriendCall1 = g_WeChatWinDllAddr + g_WxCalls.anf.call1;
DWORD acceptNewFriendCall2 = g_WeChatWinDllAddr + g_WxCalls.anf.call2;
DWORD acceptNewFriendHandle = g_WeChatWinDllAddr + g_WxCalls.anf.handle;
char buffer[0x94] = { 0 };
NewFriendParam_t param = { 0 };
DWORD status[9] = { 0xB2, (DWORD)&param, 0xB5, (DWORD)&param, 0xB0, (DWORD)&param, 0xB1, (DWORD)&param, 0x00 };
param.handle = acceptNewFriendHandle;
param.status = status;
param.statusEnd1 = (DWORD)&status[8];
param.statusEnd2 = (DWORD)&status[8];
NewFriendParam_t *pParam = &param;
__asm {
pushad;
pushfd;
push 0x0;
push 0x6;
sub esp, 0x14;
mov ecx, esp;
lea eax, v4;
push eax;
call acceptNewFriendCall1;
sub esp, 0x8;
push 0x0;
lea eax, buffer;
push eax;
lea eax, v3;
push eax;
mov ecx, pParam;
call acceptNewFriendCall2;
mov isSucceeded, eax;
popfd;
popad;
}
return isSucceeded;
}

6
Spy/accept_new_friend.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include "framework.h"
#include "string"
BOOL AcceptNewFriend(std::wstring v3, std::wstring v4);

View File

@ -4,19 +4,22 @@
#include "load_calls.h"
#define SUPPORT_VERSION L"3.7.0.30"
WxCalls_t wxCalls = { 0x2366538, // Login Status
{ 0x236607C, 0x23660F4, 0x2366128 }, // User Info: wxid, nickname, mobile
0x521D30, // Send Message
/* Receive Message:
Hook, call, type, self, id, msgXml, roomId, wxId, content */
{ 0x550F4C, 0xA96350, 0x38, 0x3C, 0x184, 0x1EC, 0x48, 0x170, 0x70 },
{ 0xBD780, 0x771980, 0x521640 }, // Send Image Message
/* Get Contacts:
Base, head, wxId, Code, Name, Gender, Country, Province, City*/
{ 0x23668F4, 0x4C, 0x30, 0x44, 0x8C, 0x184, 0x1D0, 0x1E4, 0x1F8 },
/* Exec Sql:
Exec, base, start, end, slot, name*/
{ 0x141BDF0, 0x2366934, 0x1428, 0x142C, 0x3C, 0x50 } };
WxCalls_t wxCalls = {
0x2366538, // Login Status
{ 0x236607C, 0x23660F4, 0x2366128 }, // User Info: wxid, nickname, mobile
0x521D30, // Send Message
/* Receive Message:
Hook, call, type, self, id, msgXml, roomId, wxId, content */
{ 0x550F4C, 0xA96350, 0x38, 0x3C, 0x184, 0x1EC, 0x48, 0x170, 0x70 },
{ 0xBD780, 0x771980, 0x521640 }, // Send Image Message
/* Get Contacts:
Base, head, wxId, Code, Name, Gender, Country, Province, City*/
{ 0x23668F4, 0x4C, 0x30, 0x44, 0x8C, 0x184, 0x1D0, 0x1E4, 0x1F8 },
/* Exec Sql:
Exec, base, start, end, slot, name*/
{ 0x141BDF0, 0x2366934, 0x1428, 0x142C, 0x3C, 0x50 },
{ 0x771980, 0x2AE8D0, 0x1EE40E0 } // Accept New Friend application
};
int LoadCalls(const wchar_t *version, WxCalls_t *calls)
{

View File

@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "accept_new_friend.h"
#include "exec_sql.h"
#include "get_contacts.h"
#include "receive_msg.h"
@ -277,3 +278,5 @@ int server_ExecDbQuery(const wchar_t *db, const wchar_t *sql, int *pRow, int *pC
return 0;
}
BOOL server_AcceptNewFriend(const wchar_t *v3, const wchar_t *v4) { return AcceptNewFriend(v3, v4); }

View File

@ -50,6 +50,12 @@ typedef struct Sql {
DWORD name;
} Sql_t;
typedef struct NewFriend {
DWORD call1;
DWORD call2;
DWORD handle;
} NewFriend_t;
typedef struct WxCalls {
DWORD login; // 登录状态
UserInfoCall_t ui; // 用户信息
@ -58,6 +64,8 @@ typedef struct WxCalls {
SendImg_t sendImg; // 发送图片
Contact_t contact; // 获取联系人
Sql_t sql; // 执行 SQL
NewFriend_t anf; // 通过好友申请
} WxCalls_t;
typedef struct TextStruct {