I'm working on a little prog. that decrypts the L2 packages.
The decryption algorithm is (I think) good, because the first packet seems to be decrypted successfully, the problem is probably in the key update, which is made after every packet.
You can see on this image that the decryption is good, and it doesn't screws up long strings (will be described below).
I noticed the error when I tried to decrypt Message packets.
You can see on this image, that every 9. byte is wrong if you split the packets into 16 byte parts, which is the key length (and the error is the same in each packet). On the image, the opcode is separated in the first line, and the others is the data splitted 8 byte/row.
I use this algorithm to decrypt packets (c#):
Code:
public void Decrypt(byte[] buf) { int temp = 0; for (int i = 0; i < buf.Length; i++) { int temp2 = buf[i]; buf[i] = ((byte)(temp2 ^ (this._key[i & 0x0F]) ^ temp)); temp = temp2; } long old = ((uint)this._key[8] & 0x000000ff) | (((uint)this._key[9] << 8) & 0x0000ff00) | (((uint)this._key[10] << 16) & 0x00ff0000) | (((uint)this._key[11] << 24) & 0xff000000); old += buf.Length; this._key[8] = (byte)(old & 0xff); this._key[9] = (byte)(old >> 8 & 0xff); this._key[10] = (byte)(old >> 16 & 0xff); this._key[11] = (byte)(old >> 24 & 0xff); }
I made this algorithm based on the L2J source (gameserver/Crypt.java and gameserver/network/GameCrypt.java) and the LineAge Utils ( it works on C4 and written in c#.
I try to decrypt Interlude packages, but the problem is the same on the locally installed L2J server and on an offmod server too.