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

解决部分已知Bug

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