mirror of
https://github.com/ttttupup/wxhelper.git
synced 2024-11-22 18:29:23 +08:00
feat: fix
This commit is contained in:
parent
ff21d07e40
commit
b6e07cc3d7
@ -12,7 +12,7 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /MD /EHsc ")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /MD /EHsc /FAcs")
|
||||
|
||||
|
||||
file(GLOB CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c )
|
||||
@ -30,7 +30,7 @@ add_subdirectory(../base base)
|
||||
|
||||
add_library(wxhelper SHARED ${CPP_FILES} ${ASM_FILES})
|
||||
|
||||
target_compile_definitions(wxhelper PRIVATE WECHAT_VERSION=39825)
|
||||
target_compile_definitions(wxhelper PRIVATE WECHAT_VERSION=39943)
|
||||
|
||||
# target_include_directories(wxhelper
|
||||
# PRIVATE ../base/src/include
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "chat_controller.h"
|
||||
|
||||
#include "json_utils.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "offset.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils.h"
|
||||
#include "wechat_interface.h"
|
||||
#include "wxutils.h"
|
||||
#include "offset.h"
|
||||
#include "json_utils.h"
|
||||
|
||||
namespace offset = wechat::offset;
|
||||
namespace prototype = wechat::prototype;
|
||||
@ -16,7 +16,33 @@ namespace jsonutils = wxhelper::jsonutils;
|
||||
namespace wxhelper {
|
||||
|
||||
std::string ChatController::SendTextMsg(std::string params) {
|
||||
return std::string();
|
||||
int64_t base_addr = wxutils::GetWeChatWinBase();
|
||||
nlohmann::json jp = nlohmann::json::parse(params);
|
||||
SPDLOG_INFO("sendTextMsg wxid={},msg={}",jp["wxid"],jp["msg"]);
|
||||
std::wstring wxid = jsonutils::GetWStringParam(jp, "wxid");
|
||||
std::wstring msg = jsonutils::GetWStringParam(jp, "msg");
|
||||
prototype::WeChatString to_user(wxid);
|
||||
prototype::WeChatString text_msg(msg);
|
||||
uint64_t send_message_mgr_addr = base_addr + offset::kGetSendMessageMgr;
|
||||
uint64_t send_text_msg_addr = base_addr + offset::kSendTextMsg;
|
||||
uint64_t free_chat_msg_addr = base_addr + offset::kFreeChatMsg;
|
||||
char chat_msg[0x460] = {0};
|
||||
uint64_t temp[3] = {0};
|
||||
func::__GetSendMessageMgr mgr;
|
||||
mgr = (func::__GetSendMessageMgr)send_message_mgr_addr;
|
||||
func::__SendTextMsg send;
|
||||
send = (func::__SendTextMsg)send_text_msg_addr;
|
||||
func::__FreeChatMsg free;
|
||||
free = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
mgr();
|
||||
uint64_t success = send(reinterpret_cast<UINT64>(&chat_msg),
|
||||
reinterpret_cast<UINT64>(&to_user),
|
||||
reinterpret_cast<UINT64>(&text_msg),
|
||||
reinterpret_cast<UINT64>(&temp), 1, 1, 0, 0);
|
||||
free(reinterpret_cast<UINT64>(&chat_msg));
|
||||
|
||||
nlohmann::json ret_data = {{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
std::string ChatController::SendImageMsg(std::string params) {
|
||||
return std::string();
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef WXHELPER_CHAT_CONTROLLER_H_
|
||||
#define WXHELPER_CHAT_CONTROLLER_H_
|
||||
#include <Windows.h>
|
||||
|
||||
#include "http_controller.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace wxhelper {
|
||||
class ChatController : public http::HttpController<ChatController> {
|
||||
public:
|
||||
|
@ -2,61 +2,59 @@
|
||||
#include "hook.h"
|
||||
|
||||
|
||||
#include "base64.h"
|
||||
#include "client_socket.h"
|
||||
#include "config.h"
|
||||
#include "detours.h"
|
||||
#include "http_client.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "offset.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "thread_pool.h"
|
||||
// #include "thread_pool.h"
|
||||
#include "utils.h"
|
||||
#include "wechat_interface.h"
|
||||
#include "wxutils.h"
|
||||
namespace hook {
|
||||
|
||||
VOID SendTcpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work) {
|
||||
wechat::InnerMessageStruct *msg = (wechat::InnerMessageStruct *)context;
|
||||
if (msg == NULL) {
|
||||
SPDLOG_INFO("add work:msg is null");
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<wechat::InnerMessageStruct> sms(msg);
|
||||
nlohmann::json j_msg = nlohmann::json::parse(
|
||||
msg->buffer, msg->buffer + msg->length, nullptr, false);
|
||||
if (j_msg.is_discarded() == true) {
|
||||
return;
|
||||
}
|
||||
std::string jstr = j_msg.dump() + "\n";
|
||||
std::string ip =wxhelper::Config::GetInstance().GetRecvTcpIp();
|
||||
int port = wxhelper::Config::GetInstance().GetRecvTcpPort();
|
||||
wxhelper::TcpClient client{ip,port};
|
||||
client.SendAndCloseSocket(jstr);
|
||||
}
|
||||
|
||||
VOID SendHttpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
void SendHttpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work) {
|
||||
wechat::InnerMessageStruct *msg = (wechat::InnerMessageStruct *)context;
|
||||
InnerMessageStruct *msg = (InnerMessageStruct *)context;
|
||||
if (msg == NULL) {
|
||||
SPDLOG_INFO("http msg is null");
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<wechat::InnerMessageStruct> sms(msg);
|
||||
std::unique_ptr<InnerMessageStruct> sms(msg);
|
||||
nlohmann::json j_msg = nlohmann::json::parse(
|
||||
msg->buffer, msg->buffer + msg->length, nullptr, false);
|
||||
if (j_msg.is_discarded() == true) {
|
||||
if (j_msg.is_discarded()) {
|
||||
return;
|
||||
}
|
||||
std::string jstr = j_msg.dump() + "\n";
|
||||
std::string url =wxhelper::Config::GetInstance().GetRecvHttpUrl();
|
||||
std::string url = wxhelper::Config::GetInstance().GetRecvHttpUrl();
|
||||
int timeout = wxhelper::Config::GetInstance().GetRecvHttpTimeout();
|
||||
http::HttpClient client{url,timeout};
|
||||
http::HttpClient client{url, timeout};
|
||||
client.SendRequest(jstr);
|
||||
}
|
||||
|
||||
|
||||
void SendTcpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work) {
|
||||
InnerMessageStruct *msg = (InnerMessageStruct *)context;
|
||||
if (msg == NULL) {
|
||||
SPDLOG_INFO("add work:msg is null");
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<InnerMessageStruct> sms(msg);
|
||||
nlohmann::json j_msg = nlohmann::json::parse(
|
||||
msg->buffer, msg->buffer + msg->length, nullptr, false);
|
||||
if (j_msg.is_discarded()) {
|
||||
return;
|
||||
}
|
||||
std::string jstr = j_msg.dump() + "\n";
|
||||
std::string ip = wxhelper::Config::GetInstance().GetRecvTcpIp();
|
||||
int port = wxhelper::Config::GetInstance().GetRecvTcpPort();
|
||||
wxhelper::TcpClient client{ip, port};
|
||||
client.SendAndCloseSocket(jstr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BaseHook::BaseHook(void *origin, void *detour)
|
||||
: origin_(origin), detour_(detour) {}
|
||||
|
||||
@ -91,55 +89,4 @@ int BaseHook::Unhook() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
SyncMsgHook::SyncMsgHook(void *origin, void *detour)
|
||||
: BaseHook(origin, detour) {}
|
||||
|
||||
void SyncMsgHook::HandleSyncMsg(INT64 param1, INT64 param2, INT64 param3) {
|
||||
nlohmann::json msg;
|
||||
|
||||
msg["pid"] = GetCurrentProcessId();
|
||||
msg["fromUser"] =
|
||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x18));
|
||||
msg["toUser"] =
|
||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x28));
|
||||
msg["content"] =
|
||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x30));
|
||||
msg["signature"] =
|
||||
wxhelper::wxutils::ReadWeChatStr(*(INT64 *)(param2 + 0x48));
|
||||
msg["msgId"] = *(INT64 *)(param2 + 0x60);
|
||||
msg["msgSequence"] = *(DWORD *)(param2 + 0x5C);
|
||||
msg["createTime"] = *(DWORD *)(param2 + 0x58);
|
||||
msg["displayFullContent"] =
|
||||
wxhelper::wxutils::ReadWeChatStr(*(INT64 *)(param2 + 0x50));
|
||||
DWORD type = *(DWORD *)(param2 + 0x24);
|
||||
msg["type"] = type;
|
||||
if (type == 3) {
|
||||
int a = 1;
|
||||
std::string img =
|
||||
wxhelper::wxutils::ReadSKBuiltinBuffer(*(INT64 *)(param2 + 0x40));
|
||||
SPDLOG_INFO("encode size:{}", img.size());
|
||||
msg["base64Img"] = base64_encode(img);
|
||||
a = 2;
|
||||
}
|
||||
std::string jstr = msg.dump() + '\n';
|
||||
wechat::InnerMessageStruct *inner_msg = new wechat::InnerMessageStruct;
|
||||
inner_msg->buffer = new char[jstr.size() + 1];
|
||||
memcpy(inner_msg->buffer, jstr.c_str(), jstr.size() + 1);
|
||||
inner_msg->length = jstr.size();
|
||||
std::string mode = wxhelper::Config::GetInstance().GetRecvMessageMode();
|
||||
if (mode == "http") {
|
||||
bool add =
|
||||
base::ThreadPool::GetInstance().AddWork(SendHttpMsgCallback, inner_msg);
|
||||
SPDLOG_INFO("add http msg work:{}", add);
|
||||
} else if (mode == "tcp") {
|
||||
bool add =
|
||||
base::ThreadPool::GetInstance().AddWork(SendTcpMsgCallback, inner_msg);
|
||||
SPDLOG_INFO("add tcp msg work:{}", add);
|
||||
}
|
||||
int64_t addr =
|
||||
wxhelper::wxutils::GetWeChatWinBase() + wechat::offset::kDoAddMsg;
|
||||
wechat::function::__DoAddMsg addMsg = (wechat::function::__DoAddMsg)addr;
|
||||
addMsg(param1, param2, param3);
|
||||
}
|
||||
|
||||
} // namespace hook
|
@ -1,19 +1,32 @@
|
||||
#ifndef WXHELPER_HOOK_H_
|
||||
#define WXHELPER_HOOK_H_
|
||||
#include "noncopyable.h"
|
||||
#include <Windows.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace hook {
|
||||
struct InnerMessageStruct {
|
||||
char* buffer;
|
||||
int64_t length;
|
||||
~InnerMessageStruct() {
|
||||
if (this->buffer != NULL) {
|
||||
delete[] this->buffer;
|
||||
this->buffer = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static void SendHttpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work);
|
||||
void SendHttpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work);
|
||||
|
||||
static void SendTcpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work);
|
||||
class BaseHook : public NonCopyable {
|
||||
public:
|
||||
void SendTcpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work);
|
||||
class BaseHook {
|
||||
public:
|
||||
BaseHook():hook_flag_(false),origin_(nullptr),detour_(nullptr){}
|
||||
BaseHook(void* origin, void* detour);
|
||||
int Hook();
|
||||
int Unhook();
|
||||
virtual ~BaseHook() {}
|
||||
|
||||
protected:
|
||||
bool hook_flag_;
|
||||
@ -21,12 +34,5 @@ class BaseHook : public NonCopyable {
|
||||
void* detour_;
|
||||
};
|
||||
|
||||
class SyncMsgHook : public BaseHook {
|
||||
public:
|
||||
explicit SyncMsgHook(void* origin, void* detour);
|
||||
private:
|
||||
static void HandleSyncMsg(INT64 param1, INT64 param2, INT64 param3);
|
||||
};
|
||||
|
||||
} // namespace hook
|
||||
#endif
|
@ -1,9 +1,9 @@
|
||||
|
||||
#ifndef WXHELPER_HTTP_CONTROLLER_H_
|
||||
#define WXHELPER_HTTP_CONTROLLER_H_
|
||||
#include <Windows.h>
|
||||
|
||||
#include "http_router.h"
|
||||
#include "singleton.h"
|
||||
namespace http {
|
||||
#define PATHS_BEGIN static void AddPath() {
|
||||
#define ADD_PATH(path, method) RegisterPath(path, &method)
|
||||
@ -15,7 +15,7 @@ class BaseHttpController {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class HttpController : public BaseHttpController {
|
||||
class HttpController : public base::Singleton<T>{
|
||||
public:
|
||||
virtual ~HttpController() {}
|
||||
|
||||
|
@ -130,11 +130,11 @@ const uint64_t kSyncMsg = 0xc39680;
|
||||
const uint64_t kSyncMsgNext = 0xc39680;
|
||||
const uint64_t kGetCurrentDataPath = 0x101a920;
|
||||
const uint64_t kGetAppDataSavePath = 0x13a5b90;
|
||||
const uint64_t kGetSendMessageMgr = 0x94cd10;
|
||||
const uint64_t kSendTextMsg = 0x1091F70;
|
||||
const uint64_t kFreeChatMsg = 0x94e590;
|
||||
const uint64_t kGetSendMessageMgr = 0xa7c730;
|
||||
const uint64_t kSendTextMsg = 0x11de090;
|
||||
const uint64_t kFreeChatMsg = 0xa7dfb0;
|
||||
|
||||
const uint64_t kDoAddMsg = 0x10d9450;
|
||||
const uint64_t kDoAddMsg = 0x1225a60;
|
||||
const uint64_t kSendImageMsg = 0x1087950;
|
||||
const uint64_t kChatMsgInstanceCounter = 0x956e00;
|
||||
const uint64_t kSendFileMsg = 0xea0850;
|
||||
|
@ -32,17 +32,6 @@ struct SqlResult {
|
||||
bool is_blob;
|
||||
};
|
||||
|
||||
struct InnerMessageStruct {
|
||||
char *buffer;
|
||||
int64_t length;
|
||||
~InnerMessageStruct() {
|
||||
if (this->buffer != NULL) {
|
||||
delete[] this->buffer;
|
||||
this->buffer = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct SelfInfoInner {
|
||||
std::string name;
|
||||
std::string city;
|
||||
|
Loading…
Reference in New Issue
Block a user