Problem with proxy

09/01/2012 15:30 tanelipe#1
It's been long time since I've last worked on a proxy for Conquer (1.5 years or so) however I managed to get it to a rather nice start.

I'm facing a problem now though, for some reason the TQ server / client doesn't seem to like when I change the public key within those two packets.

Below is the code that handles the calls to the DHKeyExchange. When those exchange calls are commented the client is able to login, however the data is encrypted.

PHP Code:
public void HandleHandshake(byte[] Packet)
        {
            
// exchange.HandleServerKeyPacket(Packet);
            
Send(PacketDataDirection.Client);
        }
        public 
void HandleHandshakeReply(byte[] Packet)
        {
            
// exchange.HandleClientKeyPacket(Packet);
            
Send(PacketDataDirection.Server);
            
//exchange.UpdateEncryptionKeys(clientCipher, serverCipher);  
        

and here's the Send/Decrypt

PHP Code:
public void Send(byte[] PacketDataDirection Direction)
        {
            if (
Direction == DataDirection.Client)
            {
                
localSocket.Send(clientCipher.Encrypt(Packet));
            }
            else
            {
                
remoteSocket.Send(serverCipher.Encrypt(Packet));
            }
        }

        public 
void Decrypt(byte[] PacketDataDirection Direction)
        {
            if (
Direction == DataDirection.Client)
            {
                
byte[] Decrypted clientCipher.Decrypt(Packet);
                
Buffer.BlockCopy(Decrypted0Packet0Decrypted.Length);
            }
            else
            {
                
byte[] Decrypted serverCipher.Decrypt(Packet);
                
Buffer.BlockCopy(Decrypted0Packet0Decrypted.Length);
            }
        } 
I've attached the cryptography files incase there's something wrong with them. Any help is greatly appreciated.

EDIT: It should be noted that I can actually decrypt the server and client packets properly. The problem could be also when encrypting the data for re-send (client -> server perhaps? since the client answers with the reply I can assume that the server->client portion should be fine)