提交 14edb762 编写于 作者: L ljc545w

增加检测好友状态接口

上级 cec684fd
#include "pch.h"
BOOL CheckFriendStatusInit() {
if (!hProcess)
return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0;
DWORD CheckFriendStatusInitRemoteAddr = WeChatRobotBase + CheckFriendStatusInitRemoteOffset;
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)CheckFriendStatusInitRemoteAddr, NULL, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
}
return 0;
}
BOOL CheckFriendStatusFinish() {
if (!hProcess)
return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0;
DWORD CheckFriendStatusFinishRemoteAddr = WeChatRobotBase + CheckFriendStatusFinishRemoteOffset;
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)CheckFriendStatusFinishRemoteAddr, NULL, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
}
return 0;
}
DWORD CheckFriendStatus(wchar_t* wxid) {
if (!hProcess)
return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0;
DWORD dwWriteSize = 0;
DWORD dwStatus = 0;
LPVOID wxidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
if (!wxidaddr)
return 1;
WriteProcessMemory(hProcess, wxidaddr, wxid, wcslen(wxid) * 2 + 2, &dwWriteSize);
DWORD CheckFriendStatusRemoteAddr = WeChatRobotBase + CheckFriendStatusRemoteOffset;
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)CheckFriendStatusRemoteAddr, (LPVOID)wxidaddr, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &dwStatus);
CloseHandle(hThread);
}
VirtualFreeEx(hProcess, wxidaddr, 0, MEM_RELEASE);
return dwStatus;
}
\ No newline at end of file
#pragma once
#include<windows.h>
BOOL CheckFriendStatusInit();
DWORD CheckFriendStatus(wchar_t* wxid);
BOOL CheckFriendStatusFinish();
\ No newline at end of file
......@@ -6,7 +6,7 @@
// CWeChatRobot
/*
* 参数1:`MyWeChatRobot.dll`所在目录
* 参数1:`DWeChatRobot.dll`所在目录
* 参数2:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CStartRobotService(BSTR workPath, int* __result) {
......@@ -101,4 +101,29 @@ STDMETHODIMP CWeChatRobot::CGetSelfInfo(BSTR* __result) {
string smessage = _com_util::ConvertBSTRToString((BSTR)(GetSelfInfo().c_str()));
*__result = _com_util::ConvertStringToBSTR(smessage.c_str());
return S_OK;
}
/*
* 参数1:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CCheckFriendStatusInit(int* __result) {
*__result = CheckFriendStatusInit();
return S_OK;
}
/*
* 参数1:查询的wxid
* 参数2:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CCheckFriendStatus(BSTR wxid,int* __result) {
*__result = CheckFriendStatus((wchar_t*)wxid);
return S_OK;
}
/*
* 参数1:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CCheckFriendStatusFinish(int* __result) {
*__result = CheckFriendStatusFinish();
return S_OK;
}
\ No newline at end of file
......@@ -61,6 +61,9 @@ public:
STDMETHODIMP CGetFriendList(BSTR* __result);
STDMETHODIMP CGetWxUserInfo(BSTR wxid, BSTR* __result);
STDMETHODIMP CGetSelfInfo(BSTR* __result);
STDMETHODIMP CCheckFriendStatusInit(int* __result);
STDMETHODIMP CCheckFriendStatus(BSTR wxid, int* __result);
STDMETHODIMP CCheckFriendStatusFinish(int* __result);
};
OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot)
......@@ -26,6 +26,9 @@ interface IWeChatRobot : IDispatch
[id(8)] HRESULT CGetFriendList([out, retval] BSTR* __result);
[id(9)] HRESULT CGetWxUserInfo([in] BSTR wxid, [out, retval] BSTR* __result);
[id(10)] HRESULT CGetSelfInfo([out, retval] BSTR* __result);
[id(11)] HRESULT CCheckFriendStatusInit([out, retval] int* __result);
[id(12)] HRESULT CCheckFriendStatus([in] BSTR wxid, [out, retval] int* __result);
[id(13)] HRESULT CCheckFriendStatusFinish([out, retval] int* __result);
};
[
uuid(721abb35-141a-4aa2-94f2-762e2833fa6c),
......
......@@ -211,6 +211,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CheckFriendStatus.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="FriendList.h" />
<ClInclude Include="InjertDll.h" />
......@@ -230,6 +231,7 @@
<ClInclude Include="xdlldata.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CheckFriendStatus.cpp" />
<ClCompile Include="FriendList.cpp" />
<ClCompile Include="InjertDll.cpp" />
<ClCompile Include="pch.cpp">
......
......@@ -50,6 +50,9 @@
<Filter Include="发送消息\发送名片">
<UniqueIdentifier>{9d9c2a95-9243-4809-884b-70d6d87a7128}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关\好友状态">
<UniqueIdentifier>{2543fa88-031d-42ca-9dd1-ac564ee2f744}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
......@@ -103,6 +106,9 @@
<ClInclude Include="SendCard.h">
<Filter>发送消息\发送名片</Filter>
</ClInclude>
<ClInclude Include="CheckFriendStatus.h">
<Filter>好友相关\好友状态</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WeChatRobotCOM.cpp">
......@@ -147,6 +153,9 @@
<ClCompile Include="SendCard.cpp">
<Filter>发送消息\发送名片</Filter>
</ClCompile>
<ClCompile Include="CheckFriendStatus.cpp">
<Filter>好友相关\好友状态</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
......
......@@ -133,6 +133,16 @@ EXTERN_C const IID IID_IWeChatRobot;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CGetSelfInfo(
/* [retval][out] */ BSTR *__result) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CCheckFriendStatusInit(
/* [retval][out] */ int *__result) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CCheckFriendStatus(
/* [in] */ BSTR wxid,
/* [retval][out] */ int *__result) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CCheckFriendStatusFinish(
/* [retval][out] */ int *__result) = 0;
};
......@@ -246,6 +256,19 @@ EXTERN_C const IID IID_IWeChatRobot;
IWeChatRobot * This,
/* [retval][out] */ BSTR *__result);
/* [id] */ HRESULT ( STDMETHODCALLTYPE *CCheckFriendStatusInit )(
IWeChatRobot * This,
/* [retval][out] */ int *__result);
/* [id] */ HRESULT ( STDMETHODCALLTYPE *CCheckFriendStatus )(
IWeChatRobot * This,
/* [in] */ BSTR wxid,
/* [retval][out] */ int *__result);
/* [id] */ HRESULT ( STDMETHODCALLTYPE *CCheckFriendStatusFinish )(
IWeChatRobot * This,
/* [retval][out] */ int *__result);
END_INTERFACE
} IWeChatRobotVtbl;
......@@ -312,6 +335,15 @@ EXTERN_C const IID IID_IWeChatRobot;
#define IWeChatRobot_CGetSelfInfo(This,__result) \
( (This)->lpVtbl -> CGetSelfInfo(This,__result) )
#define IWeChatRobot_CCheckFriendStatusInit(This,__result) \
( (This)->lpVtbl -> CCheckFriendStatusInit(This,__result) )
#define IWeChatRobot_CCheckFriendStatus(This,wxid,__result) \
( (This)->lpVtbl -> CCheckFriendStatus(This,wxid,__result) )
#define IWeChatRobot_CCheckFriendStatusFinish(This,__result) \
( (This)->lpVtbl -> CCheckFriendStatusFinish(This,__result) )
#endif /* COBJMACROS */
......
......@@ -49,7 +49,7 @@
#include "WeChatRobotCOM_i.h"
#define TYPE_FORMAT_STRING_SIZE 71
#define PROC_FORMAT_STRING_SIZE 451
#define PROC_FORMAT_STRING_SIZE 565
#define EXPR_FORMAT_STRING_SIZE 1
#define TRANSMIT_AS_TABLE_SIZE 0
#define WIRE_MARSHAL_TABLE_SIZE 1
......@@ -504,6 +504,105 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor
/* 448 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CCheckFriendStatusInit */
/* 450 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 452 */ NdrFcLong( 0x0 ), /* 0 */
/* 456 */ NdrFcShort( 0x11 ), /* 17 */
/* 458 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 460 */ NdrFcShort( 0x0 ), /* 0 */
/* 462 */ NdrFcShort( 0x24 ), /* 36 */
/* 464 */ 0x44, /* Oi2 Flags: has return, has ext, */
0x2, /* 2 */
/* 466 */ 0x8, /* 8 */
0x41, /* Ext Flags: new corr desc, has range on conformance */
/* 468 */ NdrFcShort( 0x0 ), /* 0 */
/* 470 */ NdrFcShort( 0x0 ), /* 0 */
/* 472 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter __result */
/* 474 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 476 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
/* 478 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Return value */
/* 480 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 482 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 484 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CCheckFriendStatus */
/* 486 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 488 */ NdrFcLong( 0x0 ), /* 0 */
/* 492 */ NdrFcShort( 0x12 ), /* 18 */
/* 494 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
/* 496 */ NdrFcShort( 0x0 ), /* 0 */
/* 498 */ NdrFcShort( 0x24 ), /* 36 */
/* 500 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */
0x3, /* 3 */
/* 502 */ 0x8, /* 8 */
0x45, /* Ext Flags: new corr desc, srv corr check, has range on conformance */
/* 504 */ NdrFcShort( 0x0 ), /* 0 */
/* 506 */ NdrFcShort( 0x1 ), /* 1 */
/* 508 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter wxid */
/* 510 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
/* 512 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
/* 514 */ NdrFcShort( 0x26 ), /* Type Offset=38 */
/* Parameter __result */
/* 516 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 518 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 520 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Return value */
/* 522 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 524 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 526 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CCheckFriendStatusFinish */
/* 528 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 530 */ NdrFcLong( 0x0 ), /* 0 */
/* 534 */ NdrFcShort( 0x13 ), /* 19 */
/* 536 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 538 */ NdrFcShort( 0x0 ), /* 0 */
/* 540 */ NdrFcShort( 0x24 ), /* 36 */
/* 542 */ 0x44, /* Oi2 Flags: has return, has ext, */
0x2, /* 2 */
/* 544 */ 0x8, /* 8 */
0x41, /* Ext Flags: new corr desc, has range on conformance */
/* 546 */ NdrFcShort( 0x0 ), /* 0 */
/* 548 */ NdrFcShort( 0x0 ), /* 0 */
/* 550 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter __result */
/* 552 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 554 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
/* 556 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Return value */
/* 558 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 560 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 562 */ 0x8, /* FC_LONG */
0x0, /* 0 */
0x0
}
};
......@@ -607,7 +706,10 @@ static const unsigned short IWeChatRobot_FormatStringOffsetTable[] =
282,
336,
372,
414
414,
450,
486,
528
};
static const MIDL_STUBLESS_PROXY_INFO IWeChatRobot_ProxyInfo =
......@@ -631,7 +733,7 @@ static const MIDL_SERVER_INFO IWeChatRobot_ServerInfo =
0,
0,
0};
CINTERFACE_PROXY_VTABLE(17) _IWeChatRobotProxyVtbl =
CINTERFACE_PROXY_VTABLE(20) _IWeChatRobotProxyVtbl =
{
&IWeChatRobot_ProxyInfo,
&IID_IWeChatRobot,
......@@ -651,7 +753,10 @@ CINTERFACE_PROXY_VTABLE(17) _IWeChatRobotProxyVtbl =
(void *) (INT_PTR) -1 /* IWeChatRobot::CSendCard */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetFriendList */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetWxUserInfo */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetSelfInfo */
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetSelfInfo */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CCheckFriendStatusInit */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CCheckFriendStatus */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CCheckFriendStatusFinish */
};
......@@ -670,6 +775,9 @@ static const PRPC_STUB_FUNCTION IWeChatRobot_table[] =
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2
};
......@@ -677,7 +785,7 @@ CInterfaceStubVtbl _IWeChatRobotStubVtbl =
{
&IID_IWeChatRobot,
&IWeChatRobot_ServerInfo,
17,
20,
&IWeChatRobot_table[-3],
CStdStubBuffer_DELEGATING_METHODS
};
......
......@@ -18,6 +18,11 @@ DWORD DeleteUserInfoCacheOffset = 0x0;
DWORD GetSelfInfoOffset = 0x0;
DWORD DeleteSelfInfoCacheOffset = 0x0;
DWORD CheckFriendStatusInitRemoteOffset = 0x0;
DWORD CheckFriendStatusRemoteOffset = 0x0;
DWORD CheckFriendStatusFinishRemoteOffset = 0x0;
wstring SelfInfoString = L"";
HANDLE hProcess = NULL;
......@@ -105,6 +110,13 @@ void GetProcOffset(wchar_t* workPath) {
DWORD DeleteSelfInfoCacheProcAddr = (DWORD)GetProcAddress(hd, DeleteSelfInfoCacheRemote);
DeleteSelfInfoCacheOffset = DeleteSelfInfoCacheProcAddr - WeChatBase;
DWORD CheckFriendStatusInitRemoteAddr = (DWORD)GetProcAddress(hd, CheckFriendStatusInitRemote);
CheckFriendStatusInitRemoteOffset = CheckFriendStatusInitRemoteAddr - WeChatBase;
DWORD CheckFriendStatusRemoteAddr = (DWORD)GetProcAddress(hd, CheckFriendStatusRemote);
CheckFriendStatusRemoteOffset = CheckFriendStatusRemoteAddr - WeChatBase;
DWORD CheckFriendStatusFinishRemoteAddr = (DWORD)GetProcAddress(hd, CheckFriendStatusFinishRemote);
CheckFriendStatusFinishRemoteOffset = CheckFriendStatusFinishRemoteAddr - WeChatBase;
FreeLibrary(hd);
delete[] dllpath;
dllpath = NULL;
......@@ -142,6 +154,7 @@ DWORD StopRobotService() {
if (!hProcess)
return 1;
DWORD wxPid = GetWeChatPid();
CheckFriendStatusFinish();
RemoveDll(wxPid);
ZeroMemory((wchar_t*)SelfInfoString.c_str(), SelfInfoString.length() * 2 + 2);
CloseHandle(hProcess);
......
......@@ -8,6 +8,7 @@
#include "FriendList.h"
#include "UserInfo.h"
#include "SelfInfo.h"
#include "CheckFriendStatus.h"
extern HANDLE hProcess;
extern DWORD SendImageOffset;
......@@ -27,6 +28,11 @@ extern DWORD GetSelfInfoOffset;
extern DWORD DeleteSelfInfoCacheOffset;
extern wstring SelfInfoString;
extern DWORD CheckFriendStatusInitRemoteOffset;
extern DWORD CheckFriendStatusRemoteOffset;
extern DWORD CheckFriendStatusFinishRemoteOffset;
#define dllname L"DWeChatRobot.dll"
#define SendTextRemote "SendTextRemote"
......@@ -43,4 +49,8 @@ extern wstring SelfInfoString;
#define DeleteUserInfoCacheRemote "DeleteUserInfoCacheRemote"
#define GetSelfInfoRemote "GetSelfInfoRemote"
#define DeleteSelfInfoCacheRemote "DeleteSelfInfoCacheRemote"
\ No newline at end of file
#define DeleteSelfInfoCacheRemote "DeleteSelfInfoCacheRemote"
#define CheckFriendStatusInitRemote "CheckFriendStatusInitRemote"
#define CheckFriendStatusRemote "CheckFriendStatusRemote"
#define CheckFriendStatusFinishRemote "CheckFriendStatusFinishRemote"
\ No newline at end of file
#include "pch.h"
#define CheckFriendStatusCall1Offset 0x78861210 - 0x787A0000
#define CheckFriendStatusCall2Offset 0x03521CD0 - 0x02E20000
#define CheckFriendStatusCall3Offset 0x03521DC0 - 0x02E20000
#define CheckFriendStatusCall4Offset 0x0321FB90 - 0x02E20000
#define CheckFriendStatusParamOffset 0x0504F3BC - 0x02E20000
#define CheckFriendStatusHookOffset 0x5E0830B3 - 0x5DB60000
#define CheckFriendStatusNextCallOffset 0x5E083150 - 0x5DB60000
#define CheckFriendStatusHookJmpBackOffset 0x5E0830B8 - 0x5DB60000
DWORD CheckFriendStatusNextCallAddress = GetWeChatWinBase() + CheckFriendStatusNextCallOffset;
DWORD CheckFriendStatusHookJmpBackAddress = GetWeChatWinBase() + CheckFriendStatusHookJmpBackOffset;
char OldAsmCode[5] = { 0 };
BOOL CheckFriendStatusHooked = false;
BOOL LocalFriendStatus = 0x0;
struct FriendStatusParamStruct {
DWORD fill0 = 0x0;
DWORD fill1 = 0x0;
DWORD fill2 = -0x1;
DWORD fill3 = 0x0;
DWORD fill4 = 0x0;
DWORD fill5 = 0xF;
char nullbuffer[0xC] = { 0 };
};
void dealVerifyUserResult(DWORD result) {
if (result < 0xB0 || result > 0xB5)
return;
LocalFriendStatus = result;
}
__declspec(naked) void doHookVerifyUserResult() {
__asm {
pushfd;
pushad;
mov eax, [esi];
push eax;
call dealVerifyUserResult;
add esp, 0x4;
popad;
popfd;
call CheckFriendStatusNextCallAddress;
jmp CheckFriendStatusHookJmpBackAddress;
}
}
VOID HookFriendStatusCode(){
if (CheckFriendStatusHooked)
return;
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD dwHookAddress = WeChatWinBase + CheckFriendStatusHookOffset;
HookAnyAddress(dwHookAddress, doHookVerifyUserResult, OldAsmCode);
CheckFriendStatusHooked = true;
}
VOID UnHookFriendStatusCode() {
if (!CheckFriendStatusHooked)
return;
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD dwHookAddress = WeChatWinBase + CheckFriendStatusHookOffset;
UnHookAnyAddress(dwHookAddress,OldAsmCode);
CheckFriendStatusHooked = false;
}
VOID CheckFriendStatusInitRemote() {
HookFriendStatusCode();
}
DWORD CheckFriendStatusRemote(LPVOID lparameter) {
CheckFriendStatus((wchar_t*)lparameter);
return LocalFriendStatus;
}
VOID CheckFriendStatusFinishRemote() {
UnHookFriendStatusCode();
}
VOID __stdcall CheckFriendStatus(wchar_t* wxid) {
LocalFriendStatus = 0x0;
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD CheckFriendStatusCall1 = WeChatWinBase + CheckFriendStatusCall1Offset;
DWORD CheckFriendStatusCall2 = WeChatWinBase + CheckFriendStatusCall2Offset;
DWORD CheckFriendStatusCall3 = WeChatWinBase + CheckFriendStatusCall3Offset;
DWORD CheckFriendStatusCall4 = WeChatWinBase + CheckFriendStatusCall4Offset;
DWORD CheckFriendStatusParam = WeChatWinBase + CheckFriendStatusParamOffset;
WxBaseStruct pwxid(wxid);
FriendStatusParamStruct FriendStatusParam;
char* swxid = new char[wcslen(wxid) + 1];
ZeroMemory(swxid, wcslen(wxid) + 1);
WideCharToMultiByte(CP_ACP, 0, wxid, -1, swxid, wcslen(wxid), NULL, NULL);
pwxid.fill1 = (DWORD)swxid;
pwxid.fill2 = wcslen(wxid);
wchar_t* message = (WCHAR*)L"";
__asm {
pushad;
pushfd;
mov edi, 0x6;
mov esi, 0x0;
sub esp, 0x18;
mov eax, esp;
mov dword ptr[eax], 0x0;
mov dword ptr[eax + 0x14], 0xF;
mov dword ptr[eax + 0x10], 0x0;
sub esp, 0x18;
lea eax, FriendStatusParam;
mov ecx, esp;
push eax;
call CheckFriendStatusCall1;
push esi;
push edi;
mov edi, message;
sub esp, 0x14;
mov ecx, esp;
push -0x1;
mov eax, edi;
push eax;
call CheckFriendStatusCall2;
push 0x1;
lea eax, pwxid;
sub esp, 0x14;
mov ecx, esp;
push eax;
call CheckFriendStatusCall3;
mov eax, [CheckFriendStatusParam];
mov eax, [eax];
mov ecx, eax;
call CheckFriendStatusCall4;
popfd;
popad;
}
while (!LocalFriendStatus && CheckFriendStatusHooked) {
Sleep(10);
}
#ifdef _DEBUG
printf("wxid:%ws,status:0x%02X\n", wxid,LocalFriendStatus);
#endif
delete[] swxid;
swxid = NULL;
return;
}
\ No newline at end of file
#pragma once
#include<windows.h>
extern "C" __declspec(dllexport) VOID CheckFriendStatusInitRemote();
extern "C" __declspec(dllexport) DWORD CheckFriendStatusRemote(LPVOID lparameter);
extern "C" __declspec(dllexport) VOID CheckFriendStatusFinishRemote();
VOID __stdcall CheckFriendStatus(wchar_t* wxid);
\ No newline at end of file
......@@ -154,6 +154,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CheckFriendStatus.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="FriendList.h" />
<ClInclude Include="pch.h" />
......@@ -166,6 +167,7 @@
<ClInclude Include="UserInfo.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CheckFriendStatus.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="FriendList.cpp" />
<ClCompile Include="pch.cpp">
......
......@@ -46,6 +46,9 @@
<Filter Include="发送消息\发送名片">
<UniqueIdentifier>{fc747a68-6314-4f23-92de-a1e55275a01e}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关\好友状态">
<UniqueIdentifier>{5a6d7d8b-a126-4da1-b540-09c79886ffef}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
......@@ -78,6 +81,9 @@
<ClInclude Include="SendCard.h">
<Filter>发送消息\发送名片</Filter>
</ClInclude>
<ClInclude Include="CheckFriendStatus.h">
<Filter>好友相关\好友状态</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
......@@ -110,5 +116,8 @@
<ClCompile Include="SendCard.cpp">
<Filter>发送消息\发送名片</Filter>
</ClCompile>
<ClCompile Include="CheckFriendStatus.cpp">
<Filter>好友相关\好友状态</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -25,6 +25,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
printf("GetUserInfoByWxId 0x%08X\n", (DWORD)GetUserInfoByWxId);
printf("SendArticle 0x%08X\n", (DWORD)SendArticle);
printf("SendCard 0x%08X\n", (DWORD)SendCard);
printf("CheckFriendStatus 0x%08X\n", (DWORD)CheckFriendStatus);
#endif
break;
}
......@@ -34,7 +35,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
#ifdef _DEBUG
detach_count++;
if (detach_count != 1) {
// FreeConsole();
FreeConsole();
// UnHookAll();
}
#endif
......
......@@ -19,6 +19,7 @@
#include "UserInfo.h"
#include "SelfInfo.h"
#include "SendCard.h"
#include "CheckFriendStatus.h"
#endif //PCH_H
using namespace std;
......
......@@ -46,7 +46,6 @@ class WeChatRobot():
status = self.robot.CStartRobotService(self.dllpath)
return status
# 有bug待修复,需要判断某项信息是否是指针,修复前不要使用
def GetSelfInfo(self):
myinfo = self.robot.CGetSelfInfo().replace('\n','\\n')
try:
......@@ -123,8 +122,26 @@ class WeChatRobot():
def GetWxUserInfo(self,wxid):
userinfo = self.robot.CGetWxUserInfo(wxid).replace('\n','\\n')
return ast.literal_eval(userinfo)
def test():
def CheckFriendStatusInit(self):
return self.robot.CCheckFriendStatusInit()
def CheckFriendStatusFinish(self):
return self.robot.CCheckFriendStatusFinish()
def CheckFriendStatus(self,wxid):
_EnumFriendStatus = {
0xB0:'被删除',
0xB1:'是好友',
0xB5:'被拉黑',
}
status = self.robot.CCheckFriendStatus(wxid)
if status == 0x0:
print('请先初始化再进行检测!')
assert False
return _EnumFriendStatus[status]
def test_SendText():
import os
# DWeChatRobot.dll path
path = os.path.split(os.path.realpath(__file__))[0]
......@@ -145,10 +162,34 @@ def test():
if os.path.exists(filepath): session.SendFile(filepath)
session.SendArticle("PC微信逆向--获取通讯录","确定不来看看么?","https://www.ljczero.top/article/2022/3/13/133.html")
shared = wx.GetFriendByWxNickName("码农翻身")
if shared:
session.SendCard(shared.get('wxid'),shared.get('wxNickName'))
if shared: session.SendCard(shared.get('wxid'),shared.get('wxNickName'))
wx.StopService()
def test_FriendStatus():
import os
import time
# DWeChatRobot.dll path
f = open('Friendstatus.txt','wt',encoding = 'utf-8')
path = os.path.split(os.path.realpath(__file__))[0]
dllpath = os.path.join(path,'Release')
wx = WeChatRobot(dllpath)
wx.StartService()
FriendList = wx.GetFriendList()
wx.CheckFriendStatusInit()
index = "\t".join(['微信号','昵称','备注','状态','\n'])
f.writelines(index)
for Friend in FriendList:
result = '\t'.join(
[Friend.get('wxNumber'),Friend.get('wxNickName'),Friend.get('wxRemark'),
wx.CheckFriendStatus(Friend.get('wxid'))])
print(result)
result += '\n'
f.writelines(result)
time.sleep(1)
break
f.close()
wx.StopService()
if __name__ == '__main__':
test()
test_SendText()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册