Hey i see that ur guys know more that i and i know that u can help me, so plz help. I cant figure out why i cant decrypt authresponse.
Code:
//[C++]
class AuthProtocolCryptographer
{
public:
class CryptCounter
{
private:
unsigned short m_Counter;
public:
unsigned char getKey2()
{
return static_cast<unsigned char>(m_Counter >> 8);
}
unsigned char getKey1()
{
return static_cast<unsigned char>(m_Counter & 0xFF);
}
void Increment()
{
m_Counter+=1;
}
};
private:
CryptCounter *_decryptCounter;
CryptCounter *_encryptCounter;
unsigned char *_cryptKey1;
unsigned char *_cryptKey2;
public:
AuthProtocolCryptographer()
{
_decryptCounter = new CryptCounter();
_encryptCounter = new CryptCounter();
_cryptKey1 = new unsigned char[256];
_cryptKey2 = new unsigned char[256];
unsigned char i_key1 = 0x9D;
unsigned char i_key2 = 0x62;
for (int i = 0; i <= 0x100; i++)
{
_cryptKey1[i] = i_key1;
_cryptKey2[i] = i_key2;
i_key1 = static_cast<unsigned char>((0xF + static_cast<unsigned char>(i_key1 * 0XFA)) * i_key1 + 0X13);
i_key2 = static_cast<unsigned char>((0x79 - static_cast<unsigned char>(i_key2 * 0X5C)) * i_key2 + 0X6D);
}
}
void EncryptClientPackets(byte buffer[], int len)
{
for (int i = 0; i < len; i++)
{
buffer[i] = buffer[i] ^ static_cast<unsigned char>(_cryptKey1[_encryptCounter->getKey1()] ^ _cryptKey2[_encryptCounter->getKey2()]);
buffer[i] = static_cast<unsigned char>(buffer[i] >> 4 | buffer[i] << 4);
buffer[i] = buffer[i] ^ static_cast<unsigned char>(0xAB);
_encryptCounter->Increment();
}
}
void EncryptServerPackets(byte buffer[], int len)
{
for (int i = 0; i < len; i++)
{
buffer[i] = buffer[i] ^ static_cast<unsigned char>(0xAB);
buffer[i] = static_cast<unsigned char>(buffer[i] >> 4 | buffer[i] << 4);
buffer[i] = buffer[i] ^ static_cast<unsigned char>(_cryptKey2[_decryptCounter->getKey2()] ^ _cryptKey1[_decryptCounter->getKey1()]);
_encryptCounter->Increment();
}
}
void DecryptClientPackets(byte buffer[],int len)
{
for (int i = 0; i < len; i++)
{
buffer[i] = buffer[i] ^ static_cast<unsigned char>(0xAB);
buffer[i] = static_cast<unsigned char>(buffer[i] >> 4 | buffer[i] << 4);
buffer[i] = buffer[i] ^ static_cast<unsigned char>(_cryptKey2[_decryptCounter->getKey2()] ^ _cryptKey1[_decryptCounter->getKey1()]);
_decryptCounter->Increment();
}
}
void DecryptServertPackets(byte buffer[],int len)
{
for (int i = 0; i < len; i++)
{
buffer[i] = buffer[i] ^ static_cast<unsigned char>(_cryptKey1[_encryptCounter->getKey1()] ^ _cryptKey2[_encryptCounter->getKey2()]);
buffer[i] = static_cast<unsigned char>(buffer[i] >> 4 | buffer[i] << 4);
buffer[i] = buffer[i] ^ static_cast<unsigned char>(0xAB);
_decryptCounter->Increment();
}
}
};
Maybe somethig wrong with keys ? bcouse i can decryt seed packets, and authrequest packets but cant decrytp authresponse