提交 00678b2f 编写于 作者: L ljc545w

解决部分已知Bug

上级 0ff0830a
...@@ -95,6 +95,8 @@ void FreeWxFriend(int index) { ...@@ -95,6 +95,8 @@ void FreeWxFriend(int index) {
} }
std::wstring GetFriendList() { std::wstring GetFriendList() {
if (!hProcess)
return L"[]";
DWORD GetFriendListInitAddr = GetWeChatRobotBase() + GetFriendListInitOffset; DWORD GetFriendListInitAddr = GetWeChatRobotBase() + GetFriendListInitOffset;
DWORD GetFriendListRemoteAddr = GetWeChatRobotBase() + GetFriendListRemoteOffset; DWORD GetFriendListRemoteAddr = GetWeChatRobotBase() + GetFriendListRemoteOffset;
DWORD GetFriendListFinishAddr = GetWeChatRobotBase() + GetFriendListFinishOffset; DWORD GetFriendListFinishAddr = GetWeChatRobotBase() + GetFriendListFinishOffset;
...@@ -108,7 +110,7 @@ std::wstring GetFriendList() { ...@@ -108,7 +110,7 @@ std::wstring GetFriendList() {
CloseHandle(hThread); CloseHandle(hThread);
} }
// 获取保存第一个好友的数据指针的结构体首地址 // 获取保存第一个好友的数据指针的结构体首地址
hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)GetFriendListRemoteAddr, 0, 0, &dwId); hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)GetFriendListRemoteAddr, NULL, 0, &dwId);
if (hThread) { if (hThread) {
WaitForSingleObject(hThread, INFINITE); WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &dwHandle); GetExitCodeThread(hThread, &dwHandle);
......
...@@ -36,7 +36,7 @@ bool Injert(DWORD dwPid,wchar_t* workPath) { ...@@ -36,7 +36,7 @@ bool Injert(DWORD dwPid,wchar_t* workPath) {
swprintf_s(dllpath, MAX_PATH, L"%ws%ws%ws", workPath, L"\\", dllname); swprintf_s(dllpath, MAX_PATH, L"%ws%ws%ws", workPath, L"\\", dllname);
string name = _com_util::ConvertBSTRToString((BSTR)workPath); string name = _com_util::ConvertBSTRToString((BSTR)workPath);
if (!isFileExists_stat(name)) { if (!isFileExists_stat(name)) {
MessageBoxA(NULL, name.c_str(), "文件不存在", MB_ICONWARNING); MessageBox(NULL, dllpath, L"文件不存在", MB_ICONWARNING);
return 1; return 1;
} }
bool status = InjectDll(dwPid, dllpath); bool status = InjectDll(dwPid, dllpath);
......
...@@ -19,7 +19,7 @@ VOID DeleteSelfInfoCache() { ...@@ -19,7 +19,7 @@ VOID DeleteSelfInfoCache() {
std::wstring GetSelfInfo() { std::wstring GetSelfInfo() {
if (!hProcess) if (!hProcess)
return L""; return L"{}";
if (SelfInfoString.compare(L"")) { if (SelfInfoString.compare(L"")) {
return SelfInfoString; return SelfInfoString;
} }
......
...@@ -9,7 +9,7 @@ struct SendArticleStruct { ...@@ -9,7 +9,7 @@ struct SendArticleStruct {
BOOL SendArticle(wchar_t* wxid, wchar_t* title, wchar_t* abstract, wchar_t* url) { BOOL SendArticle(wchar_t* wxid, wchar_t* title, wchar_t* abstract, wchar_t* url) {
if (!hProcess) if (!hProcess)
return 0; return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase(); DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0; DWORD dwId = 0;
DWORD dwWriteSize = 0; DWORD dwWriteSize = 0;
...@@ -24,7 +24,7 @@ BOOL SendArticle(wchar_t* wxid, wchar_t* title, wchar_t* abstract, wchar_t* url) ...@@ -24,7 +24,7 @@ BOOL SendArticle(wchar_t* wxid, wchar_t* title, wchar_t* abstract, wchar_t* url)
if (!wxidaddr || !titleaddr || !abstractaddr || !urladdr || if (!wxidaddr || !titleaddr || !abstractaddr || !urladdr ||
!paramAndFunc || !WeChatRobotBase) !paramAndFunc || !WeChatRobotBase)
{ {
return 0; return 1;
} }
if (wxidaddr) if (wxidaddr)
...@@ -52,5 +52,5 @@ BOOL SendArticle(wchar_t* wxid, wchar_t* title, wchar_t* abstract, wchar_t* url) ...@@ -52,5 +52,5 @@ BOOL SendArticle(wchar_t* wxid, wchar_t* title, wchar_t* abstract, wchar_t* url)
VirtualFreeEx(hProcess, abstractaddr, 0, MEM_RELEASE); VirtualFreeEx(hProcess, abstractaddr, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, urladdr, 0, MEM_RELEASE); VirtualFreeEx(hProcess, urladdr, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, paramAndFunc, 0, MEM_RELEASE); VirtualFreeEx(hProcess, paramAndFunc, 0, MEM_RELEASE);
return 1; return 0;
} }
\ No newline at end of file
...@@ -8,7 +8,7 @@ struct SendCardStruct { ...@@ -8,7 +8,7 @@ struct SendCardStruct {
BOOL SendCard(wchar_t* receiver, wchar_t* sharedwxid, wchar_t* nickname) { BOOL SendCard(wchar_t* receiver, wchar_t* sharedwxid, wchar_t* nickname) {
if (!hProcess) if (!hProcess)
return 0; return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase(); DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0; DWORD dwId = 0;
DWORD dwWriteSize = 0; DWORD dwWriteSize = 0;
...@@ -22,7 +22,7 @@ BOOL SendCard(wchar_t* receiver, wchar_t* sharedwxid, wchar_t* nickname) { ...@@ -22,7 +22,7 @@ BOOL SendCard(wchar_t* receiver, wchar_t* sharedwxid, wchar_t* nickname) {
if (!receiveraddr || !sharedwxidaddr || !nicknameaddr || if (!receiveraddr || !sharedwxidaddr || !nicknameaddr ||
!paramAndFunc || !WeChatRobotBase) !paramAndFunc || !WeChatRobotBase)
{ {
return 0; return 1;
} }
if (receiveraddr) if (receiveraddr)
WriteProcessMemory(hProcess, receiveraddr, receiver, wcslen(receiver) * 2 + 2, &dwWriteSize); WriteProcessMemory(hProcess, receiveraddr, receiver, wcslen(receiver) * 2 + 2, &dwWriteSize);
...@@ -45,5 +45,5 @@ BOOL SendCard(wchar_t* receiver, wchar_t* sharedwxid, wchar_t* nickname) { ...@@ -45,5 +45,5 @@ BOOL SendCard(wchar_t* receiver, wchar_t* sharedwxid, wchar_t* nickname) {
VirtualFreeEx(hProcess, sharedwxidaddr, 0, MEM_RELEASE); VirtualFreeEx(hProcess, sharedwxidaddr, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, nicknameaddr, 0, MEM_RELEASE); VirtualFreeEx(hProcess, nicknameaddr, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, paramAndFunc, 0, MEM_RELEASE); VirtualFreeEx(hProcess, paramAndFunc, 0, MEM_RELEASE);
return 1; return 0;
} }
\ No newline at end of file
...@@ -6,6 +6,8 @@ struct FileParamStruct { ...@@ -6,6 +6,8 @@ struct FileParamStruct {
}; };
int SendFile(wchar_t* wxid, wchar_t* filepath) { int SendFile(wchar_t* wxid, wchar_t* filepath) {
if (!hProcess)
return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase(); DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0; DWORD dwId = 0;
DWORD dwWriteSize = 0; DWORD dwWriteSize = 0;
......
...@@ -6,6 +6,8 @@ struct ImageParamStruct { ...@@ -6,6 +6,8 @@ struct ImageParamStruct {
}; };
int SendImage(wchar_t* wxid, wchar_t* imagepath) { int SendImage(wchar_t* wxid, wchar_t* imagepath) {
if (!hProcess)
return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase(); DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0; DWORD dwId = 0;
DWORD dwWriteSize = 0; DWORD dwWriteSize = 0;
......
...@@ -7,6 +7,8 @@ struct SendTextStruct ...@@ -7,6 +7,8 @@ struct SendTextStruct
}; };
int SendText(wchar_t* wxid, wchar_t* wxmsg) { int SendText(wchar_t* wxid, wchar_t* wxmsg) {
if (!hProcess)
return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase(); DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0; DWORD dwId = 0;
DWORD dwWriteSize = 0; DWORD dwWriteSize = 0;
......
...@@ -19,7 +19,7 @@ VOID DeleteUserInfoCache() { ...@@ -19,7 +19,7 @@ VOID DeleteUserInfoCache() {
std::wstring GetWxUserInfo(wchar_t* wxid) { std::wstring GetWxUserInfo(wchar_t* wxid) {
if (!hProcess) if (!hProcess)
return L""; return L"{}";
wstring WString = L""; wstring WString = L"";
DWORD GetUserInfoProcAddr = GetWeChatRobotBase() + GetWxUserInfoOffset; DWORD GetUserInfoProcAddr = GetWeChatRobotBase() + GetWxUserInfoOffset;
LPVOID wxidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE); LPVOID wxidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
...@@ -28,7 +28,7 @@ std::wstring GetWxUserInfo(wchar_t* wxid) { ...@@ -28,7 +28,7 @@ std::wstring GetWxUserInfo(wchar_t* wxid) {
DWORD dwHandle = 0; DWORD dwHandle = 0;
GetUserInfoStruct userinfo = { 0 }; GetUserInfoStruct userinfo = { 0 };
if (!wxidaddr) if (!wxidaddr)
return WString; return L"{}";
WriteProcessMemory(hProcess, wxidaddr, wxid, wcslen(wxid) * 2 + 2, &dwWriteSize); WriteProcessMemory(hProcess, wxidaddr, wxid, wcslen(wxid) * 2 + 2, &dwWriteSize);
HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)GetUserInfoProcAddr, wxidaddr, 0, &dwId); HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)GetUserInfoProcAddr, wxidaddr, 0, &dwId);
if (hThread) { if (hThread) {
......
...@@ -127,9 +127,14 @@ DWORD StartRobotService(wchar_t* workPath) { ...@@ -127,9 +127,14 @@ DWORD StartRobotService(wchar_t* workPath) {
MessageBoxA(NULL, "请先启动目标程序", "提示", MB_ICONWARNING); MessageBoxA(NULL, "请先启动目标程序", "提示", MB_ICONWARNING);
return 1; return 1;
} }
GetProcOffset(workPath);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, wxPid); hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, wxPid);
bool status = Injert(wxPid, workPath); bool status = Injert(wxPid, workPath);
if (status == 1) {
CloseHandle(hProcess);
return status;
}
GetProcOffset(workPath);
return status; return status;
} }
......
...@@ -27,14 +27,14 @@ int GetFriendListInit() { ...@@ -27,14 +27,14 @@ int GetFriendListInit() {
return WxFriendList.size(); return WxFriendList.size();
} }
DWORD GetFriendListRemote(int index) { DWORD GetFriendListRemote() {
if (WxFriendList.size() <= (unsigned int)index) if (WxFriendList.size() == 0)
return 0; return 0;
#ifdef _DEBUG #ifdef _DEBUG
printf("0x%08X\n", (DWORD)&WxFriendList[index]); printf("0x%08X\n", (DWORD)&WxFriendList[0]);
printf("0x%08X\n", (DWORD)&(WxFriendList[index].wxIdAddr)); printf("0x%08X\n", (DWORD)&(WxFriendList[0].wxIdAddr));
#endif #endif
return (DWORD)&WxFriendList[index].wxIdAddr; return (DWORD)&WxFriendList[0].wxIdAddr;
} }
void GetFriendListFinish() { void GetFriendListFinish() {
......
#pragma once #pragma once
void __stdcall GetFriendList(); void __stdcall GetFriendList();
extern "C" __declspec(dllexport) DWORD GetFriendListRemote(int index); extern "C" __declspec(dllexport) DWORD GetFriendListRemote();
extern "C" __declspec(dllexport) int GetFriendListInit(); extern "C" __declspec(dllexport) int GetFriendListInit();
extern "C" __declspec(dllexport) void GetFriendListFinish(); extern "C" __declspec(dllexport) void GetFriendListFinish();
\ No newline at end of file
...@@ -49,7 +49,10 @@ class WeChatRobot(): ...@@ -49,7 +49,10 @@ class WeChatRobot():
# 有bug待修复,需要判断某项信息是否是指针,修复前不要使用 # 有bug待修复,需要判断某项信息是否是指针,修复前不要使用
def GetSelfInfo(self): def GetSelfInfo(self):
myinfo = self.robot.CGetSelfInfo().replace('\n','\\n') myinfo = self.robot.CGetSelfInfo().replace('\n','\\n')
myinfo = ast.literal_eval(myinfo) try:
myinfo = ast.literal_eval(myinfo)
except SyntaxError:
return {}
myinfo['wxBigAvatar'] = myinfo['wxBigAvatar'].replace("/132","/0") myinfo['wxBigAvatar'] = myinfo['wxBigAvatar'].replace("/132","/0")
self.myinfo = myinfo self.myinfo = myinfo
return self.myinfo return self.myinfo
...@@ -122,13 +125,14 @@ class WeChatRobot(): ...@@ -122,13 +125,14 @@ class WeChatRobot():
return ast.literal_eval(userinfo) return ast.literal_eval(userinfo)
def test(): def test():
import os,sys import os
# DWeChatRobot.dll path # DWeChatRobot.dll path
dllpath = os.path.join(sys.path[0],'Release') path = os.path.split(os.path.realpath(__file__))[0]
dllpath = os.path.join(path,'Release')
# image full path # image full path
imgpath = os.path.join(sys.path[0],'test\\测试图片.png') imgpath = os.path.join(path,'test\\测试图片.png')
# file full path # file full path
filepath = os.path.join(sys.path[0],'test\\测试文件') filepath = os.path.join(path,'test\\测试文件')
wx = WeChatRobot(dllpath) wx = WeChatRobot(dllpath)
wx.StartService() wx.StartService()
myinfo = wx.GetSelfInfo() myinfo = wx.GetSelfInfo()
...@@ -145,7 +149,6 @@ def test(): ...@@ -145,7 +149,6 @@ def test():
session.SendCard(shared.get('wxid'),shared.get('wxNickName')) session.SendCard(shared.get('wxid'),shared.get('wxNickName'))
wx.StopService() wx.StopService()
if __name__ == '__main__': if __name__ == '__main__':
test() test()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册