feat: 好友列表

This commit is contained in:
hugy 2023-07-01 13:32:26 +08:00
parent 0bbba4a902
commit 272d62b0e9
6 changed files with 107 additions and 6 deletions

View File

@ -157,12 +157,34 @@ std::string HttpDispatch(struct mg_connection *c, struct mg_http_message *hm) {
{"code", success}, {"data", {}}, {"msg", "success"}};
ret = ret_data.dump();
return ret;
} else {
} else if (mg_http_match_uri(hm, "/api/getContactList")) {
std::vector<common::ContactInner> vec;
INT64 success = wxhelper::GlobalContext::GetInstance().mgr->GetContacts(vec);
nlohmann::json ret_data = {
{"code", success}, {"data", {}}, {"msg", "success"}};
for (unsigned int i = 0; i < vec.size(); i++) {
nlohmann::json item = {
{"customAccount", vec[i].custom_account},
{"encryptName", vec[i].encrypt_name},
{"type", vec[i].type},
{"verifyFlag", vec[i].verify_flag},
{"wxid", vec[i].wxid},
{"nickname", vec[i].nickname},
{"pinyin", vec[i].pinyin},
{"pinyinAll", vec[i].pinyin_all},
{"reserved1", vec[i].reserved1},
{"reserved2", vec[i].reserved2},
};
ret_data["data"].push_back(item);
}
ret = ret_data.dump();
return ret;
} else {
nlohmann::json ret_data = {
{"code", 200}, {"data", {}}, {"msg", "not support url"}};
ret = ret_data.dump();
return ret;
}
}
nlohmann::json ret_data = {
{"code", 200}, {"data", {}}, {"msg", "unreachable code."}};
ret = ret_data.dump();

View File

@ -322,4 +322,35 @@ INT64 Manager::SendFileMsg(const std::wstring& wxid, const std::wstring& file_pa
}
} // namespace wxhelper`
INT64 Manager::GetContacts(std::vector<common::ContactInner> &vec) {
INT64 success = -1;
UINT64 get_contact_mgr_addr = base_addr_ + offset::kGetContactMgr;
UINT64 get_contact_list_addr = base_addr_ + offset::kGetContactList;
func::__GetContactMgr get_contact_mgr =
(func::__GetContactMgr)get_contact_mgr_addr;
func::__GetContactList get_contact_list =
(func::__GetContactList)get_contact_list_addr;
UINT64 mgr = get_contact_mgr();
UINT64 contact_vec[3] = {0, 0, 0};
success = get_contact_list(mgr, reinterpret_cast<UINT64>(&contact_vec));
UINT64 start = contact_vec[0];
UINT64 end = contact_vec[2];
while (start < end) {
common::ContactInner temp;
temp.wxid = Utils::ReadWstringThenConvert(start + 0x10);
temp.custom_account = Utils::ReadWstringThenConvert(start + 0x30);
temp.encrypt_name = Utils::ReadWstringThenConvert(start + 0x50);
temp.nickname = Utils::ReadWstringThenConvert(start + 0xA0);
temp.pinyin = Utils::ReadWstringThenConvert(start + 0x108);
temp.pinyin_all = Utils::ReadWstringThenConvert(start + 0x128);
temp.verify_flag = *(DWORD *)(start + 0x70);
temp.type = *(DWORD *)(start + 0x74);
temp.reserved1 = *(DWORD *)(start + 0x1F0);
temp.reserved2 = *(DWORD *)(start + 0x1F4);
vec.push_back(temp);
start += 0x698;
}
return success;
}
} // namespace wxhelper`

View File

@ -12,6 +12,7 @@ class Manager {
INT64 SendTextMsg(const std::wstring& wxid, const std::wstring& msg);
INT64 SendImageMsg(const std::wstring& wxid, const std::wstring& image_path);
INT64 SendFileMsg(const std::wstring& wxid, const std::wstring& file_path);
INT64 GetContacts(std::vector<common::ContactInner> &vec);
private:
UINT64 base_addr_;
};

View File

@ -302,4 +302,21 @@ std::string Utils::ImageXor(std::string buf){
}
return std::string();
}
std::wstring Utils::ReadWstring(INT64 addr){
DWORD len = *(DWORD *)(addr + 0x8);
if (len == 0) {
return std::wstring();
}
wchar_t * str = *(wchar_t **)(addr);
if (str == NULL) {
return std::wstring();
}
return std::wstring(str, len);
}
std::string Utils::ReadWstringThenConvert(INT64 addr){
std::wstring wstr = ReadWstring(addr);
return WstringToUTF8(wstr);
}
} // namespace wxhelper

View File

@ -56,7 +56,8 @@ class Utils {
static std::string ReadWeChatStr(INT64 addr);
static std::string ImageXor(std::string buf);
static std::wstring ReadWstring(INT64 addr);
static std::string ReadWstringThenConvert(INT64 addr);
template <typename T1, typename T2>
static std::vector<T1> split(T1 str, T2 letter) {
std::vector<T1> arr;

View File

@ -29,6 +29,31 @@ struct SelfInfoInner {
std::string db_key;
};
struct ContactInner {
std::string wxid;
std::string custom_account;
std::string encrypt_name;
std::string nickname;
std::string pinyin;
std::string pinyin_all;
DWORD type;
DWORD verify_flag;
DWORD reserved1;
DWORD reserved2;
ContactInner(){
wxid = "";
custom_account = "";
encrypt_name = "";
nickname ="";
pinyin ="";
pinyin_all ="";
type = -1;
verify_flag = -1;
reserved1 = -1;
reserved2 = -1;
}
};
} // namespace common
namespace V3_9_5_81 {
namespace function {
@ -44,9 +69,11 @@ typedef UINT64 (*__SendImageMsg)(UINT64, UINT64, UINT64, UINT64, UINT64);
typedef UINT64 (*__NewChatMsg)(UINT64);
typedef UINT64 (*__SendFile)(UINT64, UINT64, UINT64, UINT64, UINT64,UINT64, UINT64, UINT64, UINT64, UINT64, UINT64, UINT64);
typedef UINT64(*__GetAppMsgMgr)();
typedef UINT64(*operator_new)(UINT64);
typedef UINT64(*__OperatorNew)(UINT64);
typedef UINT64(*Free)();
typedef UINT64(*__Free)();
typedef UINT64 (*__GetContactMgr)();
typedef UINT64 (*__GetContactList)(UINT64,UINT64);
} // namespace function
namespace prototype {
@ -101,6 +128,8 @@ const UINT64 kSendImageMsg = 0xfc3d30;
const UINT64 kChatMsgInstanceCounter = 0x8c7fd0;
const UINT64 kSendFileMsg = 0xdd27f0;
const UINT64 kGetAppMsgMgr = 0x8c33f0;
const UINT64 kGetContactMgr = 0x8ae3d0;
const UINT64 kGetContactList = 0xeab270;
} // namespace offset
} // namespace V3_9_5_81