Yo, i wana share a simple example of Admin Console Trainer in S4League ;)
Only Source!
[Only registered and activated users can see links. Click Here To Register...]
dllmain.cpp
CCFunction.cpp
CCFunction.h
Only Source!
[Only registered and activated users can see links. Click Here To Register...]
dllmain.cpp
Code:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "CCFunction.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
LoadConsole();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
CCFunction.cpp
Code:
#include "stdafx.h"
#include "CCFunction.h"
#include <detours.h>
void __declspec(naked) hkReadCom()
{
_asm
{
mov eaxadd, eax //Put the address contain in eax in eaxadd (DWORD var)
mov eax, [ebp - 0x04]
mov ebpadd, eax //Put the address contain in eax to ebpadd (DWORD var too)
}
char Command[20];
ReadProcessMemory(GetCurrentProcess(), (LPVOID)eaxadd, &Command, 20, NULL);//Just read the 20 first bytes of eaxadd and put in Command var
//Call my func with Command to parameter
ParseCommand(Command);
_asm
{
mov eax, [ebpadd]
mov [ebp - 0x04], eax
mov eax, [eaxadd]
push eax
mov ecx, [ebp - 0x04]
call addr//Call addr (DWORD var)
jmp RD_COM_Back//Jump to RD_COM_Back
}
}
_declspec(naked) void hkWriteResp()
{
_asm mov tmpResp, offset[MyResponse]
DWORD adr;
ReadProcessMemory(GetCurrentProcess(), (LPVOID)tmpResp, &adr, sizeof(int), NULL);
_asm {
mov eax, adr
push eax
push TypeResp
mov ecx, [ebp - 0x000001E8]
jmp RW_RES_Back
}
}
typedef int (__fastcall* typeCallResponse)(unsigned char, char*);
void ParseCommand(char* pCommand)
{
DWORD old = 0;
if(!strcmp(pCommand, "/infsp"))
{
if(!infsp)
{
VirtualProtect((LPVOID)0x00492AD2, 4, PAGE_EXECUTE_READWRITE, &old);
memcpy((void*)0x00492AD2, "\xDB\x45", 2);
VirtualProtect((LPVOID)0x00492AD2, 4, old, NULL);
ChangeResponse(" {CB-255,128,0,255}Infinite Sp Activated ! ", Response::Answer);
infsp = true;
}
else
{
VirtualProtect((LPVOID)0x00492AD2, 4, PAGE_EXECUTE_READWRITE, &old);
memcpy((void*)0x00492AD2, "\xD9\x45", 2);
VirtualProtect((LPVOID)0x00492AD2, 4, old, NULL);
ChangeResponse(" {CB-255,128,0,255}Infinite Sp Deactivated ! ", Response::Answer);
infsp = false;
}
}
else if(!strcmp(pCommand,"/help"))
{
/*typeCallResponse writResp = (typeCallResponse)0x00BE33B0;
writResp(1, " -testline1");*/
}
else
{
ChangeResponse(" {CB-255,255,255,255}Unknown Command! ", Response::Error);
}
}
void ChangeResponse(char* pResponse, Response::ResponseType resp)
{
MyResponse = pResponse;
TypeResp = resp;
}
void Activate()
{
DWORD old = 0;
VirtualProtect((LPVOID)0x00BE254A, 4, PAGE_EXECUTE_READWRITE, &old);
memcpy((void*)0x00BE254A, "\x75", 1);
VirtualProtect((LPVOID)0x00BE254A, 4, old, NULL);
}
int __fastcall hkWriteResponse(void *typ, char* command)
{
MessageBoxA(0, command, "", 0);
return mWriteResponse(typ, command);
}
void LoadConsole()
{
//Detours
DetourFunction((PBYTE)0x00BE25B3, (PBYTE)hkReadCom);
DetourFunction((PBYTE)0x00BE2ECA, (PBYTE)hkWriteResp);//display answer visualy
//mWriteResponse = (tWriteResponse)DetourFunction((PBYTE)0x00BE33B0, (PBYTE)hkWriteResponse);
Activate();
}
CCFunction.h
Code:
#include <Windows.h>
#include <string>
class Response {
public:
enum ResponseType: int
{
Answer = 01,
Error = 02,
Request = 03
};
};
static int __fastcall hkWriteResponse(void *typ, char* command);
typedef int (__fastcall *tWriteResponse)(void *typ, char* command);
static tWriteResponse mWriteResponse;
static char* MyResponse = "Unknown command ;<";
static int TypeResp = 01;
void LoadConsole();
//bool hkCallResp(char* arg01, int arg02);
void ParseCommand(char* pCommand);
void ChangeResponse(char* pResponse, Response::ResponseType resp);
void WriteResponse(char* pResponse, Response::ResponseType resp);
void Activate();
static DWORD hkCall = 0x00BE33B0;
static DWORD tmpResp = 0;
static DWORD eaxadd = 0;
static DWORD ebpadd = 0;
static DWORD addr = 0x00BE2D90;
static DWORD RD_COM_Back = 0x00BE25BC;
static DWORD ResponseConsole = 0;
static DWORD typeMsg = 0;
static DWORD RW_RES_Back = 0x00BE2ED3;
static bool infsp = false;