HOOK Send函数截取游戏数据包
来源:互联网 发布:淘宝网秋冬婴儿服装 编辑:程序博客网 时间:2024/06/04 19:55
前两天写了一个HOOK微软的加密函数然后打Log的Detours的例子,还是不够直观,这次举个简单的例子,其实完全可以应用在不加密的游戏游戏数据分析上,当然当前不加密明文传输的少之又少,此处只为学习方法。
首先在VC下建立一个DLL工程,不需要使用MFC DLL,因为不需要那个框架里面的东西。
然后新增一个源文件,写入相关代码
#include <stdio.h>#include <winsock2.h>#include <windows.h>#include "detours.h"#pragma comment( lib , "ws2_32.lib")#pragma comment( lib , "detours.lib")#pragma comment( lib , "detoured.lib")#ifdef _MANAGED#pragma managed(push, off)#endifint (WINAPI *pSend)(SOCKET s, const char* buf, int len, int flags) = send;int WINAPI SendEx(SOCKET s, const char* buf, int len, int flags);FILE *pLogFile;int WINAPI SendEx(SOCKET s, const char* buf, int len, int flags){pLogFile = fopen("c:\\SendLog.txt", "a+"); fprintf(pLogFile, "%s\r\n\n", buf);fclose(pLogFile);pLogFile = fopen("c:\\SendBin.txt", "a+");fwrite(buf, sizeof(char), len, pLogFile);fclose(pLogFile);return pSend(s, buf, len, flags);}BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved){switch(ul_reason_for_call){case DLL_THREAD_ATTACH:case DLL_PROCESS_ATTACH:{MessageBox(NULL, "Hook Send DLL OK", "Success", MB_OK);DisableThreadLibraryCalls(hModule);DetourTransactionBegin();DetourUpdateThread(GetCurrentThread());DetourAttach(&(PVOID&)pSend, SendEx);if(DetourTransactionCommit() != NO_ERROR){MessageBox(NULL, "Hook Send DLL ERROR", "Error", MB_OK);}}break;case DLL_PROCESS_DETACH:case DLL_THREAD_DETACH:{DetourTransactionBegin();DetourUpdateThread(GetCurrentThread());DetourDetach(&(PVOID&)pSend, SendEx);}break;} return TRUE;}__declspec(dllexport)LRESULT WINAPI MsgProc(int code, WPARAM wParam, LPARAM lParam){ return(CallNextHookEx(NULL,code,wParam,lParam));}#ifdef _MANAGED#pragma managed(pop)#endif
直接贴整段代码,比上次更好理解,相关的内容已经在上次解释过了,这里就说下之后注入进程的操作。
刚好在11天梯打了一把,就截取WAR3的Send数据包吧,将detoured.dll和生成的dll,HOOKSend.dll拷贝至程序所在目录(这是Detours的要求)。
待游戏开启,WAR3进程启动,可以通过进程注入工具,将HOOKSend.dll注入到进程当中。
注入成功,可以看到代码中写的MessageBox对话框。
下面就跟根据需要跑跑操作,看一下数据包都是什么内容。我没什么需求,认真打场游戏啦,可惜队友秒了....退出看看数据包抓的怎么样了。
嗯,具体内容就不分析了,可以参考相关数据包结构分析。
工程下载:下载
- HOOK Send函数截取游戏数据包
- HOOK----send
- linux 函数hook实现数据包过滤基本框架
- linux 函数hook实现数据包过滤基本框架
- 对于数据包的截取,使用linux中的netfilter钩子函数
- 对于数据包的截取,使用linux中的netfilter钩子函数
- Windows下Hook API技术(hook send)
- delphi hook send和Recv
- 游戏修改器制作教程八:D3D函数hook
- vc hook send烦请转delphi
- hook socket send recv的代码(zz)
- HOOK函数
- 游戏数据包设计
- 游戏.数据包程序
- 游戏战斗数据包
- 无dll注入游戏拦截函数截取封包
- send函数 & recv函数
- Netfilter框架通过hook捕获数据包
- 记一岁
- poj 3080 后缀自动机
- APK反破解之三:NDK编译.so动态库
- mock server —— 用于自动化测试
- APK反破解之四:Android代码动态加载技术
- HOOK Send函数截取游戏数据包
- CSS样式
- Java优化冒泡排序
- 元旦英语祝福语-恭喜发财(十四)
- phper初学objective-c之读书笔记(一)
- zoj - 1788 - Quad Trees(四分树)
- zoj - 1076 - Gene Assembly
- zoj - 2734 - Exchange Cards
- zoj - 1204 - Additive equations