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_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)
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(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 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 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 "account_mgr.h"
#include "easylogging++.h"
#include "wechat_function.h"

View File

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

View File

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

View File

@ -9,7 +9,6 @@
#include "chat_room_mgr.h"
#include "contact_mgr.h"
#include "db.h"
#include "easylogging++.h"
#include "hooks.h"
#include "misc_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) {
is_post = 1;
}
el::Logger *defaultLogger = el::Loggers::getLogger("default");
defaultLogger->info("method: %v body: %v", hm->method.ptr, hm->body.ptr);
LOG_IF(is_post != 1, INFO) << "request method is not post";
// el::Logger *defaultLogger = el::Loggers::getLogger("default");
// defaultLogger->info("method: %v body: %v", hm->method.ptr, hm->body.ptr);
// LOG_IF(is_post != 1, INFO) << "request method is not post";
if (is_post == 0) {
json ret_data = {{"result", "ERROR"}, {"msg", "not support method"}};

View File

@ -1,37 +1,20 @@
#include "log.h"
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
#include "pch.h"
#include "log.h"
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
namespace wxhelper {
Log::Log(/* args */) {}
Log::~Log() {}
Log::~Log() {
}
void Log::Initialize() {
el::Configurations conf;
// 启用日志
conf.setGlobally(el::ConfigurationType::Enabled, "true");
// 设置日志文件目录以及文件名
conf.setGlobally(el::ConfigurationType::Filename,
"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);
auto logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 23, 59);
logger->flush_on(spdlog::level::err);
spdlog::set_default_logger(logger);
spdlog::flush_every(std::chrono::seconds(3));
spdlog::set_level(spdlog::level::debug);
spdlog::set_pattern("%Y-%m-%d %H:%M:%S [%l] [%t] - <%s>|<%#>|<%!>,%v");
}
} // namespace wxhelper

View File

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

View File

@ -16,6 +16,11 @@
#include <fcntl.h>
#include "Windows.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

View File

@ -1,12 +1,9 @@
#include "pch.h"
#include "send_message_mgr.h"
#include "easylogging++.h"
#include "wechat_function.h"
#include "db.h"
#include "contact_mgr.h"
#include "spdlog/spdlog.h"
namespace wxhelper {
SendMessageMgr::SendMessageMgr(DWORD base):BaseMgr(base) {}
SendMessageMgr::~SendMessageMgr() {}
@ -38,7 +35,8 @@ int SendMessageMgr::SendText(wchar_t* wxid, wchar_t* msg) {
CALL free_chat_msg_addr
POPAD
}
LOG_IF((success == -1), ERROR) << "SendText fail";
SPDLOG_INFO("SendText code = {}",success);
SPDLOG_INFO("global log with source info");
return success;
}
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
POPAD
}
LOG_IF((success == -1), ERROR) << "SendText fail";
SPDLOG_INFO("SendText code = {}",success);
return success;
}
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
POPAD
}
LOG_IF((success == -1), ERROR) << "SendImage fail";
SPDLOG_INFO("SendImage code = {}",success);
return success;
}
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
POPAD
}
SPDLOG_INFO("SendFile code = {}",success);
if (success == 0x31) {
return 1;
}
LOG_IF((success == -1), ERROR) << "SendFile fail";
return success;
}

View File

@ -22,17 +22,17 @@
// searchContactMgr
#define WX_SEARCH_CONTACT_MGR_OFFSET 0xa6cb00
// appMsgMgr
#define WX_APP_MSG_MGR_OFFSET 0x76ae20
#define WX_APP_MSG_MGR_OFFSET 0x76b8c0
// sendMessageMgr
#define WX_SEND_MESSAGE_MGR_OFFSET 0x768140
#define WX_SEND_MESSAGE_MGR_OFFSET 0x768be0
// setChatMsgValue
#define WX_INIT_CHAT_MSG_OFFSET 0xf59e40
#define WX_INIT_CHAT_MSG_OFFSET 0xf5b3f0
// chatMsg
#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_INSTANCE_COUNTER_OFFSET 0x756e30
@ -88,7 +88,6 @@
#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_CURRENT_DATA_PATH_OFFSET 0xc872c0
#define WX_APP_MSG_INFO_OFFSET 0x7b3d20
@ -125,11 +124,11 @@
//forward
#define WX_FORWARD_MSG_OFFSET 0xce6730
// send file
#define WX_SEND_FILE_OFFSET 0xb6d1f0
#define WX_SEND_FILE_OFFSET 0xb6dfd0
// send image
#define WX_SEND_IMAGE_OFFSET 0xce6640
#define WX_SEND_IMAGE_OFFSET 0xce74b0
// send text
#define WX_SEND_TEXT_OFFSET 0xce6c80
#define WX_SEND_TEXT_OFFSET 0xce7af0
//ocr