提交 2ca77b04 编写于 作者: G Gogs

add GetSelfInfo

上级 eb5dfe1f
#include "pch.h"
struct GetSelfInfoStruct {
DWORD message;
DWORD length;
};
VOID DeleteSelfInfoCache() {
if (!hProcess)
return;
DWORD dwId = 0;
DWORD DeleteSelfInfoCacheProcAddr = GetWeChatRobotBase() + DeleteSelfInfoCacheOffset;
HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)DeleteSelfInfoCacheProcAddr, NULL, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
}
}
std::wstring GetSelfInfo() {
if (!hProcess)
return L"";
if (SelfInfoString.compare(L"")) {
return SelfInfoString;
}
DWORD GetSelfInfoProcAddr = GetWeChatRobotBase() + GetSelfInfoOffset;
DWORD dwWriteSize = 0;
DWORD dwId = 0;
DWORD dwHandle = 0;
GetSelfInfoStruct selfinfo = { 0 };
HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)GetSelfInfoProcAddr, NULL, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &dwHandle);
CloseHandle(hThread);
}
if (dwHandle)
ReadProcessMemory(hProcess, (LPCVOID)dwHandle, &selfinfo, sizeof(GetSelfInfoStruct), &dwWriteSize);
if (selfinfo.length) {
wchar_t* wmessage = new wchar_t[selfinfo.length + 1];
ZeroMemory(wmessage, (selfinfo.length + 1) * 2);
ReadProcessMemory(hProcess, (LPCVOID)selfinfo.message, wmessage, selfinfo.length * 2, &dwWriteSize);
SelfInfoString += wmessage;
delete[] wmessage;
wmessage = NULL;
}
DeleteSelfInfoCache();
return SelfInfoString;
}
\ No newline at end of file
#pragma once
#include <windows.h>
#include <iostream>
using namespace std;
std::wstring GetSelfInfo();
\ No newline at end of file
......@@ -5,7 +5,21 @@ struct GetUserInfoStruct {
DWORD length;
};
VOID DeleteUserInfoCache() {
if (!hProcess)
return;
DWORD dwId = 0;
DWORD DeleteUserInfoCacheProcAddr = GetWeChatRobotBase() + DeleteUserInfoCacheOffset;
HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)DeleteUserInfoCacheProcAddr, NULL, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
}
}
std::wstring GetWxUserInfo(wchar_t* wxid) {
if (!hProcess)
return L"";
wstring WString = L"";
DWORD GetUserInfoProcAddr = GetWeChatRobotBase() + GetWxUserInfoOffset;
LPVOID wxidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
......@@ -35,5 +49,7 @@ std::wstring GetWxUserInfo(wchar_t* wxid) {
}
VirtualFreeEx(hProcess, wxidaddr, 0, MEM_RELEASE);
DeleteUserInfoCache();
return WString;
}
\ No newline at end of file
}
......@@ -69,4 +69,13 @@ STDMETHODIMP CWeChatRobot::CGetWxUserInfo(BSTR wxid,BSTR* __result) {
string smessage = _com_util::ConvertBSTRToString((BSTR)(GetWxUserInfo(wxid).c_str()));
*__result = _com_util::ConvertStringToBSTR(smessage.c_str());
return S_OK;
}
/*
* 参数1:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CGetSelfInfo(BSTR* __result) {
string smessage = _com_util::ConvertBSTRToString((BSTR)(GetSelfInfo().c_str()));
*__result = _com_util::ConvertStringToBSTR(smessage.c_str());
return S_OK;
}
\ No newline at end of file
......@@ -58,6 +58,7 @@ public:
STDMETHODIMP CSendFile(BSTR wxid, BSTR filepath, int* __result);
STDMETHODIMP CGetFriendList(BSTR* __result);
STDMETHODIMP CGetWxUserInfo(BSTR wxid, BSTR* __result);
STDMETHODIMP CGetSelfInfo(BSTR* __result);
};
OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot)
......@@ -23,6 +23,7 @@ interface IWeChatRobot : IDispatch
[id(5)] HRESULT CSendFile([in] BSTR wxid, [in] BSTR filepath, [out, retval] int* __result);
[id(6)] HRESULT CGetFriendList([out, retval] BSTR* __result);
[id(7)] HRESULT CGetWxUserInfo([in] BSTR wxid, [out, retval] BSTR* __result);
[id(8)] HRESULT CGetSelfInfo([out, retval] BSTR* __result);
};
[
uuid(721abb35-141a-4aa2-94f2-762e2833fa6c),
......
......@@ -217,6 +217,7 @@
<ClInclude Include="pch.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="robotdata.h" />
<ClInclude Include="SelfInfo.h" />
<ClInclude Include="SendFile.h" />
<ClInclude Include="SendImage.h" />
<ClInclude Include="SendText.h" />
......@@ -235,6 +236,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="SelfInfo.cpp" />
<ClCompile Include="SendFile.cpp" />
<ClCompile Include="SendImage.cpp" />
<ClCompile Include="SendText.cpp" />
......
......@@ -41,6 +41,9 @@
<Filter Include="好友相关\好友信息">
<UniqueIdentifier>{cdd9e8b4-4576-499c-b20e-60e05911f6d6}</UniqueIdentifier>
</Filter>
<Filter Include="个人信息">
<UniqueIdentifier>{82fef7e4-e819-4cb2-9087-40ae1f426e73}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
......@@ -85,6 +88,9 @@
<ClInclude Include="UserInfo.h">
<Filter>好友相关\好友信息</Filter>
</ClInclude>
<ClInclude Include="SelfInfo.h">
<Filter>个人信息</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WeChatRobotCOM.cpp">
......@@ -120,6 +126,9 @@
<ClCompile Include="UserInfo.cpp">
<Filter>好友相关\好友信息</Filter>
</ClCompile>
<ClCompile Include="SelfInfo.cpp">
<Filter>个人信息</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
......
......@@ -117,6 +117,9 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ BSTR wxid,
/* [retval][out] */ BSTR *__result) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CGetSelfInfo(
/* [retval][out] */ BSTR *__result) = 0;
};
......@@ -211,6 +214,10 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ BSTR wxid,
/* [retval][out] */ BSTR *__result);
/* [id] */ HRESULT ( STDMETHODCALLTYPE *CGetSelfInfo )(
IWeChatRobot * This,
/* [retval][out] */ BSTR *__result);
END_INTERFACE
} IWeChatRobotVtbl;
......@@ -268,6 +275,9 @@ EXTERN_C const IID IID_IWeChatRobot;
#define IWeChatRobot_CGetWxUserInfo(This,wxid,__result) \
( (This)->lpVtbl -> CGetWxUserInfo(This,wxid,__result) )
#define IWeChatRobot_CGetSelfInfo(This,__result) \
( (This)->lpVtbl -> CGetSelfInfo(This,__result) )
#endif /* COBJMACROS */
......
......@@ -49,7 +49,7 @@
#include "WeChatRobotCOM_i.h"
#define TYPE_FORMAT_STRING_SIZE 71
#define PROC_FORMAT_STRING_SIZE 301
#define PROC_FORMAT_STRING_SIZE 337
#define EXPR_FORMAT_STRING_SIZE 1
#define TRANSMIT_AS_TABLE_SIZE 0
#define WIRE_MARSHAL_TABLE_SIZE 1
......@@ -370,6 +370,36 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor
/* 298 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CGetSelfInfo */
/* 300 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 302 */ NdrFcLong( 0x0 ), /* 0 */
/* 306 */ NdrFcShort( 0xe ), /* 14 */
/* 308 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 310 */ NdrFcShort( 0x0 ), /* 0 */
/* 312 */ NdrFcShort( 0x8 ), /* 8 */
/* 314 */ 0x45, /* Oi2 Flags: srv must size, has return, has ext, */
0x2, /* 2 */
/* 316 */ 0x8, /* 8 */
0x43, /* Ext Flags: new corr desc, clt corr check, has range on conformance */
/* 318 */ NdrFcShort( 0x1 ), /* 1 */
/* 320 */ NdrFcShort( 0x0 ), /* 0 */
/* 322 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter __result */
/* 324 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */
/* 326 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
/* 328 */ NdrFcShort( 0x3c ), /* Type Offset=60 */
/* Return value */
/* 330 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 332 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 334 */ 0x8, /* FC_LONG */
0x0, /* 0 */
0x0
}
};
......@@ -470,7 +500,8 @@ static const unsigned short IWeChatRobot_FormatStringOffsetTable[] =
126,
174,
222,
258
258,
300
};
static const MIDL_STUBLESS_PROXY_INFO IWeChatRobot_ProxyInfo =
......@@ -494,7 +525,7 @@ static const MIDL_SERVER_INFO IWeChatRobot_ServerInfo =
0,
0,
0};
CINTERFACE_PROXY_VTABLE(14) _IWeChatRobotProxyVtbl =
CINTERFACE_PROXY_VTABLE(15) _IWeChatRobotProxyVtbl =
{
&IWeChatRobot_ProxyInfo,
&IID_IWeChatRobot,
......@@ -511,7 +542,8 @@ CINTERFACE_PROXY_VTABLE(14) _IWeChatRobotProxyVtbl =
(void *) (INT_PTR) -1 /* IWeChatRobot::CSendImage */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CSendFile */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetFriendList */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetWxUserInfo */
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetWxUserInfo */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetSelfInfo */
};
......@@ -527,6 +559,7 @@ static const PRPC_STUB_FUNCTION IWeChatRobot_table[] =
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2
};
......@@ -534,7 +567,7 @@ CInterfaceStubVtbl _IWeChatRobotStubVtbl =
{
&IID_IWeChatRobot,
&IWeChatRobot_ServerInfo,
14,
15,
&IWeChatRobot_table[-3],
CStdStubBuffer_DELEGATING_METHODS
};
......
......@@ -6,10 +6,17 @@
DWORD SendImageOffset = 0x0;
DWORD SendTextOffset = 0x0;
DWORD SendFileOffset = 0x0;
DWORD GetFriendListInitOffset = 0x0;
DWORD GetFriendListRemoteOffset = 0x0;
DWORD GetFriendListFinishOffset = 0x0;
DWORD GetWxUserInfoOffset = 0x0;
DWORD DeleteUserInfoCacheOffset = 0x0;
DWORD GetSelfInfoOffset = 0x0;
DWORD DeleteSelfInfoCacheOffset = 0x0;
wstring SelfInfoString = L"";
HANDLE hProcess = NULL;
......@@ -77,15 +84,20 @@ void GetProcOffset(wchar_t* workPath) {
DWORD GetFriendListInitProcAddr = (DWORD)GetProcAddress(hd, GetFriendListInit);
GetFriendListInitOffset = GetFriendListInitProcAddr - WeChatBase;
DWORD GetFriendListRemoteProcAddr = (DWORD)GetProcAddress(hd, GetFriendListRemote);
GetFriendListRemoteOffset = GetFriendListRemoteProcAddr - WeChatBase;
DWORD GetFriendListFinishProcAddr = (DWORD)GetProcAddress(hd, GetFriendListFinish);
GetFriendListFinishOffset = GetFriendListFinishProcAddr - WeChatBase;
DWORD GetWxUserInfoProcAddr = (DWORD)GetProcAddress(hd, GetWxUserInfoRemote);
GetWxUserInfoOffset = GetWxUserInfoProcAddr - WeChatBase;
DWORD DeleteUserInfoCacheProcAddr = (DWORD)GetProcAddress(hd, DeleteUserInfoCacheRemote);
DeleteUserInfoCacheOffset = DeleteUserInfoCacheProcAddr - WeChatBase;
DWORD GetSelfInfoProcAddr = (DWORD)GetProcAddress(hd, GetSelfInfoRemote);
GetSelfInfoOffset = GetSelfInfoProcAddr - WeChatBase;
DWORD DeleteSelfInfoCacheProcAddr = (DWORD)GetProcAddress(hd, DeleteSelfInfoCacheRemote);
DeleteSelfInfoCacheOffset = DeleteSelfInfoCacheProcAddr - WeChatBase;
FreeLibrary(hd);
delete[] dllpath;
......@@ -120,6 +132,7 @@ DWORD StopRobotService() {
return 1;
DWORD wxPid = GetWeChatPid();
RemoveDll(wxPid);
ZeroMemory((wchar_t*)SelfInfoString.c_str(), SelfInfoString.length() * 2 + 2);
CloseHandle(hProcess);
return 0;
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
#include "SendFile.h"
#include "FriendList.h"
#include "UserInfo.h"
#include "SelfInfo.h"
extern HANDLE hProcess;
extern DWORD SendImageOffset;
......@@ -16,6 +17,11 @@ extern DWORD GetFriendListRemoteOffset;
extern DWORD GetFriendListFinishOffset;
extern DWORD GetWxUserInfoOffset;
extern DWORD DeleteUserInfoCacheOffset;
extern DWORD GetSelfInfoOffset;
extern DWORD DeleteSelfInfoCacheOffset;
extern wstring SelfInfoString;
#define dllname L"DWeChatRobot.dll"
......@@ -27,4 +33,8 @@ extern DWORD GetWxUserInfoOffset;
#define GetFriendListRemote "GetFriendListRemote"
#define GetFriendListFinish "GetFriendListFinish"
#define GetWxUserInfoRemote "GetWxUserInfoRemote"
\ No newline at end of file
#define GetWxUserInfoRemote "GetWxUserInfoRemote"
#define DeleteUserInfoCacheRemote "DeleteUserInfoCacheRemote"
#define GetSelfInfoRemote "GetSelfInfoRemote"
#define DeleteSelfInfoCacheRemote "DeleteSelfInfoCacheRemote"
\ No newline at end of file
......@@ -156,6 +156,8 @@
<ClInclude Include="FriendList.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="SaveGif.h" />
<ClInclude Include="SelfInfo.h" />
<ClInclude Include="SendArticle.h" />
<ClInclude Include="SendFile.h" />
<ClInclude Include="SendImage.h" />
<ClInclude Include="SendText.h" />
......@@ -171,6 +173,8 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="SaveGif.cpp" />
<ClCompile Include="SelfInfo.cpp" />
<ClCompile Include="SendArticle.cpp" />
<ClCompile Include="SendFile.cpp" />
<ClCompile Include="SendImage.cpp" />
<ClCompile Include="SendText.cpp" />
......
......@@ -40,6 +40,12 @@
<Filter Include="好友相关\好友信息">
<UniqueIdentifier>{564cc9ef-a939-4bfd-a420-a08b3072d198}</UniqueIdentifier>
</Filter>
<Filter Include="个人信息">
<UniqueIdentifier>{722c02ee-dda5-4a6a-9443-f1ed3c112709}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送文章">
<UniqueIdentifier>{edd6e39f-235b-4db5-aea1-ec2c8d0072c5}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
......@@ -66,6 +72,12 @@
<ClInclude Include="UserInfo.h">
<Filter>好友相关\好友信息</Filter>
</ClInclude>
<ClInclude Include="SelfInfo.h">
<Filter>个人信息</Filter>
</ClInclude>
<ClInclude Include="SendArticle.h">
<Filter>发送消息\发送文章</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
......@@ -95,5 +107,11 @@
<ClCompile Include="UserInfo.cpp">
<Filter>好友相关\好友信息</Filter>
</ClCompile>
<ClCompile Include="SelfInfo.cpp">
<Filter>个人信息</Filter>
</ClCompile>
<ClCompile Include="SendArticle.cpp">
<Filter>发送消息\发送文章</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
#include "pch.h"
#include <vector>
wstring selfinfo = L"";
struct SelfInfoStruct {
DWORD message;
DWORD length;
} ret;
DWORD GetSelfInfoRemote() {
DWORD WeChatWinBase = GetWeChatWinBase();
vector<DWORD> SelfInfoAddr = {
*(DWORD*)(WeChatWinBase + 0x21DC9C4),
WeChatWinBase + 0x21DCBB8,
*(DWORD*)(WeChatWinBase + 0x21DCA3C),
*(DWORD*)(WeChatWinBase + 0x21DCB74),
*(DWORD*)(WeChatWinBase + 0x21DCD34),
*(DWORD*)(WeChatWinBase + 0x21DCD1C),
WeChatWinBase + 0x21DCC30,
WeChatWinBase + 0x21DCB44,
WeChatWinBase + 0x21DCB5C,
WeChatWinBase + 0x21DCA70
};
vector<wstring> SelfInfoKey = {
L"\"wxId\"",
L"\"wxNumber\"",
L"\"wxNickName\"",
L"\"wxSignature\"",
L"\"wxBigAvatar\"",
L"\"wxSmallAvatar\"",
L"\"wxNation\"",
L"\"wxProvince\"",
L"\"wxCity\"",
L"\"PhoneNumber\""
};
selfinfo = selfinfo + L"{";
for (unsigned int i = 0; i < SelfInfoAddr.size(); i++) {
selfinfo = selfinfo + SelfInfoKey[i] + L":";
selfinfo = selfinfo + L"\"";
char* temp = (*((DWORD*)SelfInfoAddr[i]) != 0) ? (char*)SelfInfoAddr[i] : (char*)"null";
wchar_t* wtemp = new wchar_t[strlen(temp) + 1];
MultiByteToWideChar(CP_UTF8, MB_COMPOSITE, temp, -1, wtemp, strlen(temp) + 1);
selfinfo = selfinfo + wtemp;
selfinfo = selfinfo + L"\"";
if(i!= SelfInfoAddr.size() - 1)
selfinfo = selfinfo + L",";
delete[] wtemp;
wtemp = NULL;
}
selfinfo = selfinfo + L"}";
ret.message = (DWORD)selfinfo.c_str();
ret.length = selfinfo.length();
#ifdef _DEBUG
wcout.imbue(locale("chs"));
wcout << selfinfo << endl;
DeleteSelfInfoCacheRemote();
#endif
return (DWORD)&ret;
}
VOID DeleteSelfInfoCacheRemote() {
if (ret.length) {
ZeroMemory((wchar_t*)ret.message, ret.length*2 + 2);
ret.length = 0;
selfinfo = L"";
}
}
\ No newline at end of file
#pragma once
#include<windows.h>
#include<iostream>
using namespace std;
extern "C" __declspec(dllexport) DWORD GetSelfInfoRemote();
extern "C" __declspec(dllexport) VOID DeleteSelfInfoCacheRemote();
\ No newline at end of file
#include "pch.h"
struct SendArticleStruct {
DWORD title;
DWORD abstract;
DWORD wxid;
DWORD url;
};
struct WxSendXmlStruct
{
wchar_t* buffer;
DWORD length;
DWORD maxLength;
DWORD fill1;
DWORD fill2;
char nullbuffer[0x3C] = { 0 };
WxSendXmlStruct(wchar_t* pStr) {
buffer = pStr;
length = wcslen(pStr);
maxLength = wcslen(pStr) * 2;
fill1 = 0x0;
fill2 = 0x0;
}
};
struct WxSenderStruct
{
wchar_t* buffer;
DWORD length;
DWORD maxLength;
DWORD fill1;
DWORD fill2;
char nullbuffer[0x64] = { 0 };
WxSenderStruct(wchar_t* pStr) {
buffer = pStr;
length = wcslen(pStr);
maxLength = wcslen(pStr) * 2;
fill1 = 0x0;
fill2 = 0x0;
}
};
BOOL SendArticle(wchar_t* wxid,wchar_t* title, wchar_t* abstract, wchar_t* url) {
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD SendArticleCall = WeChatWinBase + 0x03297840 - 0x02F20000;
char* sselfwxid = (char*)(*(DWORD*)(WeChatWinBase + 0x21DC9C4));
wchar_t* wselfwxid = new wchar_t[strlen(sselfwxid) + 1];
MultiByteToWideChar(CP_ACP, MB_COMPOSITE, sselfwxid, -1, wselfwxid, strlen(sselfwxid) + 1);
wchar_t* xmlbuffer = new wchar_t[0x2000];
ZeroMemory(xmlbuffer, 0x2000 * 2);
swprintf_s(xmlbuffer,0x2000, (wchar_t*)L"<msg>\n <fromusername>%ws</fromusername>\n <scene>0</scene>\n <commenturl></commenturl>\n <appmsg appid=\"\" sdkver=\"0\">\n <title>%ws</title>\n <des>%ws</des>\n <action>view</action>\n <type>5</type>\n <showtype>0</showtype>\n <content></content>\n <url>%ws</url>\n <dataurl></dataurl>\n <lowurl></lowurl>\n <lowdataurl></lowdataurl>\n <recorditem>\n <![CDATA[]]>\n </recorditem>\n <thumburl></thumburl>\n <messageaction></messageaction>\n <extinfo></extinfo>\n <sourceusername></sourceusername>\n <sourcedisplayname></sourcedisplayname>\n <commenturl></commenturl>\n <appattach>\n <totallen>0</totallen>\n <attachid></attachid>\n <emoticonmd5></emoticonmd5>\n <fileext></fileext>\n <aeskey></aeskey>\n </appattach>\n <weappinfo>\n <pagepath></pagepath>\n <username></username>\n <appid></appid>\n <appservicetype>0</appservicetype>\n </weappinfo>\n <websearch />\n </appmsg>\n <appinfo>\n <version>1</version>\n <appname>Window wechat</appname>\n </appinfo>\n</msg>",
wselfwxid,title,abstract,url);
DWORD sendtype = 0x5;
WxSenderStruct pSender(wselfwxid);
char nullbuffer[0x1C] = { 0 };
char imgbuffer[0x3C] = { 0 };
WxSendXmlStruct pXml(xmlbuffer);
WxSenderStruct pReceiver(wxid);
char buffer[0xF70] = { 0 };
DWORD isSuccess = 0x0;
__asm {
pushad;
pushfd;
mov eax, [sendtype];
push eax;
lea eax, nullbuffer;
lea edx, pSender;
push eax;
lea eax, imgbuffer;
push eax;
lea eax, pXml;
push eax;
lea edi, pReceiver;
push edi;
lea ecx, buffer;
call SendArticleCall;
add esp, 0x14;
mov isSuccess, eax;
popfd;
popad;
}
delete[] xmlbuffer;
xmlbuffer = NULL;
delete[] wselfwxid;
wselfwxid = NULL;
return isSuccess;
}
\ No newline at end of file
#pragma once
#include<windows.h>
BOOL SendArticle(wchar_t* wxid, wchar_t* title, wchar_t* abstract, wchar_t* url);
\ No newline at end of file
......@@ -3,9 +3,12 @@
#include <string>
#include <vector>
#define GetUserInfoCall1Offset 0x645BD9A0 - 0x64530000
#define GetUserInfoCall2Offset 0x64C08420 - 0x64530000
#define GetUserInfoCall3Offset 0x64914260 - 0x64530000
#define GetUserInfoCall1Offset 0x5F917490 - 0x5F230000
#define GetUserInfoCall2Offset 0x5F2BD9A0 - 0x5F230000
#define GetUserInfoCall3Offset 0x5F619F70 - 0x5F230000
#define DeleteCacheCall1Offset 0x56C349A0 - 0x56B80000
#define DeleteCacheCall2Offset 0x56D983B0 - 0x56B80000
struct GetUserInfoStruct {
DWORD message;
......@@ -15,19 +18,19 @@ struct GetUserInfoStruct {
wstring wUserInfo = L"";
GetUserInfoStruct ret = { 0 };
struct GetDetailUserInfoStruct {
struct GetDetailUserInfoParamStruct {
WxString* pWxString;
DWORD ptr1 = 0;
DWORD ptr2 = 0;
char fill[0x18] = { 0 };
GetDetailUserInfoStruct(WxString* pWxString) {
GetDetailUserInfoParamStruct(WxString* pWxString) {
this->pWxString = pWxString;
ptr1 = DWORD(pWxString) + sizeof(WxString);
ptr2 = DWORD(pWxString) + sizeof(WxString);
}
};
struct UserInfoBaseStruct {
struct UserInfoBaseParamStruct {
DWORD data;
DWORD endbuffer1;
DWORD endbuffer2;
......@@ -82,7 +85,7 @@ DWORD GetWxUserInfoRemote(LPVOID lparamter) {
wchar_t* userwxid = (wchar_t*)lparamter;
DWORD address = 0;
if (!GetUserDetailInfoByWxId(userwxid, address)) {
if (!GetUserInfoByWxId(userwxid, address)) {
return 0;
}
ret.message = (DWORD)wUserInfo.c_str();
......@@ -90,29 +93,36 @@ DWORD GetWxUserInfoRemote(LPVOID lparamter) {
return (DWORD)&ret;
}
VOID DeleteUserInfoCacheRemote() {
if (ret.length) {
ZeroMemory((wchar_t*)ret.message, ret.length * 2 + 2);
ret.length = 0;
wUserInfo = L"";
}
}
BOOL GetUserDetailInfoByWxId(wchar_t* wxid,DWORD &address) {
BOOL GetUserInfoByWxId(wchar_t* wxid,DWORD &address) {
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD GetUserDetailInfoCall1 = WeChatWinBase + 0x5F917490 - 0x5F230000;
DWORD GetUserDetailInfoCall2 = WeChatWinBase + 0x5F2BD9A0 - 0x5F230000;
DWORD GetUserDetailInfoCall3 = WeChatWinBase + 0x5F619F70 - 0x5F230000;
DWORD GetUserDetailInfoCall1 = WeChatWinBase + GetUserInfoCall1Offset;
DWORD GetUserDetailInfoCall2 = WeChatWinBase + GetUserInfoCall2Offset;
DWORD GetUserDetailInfoCall3 = WeChatWinBase + GetUserInfoCall3Offset;
DWORD DeleteCacheCall1 = WeChatWinBase + 0x56C349A0 - 0x56B80000;
DWORD DeleteCacheCall2 = WeChatWinBase + 0x56D983B0 - 0x56B80000;
DWORD DeleteCacheCall1 = WeChatWinBase + DeleteCacheCall1Offset;
DWORD DeleteCacheCall2 = WeChatWinBase + DeleteCacheCall2Offset;
WxString* pWxid = new WxString;
pWxid->buffer = wxid;
pWxid->length = wcslen(wxid);
pWxid->maxLength = wcslen(wxid) * 2;
UserInfoBaseStruct temp = { 0 };
UserInfoBaseStruct userinfo = { 0 };
GetDetailUserInfoStruct pUser(pWxid);
UserInfoBaseParamStruct temp = { 0 };
UserInfoBaseParamStruct userinfo = { 0 };
GetDetailUserInfoParamStruct pUser(pWxid);
DWORD isSuccess = 0;
__asm {
pushad;
pushfd;
mov eax, 0x7;
// mov eax, 0x7;
lea ecx, pUser;
lea edx, temp;
call GetUserDetailInfoCall1;
......@@ -130,6 +140,7 @@ BOOL GetUserDetailInfoByWxId(wchar_t* wxid,DWORD &address) {
address = userinfo.data;
if(isSuccess != 0)
WxUserInfo(address);
// 释放内存
__asm {
pushad;
pushfd;
......@@ -145,11 +156,12 @@ BOOL GetUserDetailInfoByWxId(wchar_t* wxid,DWORD &address) {
return (isSuccess != 0);
}
BOOL GetWxUserInfoByWxid(wchar_t* wxid, DWORD& address) {
// 另外一个查询好友信息的地方
BOOL GetWxUserInfoByWxid2(wchar_t* wxid, DWORD& address) {
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD WxUserDataCall1 = WeChatWinBase + GetUserInfoCall1Offset;
DWORD WxUserDataCall2 = WeChatWinBase + GetUserInfoCall2Offset;
DWORD WxUserDataCall3 = WeChatWinBase + GetUserInfoCall3Offset;
DWORD WxUserDataCall1 = WeChatWinBase + 0x645BD9A0 - 0x64530000;
DWORD WxUserDataCall2 = WeChatWinBase + 0x64C08420 - 0x64530000;
DWORD WxUserDataCall3 = WeChatWinBase + 0x64914260 - 0x64530000;
char buffer[0xF90] = { 0 };
WxBaseStruct pWxid(wxid);
DWORD r_ebx = 0;
......
#pragma once
#include<windows.h>
BOOL GetWxUserInfoByWxid(wchar_t* wxid, DWORD& address);
BOOL GetUserDetailInfoByWxId(wchar_t* wxid, DWORD& address);
extern "C" __declspec(dllexport) DWORD GetWxUserInfoRemote(LPVOID lparamter);
\ No newline at end of file
BOOL GetWxUserInfoByWxid2(wchar_t* wxid, DWORD& address);
BOOL GetUserInfoByWxId(wchar_t* wxid, DWORD& address);
extern "C" __declspec(dllexport) DWORD GetWxUserInfoRemote(LPVOID lparamter);
extern "C" __declspec(dllexport) VOID DeleteUserInfoCacheRemote();
\ No newline at end of file
......@@ -23,12 +23,10 @@ BOOL APIENTRY DllMain( HMODULE hModule,
printf("SendFile 0x%08X\n", (DWORD)SendFile);
printf("GetFriendList 0x%08X\n", (DWORD)GetFriendList);
printf("HookExtractExpression 0x%08X\n", (DWORD)HookExtractExpression);
printf("GetWxUserInfoByWxid 0x%08X\n", (DWORD)GetWxUserInfoByWxid);
printf("GetUserDetailInfoByWxId 0x%08X\n", (DWORD)GetUserDetailInfoByWxId);
printf("GetWxUserInfoRemote 0x%08X\n", (DWORD)GetWxUserInfoRemote);
printf("GetUserInfoByWxId 0x%08X\n", (DWORD)GetUserInfoByWxId);
printf("SendArticle 0x%08X\n", (DWORD)SendArticle);
system("pause");
wchar_t* wxid = (wchar_t*)L"wxid_ltedgfwcw7yu22";
GetWxUserInfoRemote(wxid);
SendArticle((WCHAR*)L"filehelper",(WCHAR*)L"这是标题",(WCHAR*)L"这是摘要",(WCHAR*)L"https://www.ljczero.top/article/2022/3/13/133.html");
#endif
break;
}
......
......@@ -14,9 +14,11 @@
#include "SendImage.h"
#include "SendText.h"
#include "SendFile.h"
#include "SendArticle.h"
#include "FriendList.h"
#include "SaveGif.h"
#include "UserInfo.h"
#include "SelfInfo.h"
#endif //PCH_H
using namespace std;
......
此差异已折叠。
B^D:\C++\COMWECHATROBOT\DWECHATROBOT\PCH.CPP
B^D:\C++\COMWECHATROBOT\DWECHATROBOT\PCH.CPP
B^D:\C++\COMWECHATROBOT\DWECHATROBOT\PCH.CPP
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
Debug|x64|D:\C++\ComWeChatRobot\|
......@@ -34,9 +34,19 @@ class WeChatRobot():
self.robot = comtypes.client.CreateObject("WeChatRobot.CWeChatRobot")
self.dllpath = dllpath
self.AddressBook = []
self.myinfo = {}
def StartService(self):
return self.robot.CStartRobotService(self.dllpath)
status = self.robot.CStartRobotService(self.dllpath)
if status == 0:
self.myinfo = self.GetSelfInfo()
return status
def GetSelfInfo(self):
myinfo = self.robot.CGetSelfInfo().replace('\n','\\n')
myinfo = ast.literal_eval(myinfo)
myinfo['wxBigAvatar'] = myinfo['wxBigAvatar'].replace("/132","/0")
return myinfo
def StopService(self):
return self.robot.CStopRobotService()
......@@ -101,33 +111,34 @@ class WeChatRobot():
def GetChatSession(self,wxid):
return ChatSession(self.robot, wxid)
def GetWxDetailUserInfo(self,wxid):
return self.robot.CGetWxUserInfo(wxid)
if __name__ == '__main__':
# DWeChatRobot.dll path
dllpath = r'D:\VS2019C++\MyWeChatRobot\Release'
def GetWxUserInfo(self,wxid):
userinfo = self.robot.CGetWxUserInfo(wxid).replace('\n','\\n')
return ast.literal_eval(userinfo)
def test():
# image full path
imgpath = r"C:\Users\Administrator\Desktop\快捷\wechat\测试图片.jpg"
# file full path
filepath = r"C:\Users\Administrator\Desktop\快捷\wechat\MyWeChatRobot.zip"
# mp4 full path
mp4path = r"C:\Users\Administrator\Desktop\快捷\wechat\wxsend.mp4"
wx = WeChatRobot(dllpath)
wx.StartService()
me = wx.GetFriendByWxNickName("文件传送助手")
session = wx.GetChatSession(me.get('wxid'))
print(me.get('wxid'))
session.SendText('来自python的消息')
a = wx.GetWxDetailUserInfo(me.get('wxid'))
print(a)
session.SendImage(imgpath)
session.SendFile(filepath)
session.SendMp4(mp4path)
if __name__ == '__main__':
# DWeChatRobot.dll path
dllpath = r'D:\C++\ComWeChatRobot\Release'
wx = WeChatRobot(dllpath)
wx.StartService()
wxid = wx.GetFriendByWxNickName("传说中的勇者").get('wxid')
print(wx.myinfo)
print(wx.GetWxUserInfo(wxid))
wx.StopService()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册