메모리 코드패치 소스
# code_patch.cpp |
#include <stdio.h>
#include <windows.h> #include <tlhelp32.h> int main(int argc, char* argv[]) { if(argc != 2){ printf("Usage : %s <pid>\n",argv[0]); system("pause"); return 0; } DWORD pid = atoi(argv[1]); HANDLE hProcess; HANDLE hSanp = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid); hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
MODULEENTRY32 mme; BOOL b = Module32First(hSanp, &mme); int lvl;
BYTE newdata[]={0x90, 0x90}; DWORD newdatasize = sizeof(newdata); while(b) { if(lstrcmp(mme.szModule,"******Module.dll")==0) { printf("[+]Found Target DLL: [0x%8x] %s\n", mme.modBaseAddr, mme.szModule); WriteProcessMemory(hProcess, (LPVOID)(mme.modBaseAddr+0x77d0), &newdata, newdatasize, NULL); ReadProcessMemory(hProcess, (LPVOID)(mme.modBaseAddr+0x77d0), &lvl, 2, 0); printf("[+]Success! : eb74 -> %04x\n",lvl); } b = Module32Next(hSanp, &mme); } system("pause"); CloseHandle(hSanp); } |