好友
阅读权限20
听众
最后登录1970-1-1
|
小俊
发表于 2018-5-19 13:02
本帖最后由 wushaominkk 于 2019-6-6 21:21 编辑
更新时间:2018年12月5日
POE SPY v0.2
[C++] 纯文本查看 复制代码
#include <Windows.h>
#include <stdio.h>
#pragma warning(disable:4996)
#define SEND_RVA 0x6B2878 // 83 C1 0C 50 50 8B 11 FF 52 1C C2 08 00
#define RECV_RVA 0x6B28A5 // 81 C1 9C 00 00 00 50 50 8B 11 FF 52 1C C2 08 00
class HOOK
{
public:
HOOK(DWORD HookAddr, DWORD FakeAddr)
{
// 获取游戏模块基址
m_HookAddr = (DWORD)GetModuleHandle(NULL);
m_HookAddr += HookAddr;
m_FakeAddr = FakeAddr;
}
// 需要Hook的地址
DWORD m_HookAddr;
// 需要跳转的地址
DWORD m_FakeAddr;
// 原始代码
byte m_OldCode[5];
// 是否开启
BOOL m_State = FALSE;
// Hook
void OnHook()
{
if (m_State == FALSE)
{
// 设置状态为开启
m_State = TRUE;
// 保存原始代码
SetMemory(m_OldCode, (void*)m_HookAddr);
// Jmp 0xXXXXXXXX
char JmpCode[5] = { 0xE9 };
*(DWORD*)&JmpCode[1] = (m_FakeAddr - m_HookAddr) - 5;
// 修改代码
SetMemory((void*)m_HookAddr, JmpCode);
}
}
// UnHook
void UnHook()
{
if (m_State == TRUE)
{
// 设置状态为关闭
m_State = FALSE;
// 还原代码
SetMemory((void*)m_HookAddr, m_OldCode);
}
}
// 绕过页保护属性修改内存
static void SetMemory(void * Dst, void * Src, size_t size = 5)
{
// 用来保存内存页属性
DWORD OldProtect;
// 修改页保护属性
VirtualProtect((LPVOID)Dst, size, PAGE_EXECUTE_READWRITE, &OldProtect);
// 内存拷贝
memcpy(Dst, Src, size);
// 还原页保护属性
VirtualProtect((LPVOID)Dst, size, OldProtect, &OldProtect);
}
};
// ================================ Hook Send ================================
void __stdcall SendHandler(byte * buf, size_t len)
{
printf("发送字节数:%d\n", len);
}
DWORD SendBackAddr;
void __declspec(naked) Fake_Send()
{
__asm {
pushad
push edi
push eax
call SendHandler
popad
add ecx, 0xC
push eax
push eax
jmp[SendBackAddr]
}
}
// ================================ Hook Recv ================================
void __stdcall RecvHandler(byte * buf, size_t len)
{
printf("接收字节数:%d\n", len);
}
void __declspec(naked) Fake_Recv()
{
__asm {
pushad
push[esp + 0x28]
push[esp + 0x24]
call RecvHandler
popad
ret 8
}
}
// 工作线程
DWORD WINAPI DllThread(LPVOID lpParam)
{
printf("F1:FreeLibrary And UnHook All\n");
printf("F2:Hook Send\n");
printf("F3:Hook Recv\n");
printf("F4:UnHook All\n");
// Init HOOK
SendBackAddr = (DWORD)GetModuleHandle(NULL) + SEND_RVA + 5;
HOOK SendHook(SEND_RVA, (DWORD)Fake_Send);
HOOK RecvHook(RECV_RVA, (DWORD)Fake_Recv);
// 主循环
while (!GetAsyncKeyState(VK_F1))
{
if (GetAsyncKeyState(VK_F2))
{
printf("Hook Send\n");
SendHook.OnHook();
}
if (GetAsyncKeyState(VK_F3))
{
printf("Hook Recv\n");
RecvHook.OnHook();
}
if (GetAsyncKeyState(VK_F4))
{
printf("UnHook All\n");
SendHook.UnHook();
RecvHook.UnHook();
}
Sleep(100);
}
// UnHook All
printf("FreeLibrary And UnHook All\n");
SendHook.UnHook();
RecvHook.UnHook();
// 卸载模块,并安全退出线程
FreeLibraryAndExitThread((HMODULE)lpParam, 0);
return 0;
}
// 入口点
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
// 分配一个控制台
AllocConsole();
// 设置控制台标题
SetConsoleTitleA("POE_Spy 0.2");
// 重定向输出流到控制台
freopen("CONOUT$", "w", stdout);
// 创建线程
CreateThread(0, 0, DllThread, hModule, 0, 0);
break;
case DLL_PROCESS_DETACH:
// 释放控制台
FreeConsole();
break;
}
return TRUE;
}
注入器
[C] 纯文本查看 复制代码
#include <Windows.h>
#include <TlHelp32.h>
int main()
{
// 遍历进程
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) };
Process32First(hProcessSnap, &pe32);
do
{
if (!strcmp(pe32.szExeFile, "PathOfExile.exe"))
break;
} while (Process32Next(hProcessSnap, &pe32));
CloseHandle(hProcessSnap);
// 打开进程
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
// 在目标进程申请内存
LPVOID pRemoteAddress = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
CHAR Path[] = "SPY.dll";
// 将DLL路径写入目标进程
WriteProcessMemory(hProcess, pRemoteAddress, Path, sizeof(Path), NULL);
// 创建远程线程
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0,
(LPTHREAD_START_ROUTINE)LoadLibraryA, pRemoteAddress, 0, NULL);
// 等待线程结束
WaitForSingleObject(hThread, -1);
// 释放申请的内存
VirtualFreeEx(hProcess, pRemoteAddress, 1, MEM_DECOMMIT);
// 关闭句柄
CloseHandle(hProcess);
CloseHandle(hThread);
return 0;
}
支持国际服 3.2.4b
需要配合 Dbgview
|
免费评分
-
查看全部评分
|