Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
World Server Decryption
06-16-2009, 11:18 PM
Post: #1
World Server Decryption
If someone can understand what there happens and want to code something, feel free Wink.

bool GameClient::Decrypt(char *pData, uint16 nLength,std::string &output) {
std::string vector(pData+1,16);
TFDecrypt->Resynchronize((const byte *)vector.c_str());
std::string input(pData+17,nLength-17);
output.clear();
CryptoPP::StringSource(input, true, new CryptoPP::StreamTransformationFilter(*TFDecrypt, new CryptoPP::StringSink(output)));
//output now contains crc len time data
std::string crc32 = std::string(output.c_str(),sizeof(uint32));
uint16 length;
memcpy(&length,output.c_str()+sizeof(uint32),sizeof(uint16));

std::string computedcrc;
CryptoPP::CRC32 hash;
CryptoPP::StringSource(std::string(output.c_str()+sizeof(uint32),length+sizeof(uint32)+sizeof(uint16)),
true,new CryptoPP::HashFilter(hash,new
CryptoPP::StringSink(computedcrc)));

if (memcmp(crc32.c_str(),computedcrc.c_str(),sizeof(uint32)))
return false;

output = std::string(output.c_str()+sizeof(uint32)+sizeof(uint16)+sizeof(uint32),length);
return true;
}

void GameClient::Send(std::string &contents) {
server_sequence++;

if (server_sequence == 4096)
server_sequence=0;

OutgoingPacket packet(PlayerSetupState,client_sequence,server_sequence);
packet.FromString(contents);

std::string buffer = packet.ToString();
uint16 lenght = (uint16)buffer.size();
uint32 time = getTime();
std::string input = std::string((const char*)&lenght,sizeof(lenght))
+ std::string((const char*)&time,sizeof(time)) + buffer;
//len+time+data
std::string crc32;
std::string output;

CryptoPP::CRC32 hash;
CryptoPP::StringSource(input, true,new CryptoPP::HashFilter(hash,new CryptoPP::StringSink(crc32))); //output2 now has crc
output = crc32 + input; //add the rest onto the crc,output now contains crc len time data

byte vector[16];

for (uint32 i=0;i < sizeof(vector); i++)
{
vector[i] = rand()%255;
}

TFEncrypt->Resynchronize(vector);
input.clear();
CryptoPP::StringSource(output, true, new CryptoPP::StreamTransformationFilter(*TFEncrypt, new CryptoPP::StringSink(input))); // output now has encrypted shit
input = char(0x01) + std::string((const char*)vector,sizeof(vector))
+ input; // input has whole packet now

int clientlen=sizeof(_address);
sendto(*_sock, input.data(), (int)input.size(), 0, (struct sockaddr*)&_address,clientlen); }
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: