diff --git a/spy/accept_new_friend.cpp b/spy/accept_new_friend.cpp index 97de721..a2031a5 100644 --- a/spy/accept_new_friend.cpp +++ b/spy/accept_new_friend.cpp @@ -1,5 +1,9 @@ -#include "accept_new_friend.h" +#include "framework.h" + +#include "accept_new_friend.h" #include "load_calls.h" +#include "util.h" +#include "log.h" typedef struct NewFriendParam { DWORD handle; @@ -12,9 +16,9 @@ typedef struct NewFriendParam { extern WxCalls_t g_WxCalls; extern DWORD g_WeChatWinDllAddr; -BOOL AcceptNewFriend(std::wstring v3, std::wstring v4) +int AcceptNewFriend(std::string v3, std::string v4) { - BOOL isSucceeded = false; + int isSucceeded = false; DWORD acceptNewFriendCall1 = g_WeChatWinDllAddr + g_WxCalls.anf.call1; DWORD acceptNewFriendCall2 = g_WeChatWinDllAddr + g_WxCalls.anf.call2; @@ -30,6 +34,10 @@ BOOL AcceptNewFriend(std::wstring v3, std::wstring v4) param.statusEnd2 = (DWORD)&status[8]; NewFriendParam_t *pParam = ¶m; + LOG_INFO("v3: {}\nv4: {}", v3, v4); + const wchar_t *wsV3 = String2Wstring(v3).c_str(); + const wchar_t *wsV4 = String2Wstring(v4).c_str(); + __asm { pushad; pushfd; @@ -37,14 +45,14 @@ BOOL AcceptNewFriend(std::wstring v3, std::wstring v4) push 0x6; sub esp, 0x14; mov ecx, esp; - lea eax, v4; + lea eax, wsV4; push eax; call acceptNewFriendCall1; sub esp, 0x8; push 0x0; lea eax, buffer; push eax; - lea eax, v3; + lea eax, wsV3; push eax; mov ecx, pParam; call acceptNewFriendCall2; diff --git a/spy/accept_new_friend.h b/spy/accept_new_friend.h index 2ae834a..2882fdc 100644 --- a/spy/accept_new_friend.h +++ b/spy/accept_new_friend.h @@ -1,6 +1,5 @@ #pragma once -#include "framework.h" #include "string" -BOOL AcceptNewFriend(std::wstring v3, std::wstring v4); +int AcceptNewFriend(std::string v3, std::string v4); diff --git a/spy/rpc_server.cpp b/spy/rpc_server.cpp index 0f28677..c0e9546 100644 --- a/spy/rpc_server.cpp +++ b/spy/rpc_server.cpp @@ -345,6 +345,33 @@ bool func_exec_db_query(char *db, char *sql, uint8_t *out, size_t *len) return true; } +bool func_accept_friend(char *v3, char *v4, uint8_t *out, size_t *len) +{ + Response rsp = Response_init_default; + rsp.func = Functions_FUNC_SEND_IMG; + rsp.which_msg = Response_status_tag; + rsp.msg.status = 0; + + if ((v3 == NULL) || (v4 == NULL)) { + rsp.msg.status = -1; + LOG_ERROR("Empty V3 or V4."); + } else { + rsp.msg.status = AcceptNewFriend(v3, v4); + if (rsp.msg.status != 1) { + LOG_ERROR("AcceptNewFriend failed: {}", rsp.msg.status); + } + } + + pb_ostream_t stream = pb_ostream_from_buffer(out, *len); + if (!pb_encode(&stream, Response_fields, &rsp)) { + LOG_ERROR("Encoding failed: {}", PB_GET_ERROR(&stream)); + return false; + } + *len = stream.bytes_written; + + return true; +} + static bool dispatcher(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len) { bool ret = false; @@ -413,6 +440,11 @@ static bool dispatcher(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len ret = func_exec_db_query(req.msg.query.db, req.msg.query.sql, out, out_len); break; } + case Functions_FUNC_ACCEPT_FRIEND: { + LOG_INFO("[Functions_FUNC_ACCEPT_FRIEND]"); + ret = func_accept_friend(req.msg.v.v3, req.msg.v.v4, out, out_len); + break; + } default: { LOG_ERROR("[UNKNOW FUNCTION]"); break;