feat: 3.9.2.26发送文本,图片,文件

This commit is contained in:
hugy 2023-05-11 00:04:46 +08:00
parent 83d779c072
commit 18e34cd11b
14 changed files with 68 additions and 7777 deletions

View File

@ -4,15 +4,18 @@ project(wxhelper VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D '_UNICODE' /D 'UNICODE' /D 'ELPP_THREAD_SAFE'")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D '_UNICODE' /D 'UNICODE' ")
file(GLOB CPP_FILES ${PROJECT_SOURCE_DIR}/src/*.cc ${PROJECT_SOURCE_DIR}/src/*.cpp) file(GLOB CPP_FILES ${PROJECT_SOURCE_DIR}/src/*.cc ${PROJECT_SOURCE_DIR}/src/*.cpp)
include_directories(${VCPKG_INSTALLED_DIR}/x86-windows/include) include_directories(${VCPKG_INSTALLED_DIR}/x86-windows/include ${PROJECT_SOURCE_DIR}/spdlog/include)
add_subdirectory(spdlog)
# add_subdirectory(3rd) # add_subdirectory(3rd)
# add_subdirectory(source) # add_subdirectory(source)
@ -29,6 +32,7 @@ add_library(wxhelper SHARED ${CPP_FILES} )
target_link_libraries(wxhelper PRIVATE nlohmann_json::nlohmann_json) target_link_libraries(wxhelper PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(wxhelper PRIVATE unofficial::mongoose::mongoose) target_link_libraries(wxhelper PRIVATE unofficial::mongoose::mongoose)
target_include_directories(wxhelper PRIVATE spdlog )
# target_link_libraries(wxhelper PRIVATE spdlog::spdlog spdlog::spdlog_header_only) # target_link_libraries(wxhelper PRIVATE spdlog::spdlog spdlog::spdlog_header_only)
# target_link_libraries(wxhelper PRIVATE minhook::minhook) # target_link_libraries(wxhelper PRIVATE minhook::minhook)

5
doc/3.9.2.26.md Normal file
View File

@ -0,0 +1,5 @@
## 3.9.2.26版本,预览功能没有的接口,不能使用,文档仅供参考。
#### 功能预览:
2.发送文本
5.发送图片
6.发送文件

View File

@ -1,6 +1,5 @@
#include "pch.h" #include "pch.h"
#include "account_mgr.h" #include "account_mgr.h"
#include "easylogging++.h"
#include "wechat_function.h" #include "wechat_function.h"

View File

@ -2,8 +2,6 @@
#include "db.h" #include "db.h"
#include "base64.h" #include "base64.h"
#include "easylogging++.h"
#include "wechat_function.h" #include "wechat_function.h"
#include "utils.h" #include "utils.h"
using namespace std; using namespace std;
@ -462,9 +460,9 @@ std::vector<void *> DB::GetDbHandles() {
dbs_.push_back(db_end); dbs_.push_back(db_end);
#ifdef _DEBUG #ifdef _DEBUG
for (unsigned int i = 0; i < dbs_.size() - 1; i++) { for (unsigned int i = 0; i < dbs_.size() - 1; i++) {
LOG(INFO) << "dbname =" << dbs_[i].db_name; // LOG(INFO) << "dbname =" << dbs_[i].db_name;
LOG(INFO) << "handle =" << dbs_[i].handle; // LOG(INFO) << "handle =" << dbs_[i].handle;
LOG(INFO) << "table_count =" << dbs_[i].tables.size(); // LOG(INFO) << "table_count =" << dbs_[i].tables.size();
} }
#endif #endif
vector<void *> ret_array; vector<void *> ret_array;
@ -492,7 +490,7 @@ unsigned int DB::GetLocalIdByMsgId(ULONG64 msgid, int &dbIndex) {
swprintf_s(dbname, L"MSG%d.db", i); swprintf_s(dbname, L"MSG%d.db", i);
DWORD handle = GetDbHandleByDbName(dbname); DWORD handle = GetDbHandleByDbName(dbname);
if (handle == 0) { if (handle == 0) {
LOG(INFO) << "MSG db handle is null"; // LOG(INFO) << "MSG db handle is null";
return 0; return 0;
} }
vector<vector<string>> result; vector<vector<string>> result;
@ -517,7 +515,7 @@ vector<string> DB::GetChatMsgByMsgId(ULONG64 msgid) {
swprintf_s(dbname, L"MSG%d.db", i); swprintf_s(dbname, L"MSG%d.db", i);
DWORD handle = GetDbHandleByDbName(dbname); DWORD handle = GetDbHandleByDbName(dbname);
if (handle == 0) { if (handle == 0) {
LOG(INFO) << "MSG db handle is null"; // LOG(INFO) << "MSG db handle is null";
return {}; return {};
} }
vector<vector<string>> result; vector<vector<string>> result;
@ -536,7 +534,7 @@ std::string DB::GetVoiceBuffByMsgId(ULONG64 msgid) {
swprintf_s(dbname, L"MediaMSG%d.db", i); swprintf_s(dbname, L"MediaMSG%d.db", i);
DWORD handle = GetDbHandleByDbName(dbname); DWORD handle = GetDbHandleByDbName(dbname);
if (handle == 0) { if (handle == 0) {
LOG(INFO) << "Media db handle is null"; // LOG(INFO) << "Media db handle is null";
return ""; return "";
} }
vector<vector<string>> result; vector<vector<string>> result;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
#include "pch.h" #include "pch.h"
#include "global_context.h" #include "global_context.h"
#include "http_server.h" #include "http_server.h"
#include "easylogging++.h"
#include "hooks.h" #include "hooks.h"

View File

@ -1,10 +1,9 @@
#include <Ws2tcpip.h> #include "pch.h"
#include <Ws2tcpip.h>
#include <winsock2.h> #include <winsock2.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "easylogging++.h"
#include "pch.h"
#include "wechat_function.h" #include "wechat_function.h"
using namespace nlohmann; using namespace nlohmann;
using namespace std; using namespace std;
@ -57,12 +56,12 @@ void SendSocketMessage(InnerMessageStruct *msg) {
string jstr = j_msg.dump() + "\n"; string jstr = j_msg.dump() + "\n";
if (server_port_ == 0) { if (server_port_ == 0) {
LOG(INFO) << "http server port error :" << server_port_; // LOG(INFO) << "http server port error :" << server_port_;
return; return;
} }
SOCKET client_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); SOCKET client_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (client_socket < 0) { if (client_socket < 0) {
LOG(INFO) << "socket init fail"; // LOG(INFO) << "socket init fail";
return; return;
} }
BOOL status = false; BOOL status = false;
@ -73,13 +72,13 @@ void SendSocketMessage(InnerMessageStruct *msg) {
InetPtonA(AF_INET, server_ip_, &client_addr.sin_addr.s_addr); InetPtonA(AF_INET, server_ip_, &client_addr.sin_addr.s_addr);
if (connect(client_socket, reinterpret_cast<sockaddr *>(&client_addr), if (connect(client_socket, reinterpret_cast<sockaddr *>(&client_addr),
sizeof(sockaddr)) < 0) { sizeof(sockaddr)) < 0) {
LOG(INFO) << "socket connect fail"; // LOG(INFO) << "socket connect fail";
return; return;
} }
char recv_buf[1024] = {0}; char recv_buf[1024] = {0};
int ret = send(client_socket, jstr.c_str(), jstr.size(), 0); int ret = send(client_socket, jstr.c_str(), jstr.size(), 0);
if (ret == -1 || ret == 0) { if (ret == -1 || ret == 0) {
LOG(INFO) << "socket send fail ,ret:" << ret; // LOG(INFO) << "socket send fail ,ret:" << ret;
closesocket(client_socket); closesocket(client_socket);
return; return;
} }
@ -87,7 +86,7 @@ void SendSocketMessage(InnerMessageStruct *msg) {
ret = recv(client_socket, recv_buf, sizeof(recv_buf), 0); ret = recv(client_socket, recv_buf, sizeof(recv_buf), 0);
closesocket(client_socket); closesocket(client_socket);
if (ret == -1 || ret == 0) { if (ret == -1 || ret == 0) {
LOG(INFO) << "socket recv fail ,ret:" << ret; // LOG(INFO) << "socket recv fail ,ret:" << ret;
} }
} }
@ -223,19 +222,19 @@ int HookRecvMsg(char *client_ip, int port) {
DWORD hook_recv_msg_addr = base + WX_RECV_MSG_HOOK_OFFSET; DWORD hook_recv_msg_addr = base + WX_RECV_MSG_HOOK_OFFSET;
msg_next_addr_ = base + WX_RECV_MSG_HOOK_NEXT_OFFSET; msg_next_addr_ = base + WX_RECV_MSG_HOOK_NEXT_OFFSET;
msg_back_addr_ = hook_recv_msg_addr + 0x5; // msg_back_addr_ = hook_recv_msg_addr + 0x5;
LOG(INFO) << "base" << base; // LOG(INFO) << "base" << base;
LOG(INFO) << "msg_next_addr_" << msg_next_addr_; // LOG(INFO) << "msg_next_addr_" << msg_next_addr_;
LOG(INFO) << "msg_back_addr_" << msg_back_addr_; // LOG(INFO) << "msg_back_addr_" << msg_back_addr_;
Utils::HookAnyAddress(hook_recv_msg_addr, (LPVOID)HandleSyncMsg, Utils::HookAnyAddress(hook_recv_msg_addr, (LPVOID)HandleSyncMsg,
msg_asm_code_); msg_asm_code_);
DWORD hook_sns_msg_addr = base + WX_SNS_HOOK_OFFSET; DWORD hook_sns_msg_addr = base + WX_SNS_HOOK_OFFSET;
sns_next_addr_ = base + WX_SNS_HOOK_NEXT_OFFSET; sns_next_addr_ = base + WX_SNS_HOOK_NEXT_OFFSET;
sns_back_addr_ = hook_sns_msg_addr + 0x5; sns_back_addr_ = hook_sns_msg_addr + 0x5;
LOG(INFO) << "base" << base; // LOG(INFO) << "base" << base;
LOG(INFO) << "sns_next_addr_" << sns_next_addr_; // LOG(INFO) << "sns_next_addr_" << sns_next_addr_;
LOG(INFO) << "sns_back_addr_" << sns_back_addr_; // LOG(INFO) << "sns_back_addr_" << sns_back_addr_;
Utils::HookAnyAddress(hook_sns_msg_addr, (LPVOID)HandleSNSMsg, sns_asm_code_); Utils::HookAnyAddress(hook_sns_msg_addr, (LPVOID)HandleSNSMsg, sns_asm_code_);
msg_hook_flag_ = true; msg_hook_flag_ = true;
@ -245,7 +244,7 @@ int HookRecvMsg(char *client_ip, int port) {
int UnHookRecvMsg() { int UnHookRecvMsg() {
server_port_ = 0; server_port_ = 0;
if (!msg_hook_flag_) { if (!msg_hook_flag_) {
LOG(INFO) << "this port already hooked"; // LOG(INFO) << "this port already hooked";
return 2; return 2;
} }
DWORD base = Utils::GetWeChatWinBase(); DWORD base = Utils::GetWeChatWinBase();
@ -273,7 +272,7 @@ void PrintLog(DWORD addr) {
WideCharToMultiByte(CP_ACP, 0, w_msg, -1, ansi_message, size, 0, 0); WideCharToMultiByte(CP_ACP, 0, w_msg, -1, ansi_message, size, 0, 0);
delete[] w_msg; delete[] w_msg;
w_msg = NULL; w_msg = NULL;
LOG(INFO) << ansi_message; // LOG(INFO) << ansi_message;
delete[] ansi_message; delete[] ansi_message;
ansi_message = NULL; ansi_message = NULL;
} }
@ -321,7 +320,7 @@ int UnHookLog() {
void SetErrorCode(int code) { userinfo.error_code = code; } void SetErrorCode(int code) { userinfo.error_code = code; }
void SetUserInfoDetail(DWORD address) { void SetUserInfoDetail(DWORD address) {
LOG(INFO) << "hook userinfo addr" <<&userinfo; // LOG(INFO) << "hook userinfo addr" <<&userinfo;
DWORD length = *(DWORD *)(address + 0x8); DWORD length = *(DWORD *)(address + 0x8);
userinfo.keyword = new wchar_t[length + 1]; userinfo.keyword = new wchar_t[length + 1];
userinfo.keyword_len = length; userinfo.keyword_len = length;

View File

@ -9,7 +9,6 @@
#include "chat_room_mgr.h" #include "chat_room_mgr.h"
#include "contact_mgr.h" #include "contact_mgr.h"
#include "db.h" #include "db.h"
#include "easylogging++.h"
#include "hooks.h" #include "hooks.h"
#include "misc_mgr.h" #include "misc_mgr.h"
#include "send_message_mgr.h" #include "send_message_mgr.h"
@ -71,9 +70,9 @@ string Dispatch(struct mg_connection *c, struct mg_http_message *hm) {
if (mg_vcasecmp(&hm->method, "POST") == 0) { if (mg_vcasecmp(&hm->method, "POST") == 0) {
is_post = 1; is_post = 1;
} }
el::Logger *defaultLogger = el::Loggers::getLogger("default"); // el::Logger *defaultLogger = el::Loggers::getLogger("default");
defaultLogger->info("method: %v body: %v", hm->method.ptr, hm->body.ptr); // defaultLogger->info("method: %v body: %v", hm->method.ptr, hm->body.ptr);
LOG_IF(is_post != 1, INFO) << "request method is not post"; // LOG_IF(is_post != 1, INFO) << "request method is not post";
if (is_post == 0) { if (is_post == 0) {
json ret_data = {{"result", "ERROR"}, {"msg", "not support method"}}; json ret_data = {{"result", "ERROR"}, {"msg", "not support method"}};

View File

@ -1,37 +1,20 @@
#include "log.h" #include "pch.h"
#include "log.h"
#include "easylogging++.h" #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
INITIALIZE_EASYLOGGINGPP
namespace wxhelper { namespace wxhelper {
Log::Log(/* args */) {} Log::Log(/* args */) {}
Log::~Log() {} Log::~Log() {
}
void Log::Initialize() { void Log::Initialize() {
auto logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 23, 59);
el::Configurations conf; logger->flush_on(spdlog::level::err);
// 启用日志 spdlog::set_default_logger(logger);
conf.setGlobally(el::ConfigurationType::Enabled, "true"); spdlog::flush_every(std::chrono::seconds(3));
// 设置日志文件目录以及文件名 spdlog::set_level(spdlog::level::debug);
conf.setGlobally(el::ConfigurationType::Filename, spdlog::set_pattern("%Y-%m-%d %H:%M:%S [%l] [%t] - <%s>|<%#>|<%!>,%v");
"log\\log_%datetime{%Y%M%d %H%m%s}.log");
// 设置日志文件最大文件大小
conf.setGlobally(el::ConfigurationType::MaxLogFileSize, "20971520");
// 是否写入文件
conf.setGlobally(el::ConfigurationType::ToFile, "true");
// 是否输出控制台
conf.setGlobally(el::ConfigurationType::ToStandardOutput, "true");
// 设置日志输出格式
conf.setGlobally(el::ConfigurationType::Format,
"[%datetime] [%thread] [%loc] [%level] : %msg");
// 设置日志文件写入周期如下每100条刷新到输出流中
#ifdef _DEBUG
conf.setGlobally(el::ConfigurationType::LogFlushThreshold, "1");
#else
conf.setGlobally(el::ConfigurationType::LogFlushThreshold, "100");
#endif
// 设置配置文件
el::Loggers::reconfigureAllLoggers(conf);
} }
} // namespace wxhelper } // namespace wxhelper

View File

@ -5,7 +5,6 @@
#include "base64.h" #include "base64.h"
#include "db.h" #include "db.h"
#include "hooks.h" #include "hooks.h"
#include "easylogging++.h"
#define BUFSIZE 1024 #define BUFSIZE 1024
#define JPEG0 0xFF #define JPEG0 0xFF
@ -429,7 +428,7 @@ int MiscMgr::SearchContactNetScene(wchar_t *keyword,UserInfo ** user) {
} }
} }
*user= &hooks::userinfo; *user= &hooks::userinfo;
LOG(INFO)<<"user:" <<user; // LOG(INFO)<<"user:" <<user;
return success; return success;
} }

View File

@ -16,6 +16,11 @@
#include <fcntl.h> #include <fcntl.h>
#include "Windows.h" #include "Windows.h"
#include "utils.h" #include "utils.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#endif // PCH_H #endif // PCH_H

View File

@ -1,12 +1,9 @@
#include "pch.h" #include "pch.h"
#include "send_message_mgr.h" #include "send_message_mgr.h"
#include "easylogging++.h"
#include "wechat_function.h" #include "wechat_function.h"
#include "db.h" #include "db.h"
#include "contact_mgr.h" #include "contact_mgr.h"
#include "spdlog/spdlog.h"
namespace wxhelper { namespace wxhelper {
SendMessageMgr::SendMessageMgr(DWORD base):BaseMgr(base) {} SendMessageMgr::SendMessageMgr(DWORD base):BaseMgr(base) {}
SendMessageMgr::~SendMessageMgr() {} SendMessageMgr::~SendMessageMgr() {}
@ -38,7 +35,8 @@ int SendMessageMgr::SendText(wchar_t* wxid, wchar_t* msg) {
CALL free_chat_msg_addr CALL free_chat_msg_addr
POPAD POPAD
} }
LOG_IF((success == -1), ERROR) << "SendText fail"; SPDLOG_INFO("SendText code = {}",success);
SPDLOG_INFO("global log with source info");
return success; return success;
} }
int SendMessageMgr::SendAtText(wchar_t* chat_room_id, wchar_t** wxids, int len, int SendMessageMgr::SendAtText(wchar_t* chat_room_id, wchar_t** wxids, int len,
@ -104,7 +102,7 @@ int SendMessageMgr::SendAtText(wchar_t* chat_room_id, wchar_t** wxids, int len,
CALL free_chat_msg_addr CALL free_chat_msg_addr
POPAD POPAD
} }
LOG_IF((success == -1), ERROR) << "SendText fail"; SPDLOG_INFO("SendText code = {}",success);
return success; return success;
} }
int SendMessageMgr::SendImage(wchar_t* wxid, wchar_t* image_path) { int SendMessageMgr::SendImage(wchar_t* wxid, wchar_t* image_path) {
@ -140,7 +138,7 @@ int SendMessageMgr::SendImage(wchar_t* wxid, wchar_t* image_path) {
CALL free_msg_addr CALL free_msg_addr
POPAD POPAD
} }
LOG_IF((success == -1), ERROR) << "SendImage fail"; SPDLOG_INFO("SendImage code = {}",success);
return success; return success;
} }
int SendMessageMgr::SendFile(wchar_t* wxid, wchar_t* file_path) { int SendMessageMgr::SendFile(wchar_t* wxid, wchar_t* file_path) {
@ -194,10 +192,10 @@ int SendMessageMgr::SendFile(wchar_t* wxid, wchar_t* file_path) {
POPFD POPFD
POPAD POPAD
} }
SPDLOG_INFO("SendFile code = {}",success);
if (success == 0x31) { if (success == 0x31) {
return 1; return 1;
} }
LOG_IF((success == -1), ERROR) << "SendFile fail";
return success; return success;
} }

View File

@ -22,17 +22,17 @@
// searchContactMgr // searchContactMgr
#define WX_SEARCH_CONTACT_MGR_OFFSET 0xa6cb00 #define WX_SEARCH_CONTACT_MGR_OFFSET 0xa6cb00
// appMsgMgr // appMsgMgr
#define WX_APP_MSG_MGR_OFFSET 0x76ae20 #define WX_APP_MSG_MGR_OFFSET 0x76b8c0
// sendMessageMgr // sendMessageMgr
#define WX_SEND_MESSAGE_MGR_OFFSET 0x768140 #define WX_SEND_MESSAGE_MGR_OFFSET 0x768be0
// setChatMsgValue // setChatMsgValue
#define WX_INIT_CHAT_MSG_OFFSET 0xf59e40 #define WX_INIT_CHAT_MSG_OFFSET 0xf5b3f0
// chatMsg // chatMsg
#define WX_NEW_CHAT_MSG_OFFSET 0x76f010 #define WX_NEW_CHAT_MSG_OFFSET 0x76f010
#define WX_FREE_CHAT_MSG_OFFSET 0x756960 #define WX_FREE_CHAT_MSG_OFFSET 0x7573f0
#define WX_FREE_CHAT_MSG_2_OFFSET 0x6f4ea0 #define WX_FREE_CHAT_MSG_2_OFFSET 0x6f4ea0
#define WX_FREE_CHAT_MSG_INSTANCE_COUNTER_OFFSET 0x756e30 #define WX_FREE_CHAT_MSG_INSTANCE_COUNTER_OFFSET 0x756e30
@ -88,7 +88,6 @@
#define WX_PUSH_ATTACH_TASK_OFFSET 0x82bb40 #define WX_PUSH_ATTACH_TASK_OFFSET 0x82bb40
#define WX_FREE_CHAT_MSG_OFFSET 0x756960
#define WX_GET_MGR_BY_PREFIX_LOCAL_ID_OFFSET 0xbc0370 #define WX_GET_MGR_BY_PREFIX_LOCAL_ID_OFFSET 0xbc0370
#define WX_GET_CURRENT_DATA_PATH_OFFSET 0xc872c0 #define WX_GET_CURRENT_DATA_PATH_OFFSET 0xc872c0
#define WX_APP_MSG_INFO_OFFSET 0x7b3d20 #define WX_APP_MSG_INFO_OFFSET 0x7b3d20
@ -125,11 +124,11 @@
//forward //forward
#define WX_FORWARD_MSG_OFFSET 0xce6730 #define WX_FORWARD_MSG_OFFSET 0xce6730
// send file // send file
#define WX_SEND_FILE_OFFSET 0xb6d1f0 #define WX_SEND_FILE_OFFSET 0xb6dfd0
// send image // send image
#define WX_SEND_IMAGE_OFFSET 0xce6640 #define WX_SEND_IMAGE_OFFSET 0xce74b0
// send text // send text
#define WX_SEND_TEXT_OFFSET 0xce6c80 #define WX_SEND_TEXT_OFFSET 0xce7af0
//ocr //ocr