anyways, someone told me to use this code..
i've tried to edit it a little.
and tried to compile it.. but got errors..
i hope you can help me fix it.. thanks..
Code:
#include <Winsock2.h>
#include <Windows.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#pragma comment(lib, "ws2_32.lib")
using namespace std;
FILE* pSendLogFile;
FILE* pRecvLogFile;
typedef int (WINAPI* r_send)(SOCKET sock, char* buf, int len, int flags);
r_send osend;
typedef int (WINAPI* r_recv)(SOCKET sock, char* buf, int len, int flags);
r_recv orecv;
int WINAPI custom_send (SOCKET sock, char* buf, int len, int flags);
int WINAPI custom_recv (SOCKET sock, char* buf, int len, int flags);
void InitDebugConsole();
void *DetourFunc(BYTE *src, const BYTE *dst, const int len);
bool RetourFunc(BYTE *src, BYTE *restore, const int len);
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask);
DWORD dwFindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask);
void DumpIt(char v,int size,char* buf);
char score[18];
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
osend = (r_send) GetProcAddress(GetModuleHandle("ws2_32.dll"), "send"); //gets original address for send
orecv = (r_recv) GetProcAddress(GetModuleHandle("ws2_32.dll"), "recv"); //for recv same as above
//DWORD dwSendOriAddr = GetProcAddress(GetModuleHandle("ws2_32.dll"), "send"); //gets original address for send
//DWORD dwRecvOriAddr = GetProcAddress(GetModuleHandle("ws2_32.dll"), "recv"); //for recv same as above
printf("[In Application] Ori Send Address = %x\n", osend);
printf("[In Application] Ori Recv Address = %x\n", orecv);
osend = (r_send) DetourFunc((BYTE*)osend, (BYTE*)&custom_send, 5);
orecv = (r_recv) DetourFunc((BYTE*)orecv, (BYTE*)&custom_recv, 5);
printf("[This DLL] Ori Send Address = %x\n", osend);
printf("[This DLL] Ori Recv Address = %x\n", orecv);
printf("The score should look like this 73%%2E0440539 (%%2E = dot) accuracy after the dot)\n");
printf("Lowest score is 0%%2E000\n");
printf("Type score you want to get : ");
cin.getline (score,18);
printf("loaded score to be = %s\n", score);
}
else if (reason == DLL_PROCESS_DETACH)
{
}
return true;
}
void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwback;
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
memcpy(jmp, src, len); jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0xE9;
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
VirtualProtect(src, len, dwback, &dwback);
return (jmp-len);
}
bool RetourFunc(BYTE *src, BYTE *restore, const int len)
{
DWORD dwback;
if(!VirtualProtect(src, len, PAGE_READWRITE, &dwback)) { return false; }
if(!memcpy(src, restore, len)) { return false; }
restore[0] = 0xE9;
*(DWORD*)(restore+1) = (DWORD)(src - restore) - 5;
if(!VirtualProtect(src, len, dwback, &dwback)) { return false; }
return true;
}
bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
{
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask )
return false;
return (*szMask) == NULL;
}
DWORD dwFindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
{
for(DWORD i=0; i < dwLen; i++)
if( bCompare( (BYTE*)( dwAddress+i ),bMask,szMask) )
return (DWORD)(dwAddress+i);
return 0;
}
int WINAPI custom_send(SOCKET sock, char* buf, int len, int flags)
{
//struct sockaddr_in socketClient = (struct sockaddr_in*)sock;
//printf("ip = %s\n", inet_ntoa(socketClient.sin_addr));
//DumpIt('S',len,buf);
char* pch;
char makeOne[10000];
char endString[5000]; //500 bytes max for now?
pch = strstr(buf,"score=");
if(pch != NULL) { //found match
pch = strstr(buf, "&"); //<-score finish
if(pch != NULL) {
int size = pch-buf;
memcpy(endString,buf+size, len-size);
endString[len-size] = '\0';
sprintf(makeOne, "%s%s%s%s","score=", score,"%2D1195345", endString);
size = strlen(makeOne);
char* sendPacket = new char[size];
memcpy(sendPacket, makeOne, size);
DumpIt('S',size, makeOne);
return osend(sock, sendPacket, size, flags);
}
}
//pSendLogFile = fopen("C:\\sndlog.txt", "a+");
//fprintf(pSendLogFile, "\n", buf);
//fclose(pSendLogFile);
return osend(sock, buf, len, flags);
}
int WINAPI custom_recv(SOCKET sock, char* buf, int len, int flags)
{
//pRecvLogFile = fopen("C:\\rcvlog.txt", "a+");
//fprintf(pRecvLogFile, "\n", buf);
//fclose(pRecvLogFile);
return orecv(sock, buf, len, flags);
}
void DumpIt(char v,int size,char* buf)
{
printf("\n\n");
if (v == 'S')
printf("SEND PACKET");
else
printf("RECV PACKET");
printf(" SIZE: %3d \n ",size);
int col=14;
int pc=0;
int lasti=0;
bool notfull=true;
for (int i=0;i<size;i++)
{
printf("%02x ",BYTE(buf[i]));
if (pc++>col)
{
//PRINT the text to it XD
printf(" ");
for (int x=lasti;x<=i;x++)
{
if (BYTE(buf[x]) >= 33)
printf("%c",char(buf[x]));
else
printf(".");
}
printf("\n ");
pc=0;
lasti=i+1;
notfull=false;
} else
notfull=true;
}
if (notfull)
{
while(1)
{
//FINISH LAST ROW !
printf(" "); //no hex here
if (pc++>col)
{
//PRINT the text to it XD
printf(" ");
for (int x=lasti;x<=i;x++)
{
if (x <size)
if (BYTE(buf[x]) >= 33)
printf("%c",char(buf[x]));
else
printf(".");
else
printf(" ");
}
printf("\n ");
pc=0;
lasti=i+1;
notfull=false;
break;
}
}
}
printf("\n");
}
Errors:
Code:
1>------ Build started: Project: injection, Configuration: Debug Win32 ------ 1>Compiling... 1>injection.cpp 1>c:\documents and settings\silencio\my documents\khanhookc++\injection\injection\injection.cpp(41) : error C2664: 'GetModuleHandleW' : cannot convert parameter 1 from 'const char [11]' to 'LPCWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\documents and settings\silencio\my documents\khanhookc++\injection\injection\injection.cpp(42) : error C2664: 'GetModuleHandleW' : cannot convert parameter 1 from 'const char [11]' to 'LPCWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\documents and settings\silencio\my documents\khanhookc++\injection\injection\injection.cpp(203) : error C2065: 'i' : undeclared identifier 1>c:\documents and settings\silencio\my documents\khanhookc++\injection\injection\injection.cpp(215) : error C2065: 'i' : undeclared identifier 1>Build log was saved at "file://c:\Documents and Settings\silencio\My Documents\KhanhookC++\injection\injection\Debug\BuildLog.htm" 1>injection - 4 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========






