Exemple #1
0
 internal void SendPacket(ClientPacket packet)
 {
     byte[] packetData = packetParser.CreateByteData(packet);
     Logger.LogDebug("Sent: " + packet.PacketHeader, packetData);
     if (Encryption == true)
     {
         packetData = TinyEncryptionAlgorithm.Encrypt(packetData, XTeaEncryptKey);
     }
     tcpClient.Send(packetData);
 }
 private void DecryptNewData()
 {
     if (Encryption == false)
     {
         //logger.Log("Received: ", newData.Peek(newData.Count));
         decryptedData.Enqueue(newData.Dequeue(newData.Count));
     }
     else if (Encryption == true && newData.Count >= 8)
     {
         int bytesToDecrypt = newData.Count >> 3;
         bytesToDecrypt = bytesToDecrypt << 3;
         byte[] decrypted = TinyEncryptionAlgorithm.Decrypt(newData.Dequeue(bytesToDecrypt), XTeaDecryptKey);
         Logger.LogDebug("Received raw: ", decrypted);
         decryptedData.Enqueue(decrypted);
     }
 }
Exemple #3
0
        private void Received_PhaseLogin(VirtualClient virtualClient)
        {
            if (virtualClient.LoginInformation.LoginKey.HasValue == false)
            {
                throw new Exception("No Login Key available");
            }
            virtualClient.Encryption = true;
            CLogin2Packet packet = new CLogin2Packet
            {
                Username = virtualClient.LoginInformation.Username,
                LoginKey = virtualClient.LoginInformation.LoginKey.Value
            };

            Array.Copy(virtualClient.ClientKey, packet.ClientKey, 4);
            virtualClient.SendPacket(packet);

            byte[] encryptKey = new byte[16];
            Buffer.BlockCopy(virtualClient.ClientKey, 0, encryptKey, 0, 16);
            byte[] key        = CryptoUtils.GetKey_20050304Myevan();
            byte[] decryptKey = TinyEncryptionAlgorithm.Encrypt(encryptKey, key);
            virtualClient.SetXteaKey(encryptKey, decryptKey);
        }