feat: check login and self info

This commit is contained in:
hugy 2023-11-01 21:57:03 +08:00
parent 1ff56fc055
commit bede8f7150
8 changed files with 240 additions and 5 deletions

View File

@ -58,6 +58,8 @@ void CloseConsole();
void HideModule(HMODULE module); void HideModule(HMODULE module);
bool IsDigit(const std::string &str); bool IsDigit(const std::string &str);
std::string Bytes2Hex(const BYTE *bytes, const int length);
} // namespace utils } // namespace utils
} // namespace base } // namespace base
#endif #endif

View File

@ -167,5 +167,19 @@ bool IsDigit(const std::string &str) {
return true; return true;
} }
std::string Bytes2Hex(const BYTE *bytes, const int length) {
if (bytes == NULL) {
return "";
}
std::string buff;
const int len = length;
for (int j = 0; j < len; j++) {
int high = bytes[j] / 16, low = bytes[j] % 16;
buff += (high < 10) ? ('0' + high) : ('a' + high - 10);
buff += (low < 10) ? ('0' + low) : ('a' + low - 10);
}
return buff;
}
} // namespace utils } // namespace utils
} // namespace base } // namespace base

View File

@ -26,6 +26,8 @@ void GlobalManager::initialize(HMODULE module) {
http_server->AddHttpApiUrl("/api/hookSyncMsg", HookSyncMsg); http_server->AddHttpApiUrl("/api/hookSyncMsg", HookSyncMsg);
http_server->AddHttpApiUrl("/api/getContactList", GetContacts); http_server->AddHttpApiUrl("/api/getContactList", GetContacts);
http_server->AddHttpApiUrl("/api/unhookSyncMsg", UnHookSyncMsg); http_server->AddHttpApiUrl("/api/unhookSyncMsg", UnHookSyncMsg);
http_server->AddHttpApiUrl("/api/checkLogin", CheckLogin);
http_server->AddHttpApiUrl("/api/userInfo", GetSelfInfo);
http_server->Start(); http_server->Start();
base::ThreadPool::GetInstance().Create(2, 8); base::ThreadPool::GetInstance().Create(2, 8);

View File

@ -3,8 +3,8 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "utils.h" #include "utils.h"
#include "wechat_service.h"
#include "wechat_hook.h" #include "wechat_hook.h"
#include "wechat_service.h"
#define STR2ULL(str) (base::utils::IsDigit(str) ? stoull(str) : 0) #define STR2ULL(str) (base::utils::IsDigit(str) ? stoull(str) : 0)
#define STR2LL(str) (base::utils::IsDigit(str) ? stoll(str) : 0) #define STR2LL(str) (base::utils::IsDigit(str) ? stoll(str) : 0)
@ -90,10 +90,43 @@ std::string GetContacts(mg_http_message* hm) {
std::string ret = ret_data.dump(); std::string ret = ret_data.dump();
return ret; return ret;
} }
std::string UnHookSyncMsg(mg_http_message* hm) { std::string UnHookSyncMsg(mg_http_message* hm) {
INT64 success = hook::WechatHook::GetInstance().UnHookSyncMsg(); INT64 success = hook::WechatHook::GetInstance().UnHookSyncMsg();
nlohmann::json ret_data = { nlohmann::json ret_data = {
{"code", success}, {"data", {}}, {"msg", "success"}}; {"code", success}, {"data", {}}, {"msg", "success"}};
return ret_data.dump(); return ret_data.dump();
} }
std::string CheckLogin(mg_http_message* hm) {
INT64 success = WechatService::GetInstance().CheckLogin();
nlohmann::json ret_data = {
{"code", success}, {"data", {}}, {"msg", "success"}};
return ret_data.dump();
}
std::string GetSelfInfo(mg_http_message* hm) {
common::SelfInfoInner self_info;
INT64 success = WechatService::GetInstance().GetSelfInfo(self_info);
nlohmann::json ret_data = {
{"code", success}, {"data", {}}, {"msg", "success"}};
if (success) {
nlohmann::json j_info = {
{"name", self_info.name},
{"city", self_info.city},
{"province", self_info.province},
{"country", self_info.country},
{"account", self_info.account},
{"wxid", self_info.wxid},
{"mobile", self_info.mobile},
{"headImage", self_info.head_img},
{"signature", self_info.signature},
{"dataSavePath", self_info.data_save_path},
{"currentDataPath", self_info.current_data_path},
{"dbKey", self_info.db_key},
};
ret_data["data"] = j_info;
}
return ret_data.dump();
}
} // namespace wxhelper } // namespace wxhelper

View File

@ -8,6 +8,8 @@ std::string SendTextMsg(struct mg_http_message *hm);
std::string HookSyncMsg(struct mg_http_message *hm); std::string HookSyncMsg(struct mg_http_message *hm);
std::string GetContacts(struct mg_http_message *hm); std::string GetContacts(struct mg_http_message *hm);
std::string UnHookSyncMsg(struct mg_http_message *hm); std::string UnHookSyncMsg(struct mg_http_message *hm);
} std::string CheckLogin(struct mg_http_message *hm);
std::string GetSelfInfo(struct mg_http_message *hm);
} // namespace wxhelper
#endif #endif

View File

@ -490,6 +490,11 @@ const UINT64 kSendTextMsg = 0x1024370;
const UINT64 kDoAddMsg = 0x106b810; const UINT64 kDoAddMsg = 0x106b810;
const UINT64 kGetContactMgr = 0x8ebfb0; const UINT64 kGetContactMgr = 0x8ebfb0;
const UINT64 kGetContactList = 0xeff050; const UINT64 kGetContactList = 0xeff050;
const UINT64 kGetAccountServiceMgr = 0x8fff40;
const UINT64 kGetAppDataSavePath = 0x1336c60;
const UINT64 kGetCurrentDataPath = 0xfacb50;
} // namespace offset } // namespace offset
namespace function { namespace function {
typedef UINT64 (*__GetSendMessageMgr)(); typedef UINT64 (*__GetSendMessageMgr)();
@ -498,6 +503,9 @@ typedef UINT64 (*__SendTextMsg)(UINT64, UINT64, UINT64, UINT64, UINT64, UINT64,
typedef UINT64 (*__FreeChatMsg)(UINT64); typedef UINT64 (*__FreeChatMsg)(UINT64);
typedef UINT64 (*__GetContactMgr)(); typedef UINT64 (*__GetContactMgr)();
typedef UINT64 (*__GetContactList)(UINT64, UINT64); typedef UINT64 (*__GetContactList)(UINT64, UINT64);
typedef UINT64(*__GetAccountService)();
typedef UINT64 (*__GetDataSavePath)(UINT64);
typedef UINT64 (*__GetCurrentDataPath)(UINT64);
} // namespace function } // namespace function
} // namespace V3_9_7_29 } // namespace V3_9_7_29
} // namespace wxhelper } // namespace wxhelper

View File

@ -1,14 +1,185 @@
#include "wechat_service.h" #include "wechat_service.h"
#include "wxutils.h" #include "wxutils.h"
#include "utils.h"
namespace offset = wxhelper::V3_9_7_29::offset; namespace offset = wxhelper::V3_9_7_29::offset;
namespace prototype = wxhelper::V3_9_7_29::prototype; namespace prototype = wxhelper::V3_9_7_29::prototype;
namespace func = wxhelper::V3_9_7_29::function; namespace func = wxhelper::V3_9_7_29::function;
namespace wxhelper { namespace wxhelper {
WechatService::~WechatService() {} WechatService::~WechatService() {}
INT64 WechatService::CheckLogin() { return INT64(); } INT64 WechatService::CheckLogin() {
INT64 success = -1;
UINT64 accout_service_addr = base_addr_ + offset::kGetAccountServiceMgr;
func::__GetAccountService GetSevice =
(func::__GetAccountService)accout_service_addr;
UINT64 service_addr = GetSevice();
if (service_addr) {
success = *(UINT64*)(service_addr + 0x7F8);
}
return success;
}
INT64 WechatService::GetSelfInfo(common::SelfInfoInner& out) { return INT64(); } INT64 WechatService::GetSelfInfo(common::SelfInfoInner& out) {
INT64 success = -1;
UINT64 accout_service_addr = base_addr_ + offset::kGetAccountServiceMgr;
UINT64 get_app_data_save_path_addr = base_addr_ + offset::kGetAppDataSavePath;
UINT64 get_current_data_path_addr = base_addr_ + offset::kGetCurrentDataPath;
func::__GetAccountService GetSevice = (func::__GetAccountService)accout_service_addr;
func::__GetDataSavePath GetDataSavePath = (func::__GetDataSavePath)get_app_data_save_path_addr;
func::__GetCurrentDataPath GetCurrentDataPath = (func::__GetCurrentDataPath)get_current_data_path_addr;
UINT64 service_addr = GetSevice();
if (service_addr) {
if (*(INT64 *)(service_addr + 0x80) == 0 ||
*(INT64 *)(service_addr + 0x80 + 0x10) == 0) {
out.wxid = std::string();
} else {
if (*(INT64 *)(service_addr + 0x80 + 0x18) == 0xF) {
out.wxid = std::string((char *)(service_addr + 0x80),
*(INT64 *)(service_addr + 0x80 + 0x10));
} else {
out.wxid = std::string(*(char **)(service_addr + 0x80),
*(INT64 *)(service_addr + 0x80 + 0x10));
}
}
if (*(INT64 *)(service_addr + 0x108) == 0 ||
*(INT64 *)(service_addr + 0x108 + 0x10) == 0) {
out.account = std::string();
} else {
if (*(INT64 *)(service_addr + 0x108 + 0x18) == 0xF) {
out.account = std::string((char *)(service_addr + 0x108),
*(INT64 *)(service_addr + 0x108 + 0x10));
} else {
out.account = std::string(*(char **)(service_addr + 0x108),
*(INT64 *)(service_addr + 0x108 + 0x10));
}
}
if (*(INT64 *)(service_addr + 0x128) == 0 ||
*(INT64 *)(service_addr + 0x128 + 0x10) == 0) {
out.mobile = std::string();
} else {
if (*(INT64 *)(service_addr + 0x128 + 0x18) == 0xF) {
out.mobile = std::string((char *)(service_addr + 0x128),
*(INT64 *)(service_addr + 0x128 + 0x10));
} else {
out.mobile = std::string(*(char **)(service_addr + 0x128),
*(INT64 *)(service_addr + 0x128 + 0x10));
}
}
if (*(INT64 *)(service_addr + 0x148) == 0 ||
*(INT64 *)(service_addr + 0x148 + 0x10) == 0) {
out.signature = std::string();
} else {
if (*(INT64 *)(service_addr + 0x148 + 0x18) == 0xF) {
out.signature = std::string((char *)(service_addr + 0x148),
*(INT64 *)(service_addr + 0x148 + 0x10));
} else {
out.signature = std::string(*(char **)(service_addr + 0x148),
*(INT64 *)(service_addr + 0x148 + 0x10));
}
}
if (*(INT64 *)(service_addr + 0x168) == 0 ||
*(INT64 *)(service_addr + 0x168 + 0x10) == 0) {
out.country = std::string();
} else {
if (*(INT64 *)(service_addr + 0x168 + 0x18) == 0xF) {
out.country = std::string((char *)(service_addr + 0x168),
*(INT64 *)(service_addr + 0x168 + 0x10));
} else {
out.country = std::string(*(char **)(service_addr + 0x168),
*(INT64 *)(service_addr + 0x168 + 0x10));
}
}
if (*(INT64 *)(service_addr + 0x188) == 0 ||
*(INT64 *)(service_addr + 0x188 + 0x10) == 0) {
out.province = std::string();
} else {
if (*(INT64 *)(service_addr + 0x188 + 0x18) == 0xF) {
out.province = std::string((char *)(service_addr + 0x188),
*(INT64 *)(service_addr + 0x188 + 0x10));
} else {
out.province = std::string(*(char **)(service_addr + 0x188),
*(INT64 *)(service_addr + 0x188 + 0x10));
}
}
if (*(INT64 *)(service_addr + 0x1A8) == 0 ||
*(INT64 *)(service_addr + 0x1A8 + 0x10) == 0) {
out.city = std::string();
} else {
if (*(INT64 *)(service_addr + 0x1A8 + 0x18) == 0xF) {
out.city = std::string((char *)(service_addr + 0x1A8),
*(INT64 *)(service_addr + 0x1A8 + 0x10));
} else {
out.city = std::string(*(char **)(service_addr + 0x1A8),
*(INT64 *)(service_addr + 0x1A8 + 0x10));
}
}
if (*(INT64 *)(service_addr + 0x1E8) == 0 ||
*(INT64 *)(service_addr + 0x1E8 + 0x10) == 0) {
out.name = std::string();
} else {
if (*(INT64 *)(service_addr + 0x1E8 + 0x18) == 0xF) {
out.name = std::string((char *)(service_addr + 0x1E8),
*(INT64 *)(service_addr + 0x1E8 + 0x10));
} else {
out.name = std::string(*(char **)(service_addr + 0x1E8),
*(INT64 *)(service_addr + 0x1E8 + 0x10));
}
}
if (*(INT64 *)(service_addr + 0x450) == 0 ||
*(INT64 *)(service_addr + 0x450 + 0x10) == 0) {
out.head_img = std::string();
} else {
out.head_img = std::string(*(char **)(service_addr + 0x450),
*(INT64 *)(service_addr + 0x450 + 0x10));
}
if (*(INT64 *)(service_addr + 0x6E0) == 0 ||
*(INT64 *)(service_addr + 0x6E8) == 0) {
out.db_key = std::string();
} else {
INT64 byte_addr = *(INT64 *)(service_addr + 0x6E0);
INT64 len = *(INT64 *)(service_addr + 0x6E8);
out.db_key = base::utils::Bytes2Hex((BYTE *)byte_addr, static_cast<int>(len));
}
UINT64 flag = *(UINT64 *)(service_addr + 0x7F8);
if (flag == 1) {
prototype::WeChatString current_data_path;
// _GetCurrentDataPath(get_current_data_path_addr,
// reinterpret_cast<ULONG_PTR>(&current_data_path));
GetCurrentDataPath(reinterpret_cast<ULONG_PTR>(&current_data_path));
if (current_data_path.ptr) {
out.current_data_path = base::utils::WstringToUtf8(
std::wstring(current_data_path.ptr, current_data_path.length));
} else {
out.current_data_path = std::string();
}
}
}
prototype::WeChatString data_save_path;
// _GetDataSavePath(get_app_data_save_path_addr,
// reinterpret_cast<ULONG_PTR>(&data_save_path));
GetCurrentDataPath(reinterpret_cast<ULONG_PTR>(&data_save_path));
if (data_save_path.ptr) {
out.data_save_path = base::utils::WstringToUtf8(
std::wstring(data_save_path.ptr, data_save_path.length));
} else {
out.data_save_path = std::string();
}
success = 1;
return success;
}
INT64 WechatService::SendTextMsg(const std::wstring& wxid, INT64 WechatService::SendTextMsg(const std::wstring& wxid,
const std::wstring& msg) { const std::wstring& msg) {

View File

@ -92,5 +92,8 @@ std::string ReadWstringThenConvert(INT64 addr) {
std::wstring wstr = ReadWstring(addr); std::wstring wstr = ReadWstring(addr);
return base::utils::WstringToUtf8(wstr); return base::utils::WstringToUtf8(wstr);
} }
} // namespace wxutils } // namespace wxutils
} // namespace wxhelper } // namespace wxhelper