Jump to content
SubSpace Forum Network

Recommended Posts

Posted
When I send reliable packets to the server I don't get an ansver :/ This is my net log (Note: packets sent after encryption kicks in are logged _before_ they're encrypted):
Core   [  8] 0 0x1 0xd7 0xff 0xff 0xff 0x1 0 
Server [  6] 0 0x2 0x29 0 0 0 
Core   [107] 0 0x3 0x1 0 0 0 0x9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x75 0x73 0x65 0x72 0 0x74 0x20 0x69 0x6e 0 0 0 0x74 0x13 0x77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x24 0x48 0 0 0 0xf0 0 0 0 0 0 0 0x74 0x86 0 0 0 0xbc 0x1 0 0 0x2b 0x2 0 0 0x24 0x48 0 0 0 0 0 0 0 0 
Core   [ 14] 0 0x5 0x4e 0x71 0x45 0 0x2 0 0 0 0x1 0 0 0 
Server [ 10] 0 0x6 0x11 0x8b 0xde 0xfc 0x77 0x8c 0xff 0xdc 
Core   [107] 0 0x3 0x1 0 0 0 0x9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x75 0x73 0x65 0x72 0 0x74 0x20 0x69 0x6e 0 0 0 0x74 0x13 0x77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x24 0x48 0 0 0 0xf0 0 0 0 0 0 0 0x74 0x86 0 0 0 0xbc 0x1 0 0 0x2b 0x2 0 0 0x24 0x48 0 0 0 0 0 0 0 0 
Core   [107] 0 0x3 0x1 0 0 0 0x9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x75 0x73 0x65 0x72 0 0x74 0x20 0x69 0x6e 0 0 0 0x74 0x13 0x77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x24 0x48 0 0 0 0xf0 0 0 0 0 0 0 0x74 0x86 0 0 0 0xbc 0x1 0 0 0x2b 0x2 0 0 0x24 0x48 0 0 0 0 0 0 0 0 
Core   [107] 0 0x3 0x1 0 0 0 0x9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x75 0x73 0x65 0x72 0 0x74 0x20 0x69 0x6e 0 0 0 0x74 0x13 0x77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x24 0x48 0 0 0 0xf0 0 0 0 0 0 0 0x74 0x86 0 0 0 0xbc 0x1 0 0 0x2b 0x2 0 0 0x24 0x48 0 0 0 0 0 0 0 0

Posted

That's because your reliable ID should start at 0 and not 1. Reliable packets are handled in the order in which they are received and since reliable ID 0 has not been received, ID 1 cannot be processed. Instead of sending

 

0 0x3 0x1 0 0 0

 

as the header, send

 

0 0x3 0 0 0 0

 

for the first reliable packet header and you're set.

 

-Snrrrub

Posted
Thanks! Corrected. However - that didnt do the trick :/
Core   [  8] 0 0x1 0xd7 0xff 0xff 0xff 0x1 0 
Server [  6] 0 0x2 0x29 0 0 0 
Core   [107] 0 0x3 0 0 0 0 0x9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x75 0x73 0x65 0x72 0 0x74 0x20 0x69 0x6e 0 0 0 0x74 0x13 0x77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x24 0x48 0 0 0 0xf0 0 0 0 0 0 0 0x74 0x86 0 0 0 0xbc 0x1 0 0 0x2b 0x2 0 0 0x24 0x48 0 0 0 0 0 0 0 0 
Core   [ 14] 0 0x5 0xed 0x63 0x1 0 0x2 0 0 0 0x1 0 0 0 
Server [ 10] 0 0x6 0x11 0x8b 0xde 0xfc 0x77 0x8c 0xff 0xdc 
Core   [107] 0 0x3 0 0 0 0 0x9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x75 0x73 0x65 0x72 0 0x74 0x20 0x69 0x6e 0 0 0 0x74 0x13 0x77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x24 0x48 0 0 0 0xf0 0 0 0 0 0 0 0x74 0x86 0 0 0 0xbc 0x1 0 0 0x2b 0x2 0 0 0x24 0x48 0 0 0 0 0 0 0 0 
Core   [107] 0 0x3 0 0 0 0 0x9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x75 0x73 0x65 0x72 0 0x74 0x20 0x69 0x6e 0 0 0 0x74 0x13 0x77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x24 0x48 0 0 0 0xf0 0 0 0 0 0 0 0x74 0x86 0 0 0 0xbc 0x1 0 0 0x2b 0x2 0 0 0x24 0x48 0 0 0 0 0 0 0 0

Posted

Well the reliable packet structure looks right... so the server should send you an ACK at the least. Since you're not getting an ACK, I'm !@#$%^&*uming the encryption code is messed. You can find out for yourself by disabling the encryption (set the enc. key to 0 in connect packet) while you're testing/debugging (recommended). If the server replies when the encryption is off but not when it's on then you've probably found your problem.

 

-Snrrrub

Posted

Sweet! I tought encryption was required!

 

Hmm... And apparently it is... When I set the encryption key to 0 I dont get any more response from the server. :(

 

I attached my logs from when I try logging into 17th Parallel with encryption enabled.

 

I dont know if I have added some bugs when I imported your code.

//Conversion routine
void CSSConnection::WriteUint32to8(Uint32 data,Uint8 *target,int len){
   for(Uint32 cnt=0;cnt<sizeof(Uint32) && cnt<len;cnt++)
       target[cnt]=(Uint8)((data >> (cnt * 8)) & 0xFF);
}

//Encryption routines - by Snrrrup
void CSSConnection::InitEncryption(Uint32 key){
   Log("InitEncryption");

Sint32 temp = 0;
encCypherKey = key;

for(int cnt = 0; cnt < 520; cnt += 2) // Each "block" is 2 bytes and the keystream size is 520 bytes
{
 temp = (Uint32)((Uint64)((Uint64)key * (Uint64)0x834E0B5F) >> 48);
 temp += (temp >> 31);
 key = ((key % 0x1F31D) * 16807) - (temp * 2836) + 123;
 if((Sint32)key < 0)
	 key += 0x7FFFFFFF;
 *((Uint16 *)(encKeyStream + cnt)) = (Uint16)key;
}

encryptionEnabled=true;
}

void CSSConnection::Encrypt(char *data,int len){
   Log("Encrypt");
if(!encryptionEnabled)
 return;

int StartPos = 1;
Uint32 Encrypted = encCypherKey;

if(!data[0]) //If Byte at Offset 0 is 0x00
 StartPos++;

for(Uint32 Count = StartPos; Count < len; Count += 4)
{
 Encrypted ^= *(Uint32 *)(encKeyStream + (Count - StartPos)) ^ (Uint32)(data+Count);
 WriteUint32to8(Encrypted,(Uint8*)(data+Count),len-Count);
}
}

void CSSConnection::Decrypt(char *data,int len){
   Log("Decrypt");
if(!encryptionEnabled)
 return;

Uint32 Decrypted = encCypherKey;
int StartPos = 1;

if(!data[0]) //If Byte at Offset 0 is 0x00
 StartPos++;

for(Uint32 Count = StartPos; Count < len; Count += 4)
{
 Uint32 Encrypted = (Uint32)(data+Count);
 Decrypted ^= *(Uint32 *)(encKeyStream + (Count - StartPos)) ^ Encrypted;
 WriteUint32to8(Decrypted,(Uint8*)(data+Count),len-Count);
 Decrypted = Encrypted;
}
}

some_core.zip.logs

Guest
This topic is now closed to further replies.
×
×
  • Create New...