分享自己写的扫雷辅助工具,0秒扫出所有雷
这学期上机课有点多,去了比较无聊,然后就和同学比赛玩扫雷,但是玩不赢同学,就想写个辅助工具玩玩
由于不懂外挂怎么是什么原理,但是自己会几种注入和反汇编,想能不能通过注入来调用里面的函数完成相应的功能呢?
于是就把扫雷逆了一下,得到以下数据
DS:[10056A8] height
DS:[1005338] height
DS:[10056AC] width
DS:[1005334] width
DS:[10056A0] 游戏难度 short型的
DS:[10056A4] 游戏的雷数
DS:[10056B0] X起始坐标
DS:[10056B4] Y起始坐标
DS:[10056B8] 是否有声音
DS:[10056BC] mark
DS:[10056C0] Tick
DS:[10056C4] Menu
DS:[10056CC] Time1
DS:[10056D0] Time2
DS:[10056D4] Time3
DS:[10056C8] Color
数组起始位置 DS:[1005340]
调用触发雷的程序
0007FD5C 00000007 |Arg1 = 00000007
0007FD60 00000001 \Arg2 = 00000001
0007FD64 0100200A 返回到 winmine.0100200A 来自 winmine.010037E1
有了这些数据,然后就用hook来监视消息
写了这样一个dll
VOID StartCalc(){ int nHeight = 0; int nWidth = 0; _asm { pushad mov eax,DS:[0x1005338] mov ebx,DS:[0x10056AC] mov [nHeight],eax mov [nWidth],ebx popad } char* pBuffer = (char*)(0x1005340);//存放数据的首地址 for(int i = 1; i <= nHeight; i++) { for(int j = 1; j <= nWidth; j++) { int nTmp = (i << 5) + j; if((pBuffer[nTmp] & 0x80) == 0) //不是雷的方格,标记为雷的区域,为1000xxxxB这种形式,已经点过或者探索过的方格为0100xxxxB的形式 { _asm { pushad push i push j mov eax,0x01003512 call eax popad } } } }}extern "C" _declspec(dllexport) LRESULT CALLBACK GetMsgProc(int code,WPARAM wParam,LPARAM lParam){ if(HC_ACTION == code) { MSG* pMsg = (MSG*)lParam; if(pMsg->message == 0x201) /* 我设计的是点一下,然后就去计算雷的位置,大家也可以设计其他的消息,比如点击中间的人脸,菜单消息,这些都逆出来了,只是没有写,还有可以设置多少时间出去计算雷,截取WM_TIME消息,然后再里面调用StartCalc()。 */ { StartCalc(); CallNextHookEx(g_hHook,code,wParam,lParam); } else { CallNextHookEx(g_hHook,code,wParam,lParam); } } return CallNextHookEx(g_hHook,code,wParam,lParam);}
#include <Windows.h>#include <iostream>#include <cstdlib>using namespace std;int main(){ HINSTANCE hInst= LoadLibrary("dll.dll"); if(NULL == hInst) { cout <<"Fail to load HookDll.dll" <<endl; return 0; } typedef bool (*INITHOOK)(HWND); INITHOOK lpProc = (INITHOOK)GetProcAddress(hInst,"InitHook"); if(lpProc == NULL) { FreeLibrary(hInst); return 0; } HWND hWnd = ::FindWindow(NULL,"扫雷"); if(hWnd == NULL) { cout << "Error hWnd" << endl; return 0; } BOOL bRet = lpProc(hWnd); cout << "Success" << endl; system("pause"); FreeLibrary(hInst); return 0;}