Perhaps I didn't articulate this well sorry - This is the start of the DH handshake. The client disconnects the moment it receives the first DH Exchange packet after initially connecting to the Game server.Spirited wrote: Mon May 17, 2021 2:16 am So when decoding the message, Comet only skips in 7 bytes before it reads in the length. So perhaps you're skipping that? See here: https://gitlab.com/spirited/comet/-/blo ... ake.cs#L65
I copy pasted a sample from a revised 5165 COEmu source to ensure I wasn't doing something incorrectly. As far as I know nothing about the DH exchange changed between 5165 and 5187 -> even when performing the query with the packet structure below:
Code: Select all
var random = new System.Random();
int PAD_LEN = 11;
int _junk_len = 12;
string tqs = "TQServer";
MemoryStream ms = new MemoryStream();
byte[] pad = new byte[PAD_LEN];
random.NextBytes(pad);
byte[] junk = new byte[_junk_len];
random.NextBytes(junk);
int size = 47 + aPrimeRoot.Length + aGenerator.Length + key.Length + 12 + 8 + 8;
BinaryWriter bw = new BinaryWriter(ms);
bw.Write(pad);
bw.Write(size - PAD_LEN);
bw.Write((UInt32)_junk_len);
bw.Write(junk);
bw.Write((UInt32)encryptionIV.Length);
bw.Write(encryptionIV);
bw.Write((UInt32)decryptionIV.Length);
bw.Write(decryptionIV);
bw.Write((UInt32)aPrimeRoot.ToCharArray().Length);
foreach (char fP in aPrimeRoot.ToCharArray())
{
bw.BaseStream.WriteByte((byte)fP);
}
bw.Write((UInt32)aGenerator.ToCharArray().Length);
foreach (char fG in aGenerator.ToCharArray())
{
bw.BaseStream.WriteByte((byte)fG);
}
bw.Write((UInt32)key.ToCharArray().Length);
foreach (char SPK in key.ToCharArray())
{
bw.BaseStream.WriteByte((byte)SPK);
}
foreach (char tq in tqs.ToCharArray())
{
bw.BaseStream.WriteByte((byte)tq);
}
byte[] Packet = new byte[ms.Length];
Packet = ms.ToArray();
Console.WriteLine(PacketDump.Hex(Packet));
Buffer.BlockCopy(Packet, 0, mBuf, 0, (int)ms.Length); // Copy it to this current Msg in preparation of sending it to the server.
Console.WriteLine(PacketDump.Hex(mBuf));
I'm not really sure what could cause a conquer client to instantly disconnect from the game server other than a malformed packet? I'm thinking perhaps I need to step away from this for a few days and come back to it with a fresh pair of eyes.