Hello everybody,
I've hooked send and recv calls from a game.exe, here is my source:
As you may know, packets are encrypted, and I have its cryption and decryption method:
My question is, How can I implement this decryption method into my hook packets project to make it print in console packets decrypted?
It may not be that dificult but I really cannot sort it out, I hope someone can help.
Thank you in advance
I've hooked send and recv calls from a game.exe, here is my source:
Code
// General
#include <stdio.h>
#include <WinSock2.h>
#include <Windows.h>
#include <sstream>
#include <string>
#include <iomanip>
#include <xhacking/xHacking.h>
#include <xhacking/Utilities/Utilities.h>
#include <xhacking/Loader/Loader.h>
#include <xhacking/Detour/Detour.h>
using namespace xHacking;
Detour<int, SOCKET, char*, int, int>* recvDetour = NULL;
Detour<int, SOCKET, const char*, int, int>* sendDetour = NULL;
int WINAPI nuestro_recv(SOCKET s, char *buf, int len, int flags)
{
// LLAMAR ORIGINAL
int ret = (*recvDetour)(s, buf, len, flags);
__asm PUSHAD;
__asm PUSHFD;
std::ostringstream info;
// Server message
info << "**----------[[SERVIDOR]] >>>> CLIENTE]----------**\n\n- HEX:\n\n";
info << std::hex << std::uppercase;
for (int i = 0; i < ret; i++)
{
info << std::setw(2) << std::setfill('0') << (int)buf[i];
}
info << std::dec << std::nouppercase;
printf("%s\n\n", info.str().c_str());
printf("- Chars:\n\n");
printf("%s\n", buf);
printf("----------------------------------------------------\n\n\n");
__asm POPFD;
__asm POPAD;
return ret;
}
int WINAPI nuestro_send(SOCKET s, const char *buf, int len, int flags)
{
// CALL ORIGINAL
int ret = (*sendDetour)(s, buf, len, flags);
__asm PUSHAD;
__asm PUSHFD;
// Client message
std::ostringstream info;
info << "**----------[[CLIENTE]] >>>> SERVIDOR]----------**\n\n- HEX:\n\n";
info << std::hex << std::uppercase;
// si no funciona, cambiar ret por len
for (int i = 0; i < len; i++)
{
info << std::setw(2) << std::setfill('0') << (int)buf[i];
}
info << std::dec << std::nouppercase;
printf("%s\n\n", info.str().c_str());
printf("- Chars:\n\n");
printf("%s\n", buf);
printf("----------------------------------------------------\n\n\n");
__asm POPFD;
__asm POPAD;
return ret;
}
void Hooks()
{
recvDetour = new Detour<int, SOCKET, char*, int, int>();
recvDetour->Wait((char*)"ws2_32.dll", (char*)"recv", (BYTE*)nuestro_recv);
sendDetour = new Detour<int, SOCKET, const char*, int, int>();
sendDetour->Wait((char*)"ws2_32.dll", (char*)"send", (BYTE*)nuestro_send);
}
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, DWORD reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
// We are in the game
CreateConsole();
Hooks();
}
return true;
}As you may know, packets are encrypted, and I have its cryption and decryption method:
Code
bool Decryption(char * pData, const USHORT usDataLen, const u_char key )
{
// Get key string
char * cValKey ;
UINT * uiValKey ;
cValKey = "83kck3ks92 82drd";
uiValKey = (UINT*)cValKey ;
try {
int x, i,j,k,l ;
UINT * puiData = (UINT *) pData ; // 'int *' Convert to type data
j = 0 ; // line step
k = usDataLen / 16 ; // line count
l = usDataLen % 16 ; // char count
// line data block Encrypto
for( i = 0, x = 0, j = 0 ; i < k ; i++, x += 4, j += 16 ) { // Transpose Key and pData.
puiData[x+0] = uiValKey[0] ^ puiData[x+0] ;
puiData[x+1] = ~(uiValKey[2] ^ puiData[x+1]) ;
puiData[x+2] = uiValKey[1] ^ puiData[x+2] ;
puiData[x+3] = ~(uiValKey[3] ^ puiData[x+3]) ;
}
// char data Encrypto
//j += KEYVALLENTH ;
for(int h = 0 ; h < l ; h++ ) {
pData[j+h] = ~(cValKey[h] ^ pData[j+h]) ;
}
}// try
catch (...) {
return false ;
}
return true ;
}My question is, How can I implement this decryption method into my hook packets project to make it print in console packets decrypted?
It may not be that dificult but I really cannot sort it out, I hope someone can help.
Thank you in advance

