#include <stdio.h>
#include <windows.h>
#define LUA_MULTRET -1
// Lua function prototypes.
typedef int(__cdecl *_luaL_loadfile)(void *state, char *filename);
_luaL_loadfile luaL_loadfile = NULL;
typedef int(__cdecl *_lua_pcall)(void *state, int nargs, int nresults, int errfunc);
_lua_pcall lua_pcall = NULL;
#define GLUA_STATE_PTR 0x602008 // client.dll
void init(void){
// Allocate a console and redirect console I/O.
AllocConsole();
SetConsoleTitleA("sniff_glua by anher0");
freopen("CONOUT$", "w", stdout);
freopen("CONIN$", "r", stdin);
// Get all the Lua functions we need.
HMODULE luaShared = GetModuleHandleA("lua_shared.dll");
if (!luaShared){
printf("Failed to find lua_shared.dll.\n");
return;
}
luaL_loadfile = (_luaL_loadfile)GetProcAddress(luaShared, "luaL_loadfile");
if (!luaL_loadfile){
printf("Failed to find function: luaL_loadfile.\n");
return;
}
lua_pcall = (_lua_pcall)GetProcAddress(luaShared, "lua_pcall");
if (!lua_pcall){
printf("Failed to find function: lua_pcall.\n");
return;
}
// Get client.dll
DWORD clientDLL = (DWORD)GetModuleHandleA("client.dll");
if (!clientDLL){
printf("Failed to find client.dll.\n");
return;
}
// Do the main shit.
while (1){
// Get input from the user.
char usrInput[2048] = { 0 };
fgets(usrInput, 2047, stdin);
// Get the GLua state.
DWORD CLuaInterface = *(DWORD*)(clientDLL + GLUA_STATE_PTR);
if (!CLuaInterface){
printf("Failed to get CLuaInterface.\n");
continue;
}
DWORD pGLuaState = *(DWORD*)(CLuaInterface + 0x4);
if (!pGLuaState){
printf("Failed to get lua_State.\n");
continue;
}
if (!*(BYTE*)(CLuaInterface + 0x8) && !*(DWORD*)(CLuaInterface + 0x2C)){
// Seperate and validate the user input.
char *cmd = strtok(usrInput, " ");
if (strcmp(cmd, "-run")){
printf("Unknown command: %s\n", cmd);
continue;
}
char *scrDir = strtok(NULL, "\0");
scrDir[strlen(scrDir) - 1] = '\0';
// Execute the Lua script provided.
luaL_loadfile((void*)pGLuaState, scrDir);
lua_pcall((void*)pGLuaState, 0, LUA_MULTRET, 0);
}
}
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved){
if (fdwReason == DLL_PROCESS_ATTACH)
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)init, NULL, 0, NULL);
return(1);
}
while (1){
Проект предоставляет различный материал, относящийся к сфере киберспорта, программирования, ПО для игр, а также позволяет его участникам общаться на многие другие темы. Почта для жалоб: admin@yougame.biz