unityro icon indicating copy to clipboard operation
unityro copied to clipboard

Figure out how to use Packet obfuscation

Open Danil0v3s opened this issue 4 years ago • 3 comments

It seems like Packet obfuscation is only used by map server, for that we would need to enabled it on our side as soon as we connect to map server. Other than that, we would need to find out how to encrypt the packets.

So far I've got this:

var key = (((((ENCRYPTION_KEY_1 * ENCRYPTION_KEY_2) + ENCRYPTION_KEY_3) & 0xFFFFFFFF) * ENCRYPTION_KEY_2) + ENCRYPTION_KEY_3) & 0xFFFFFFFF;
cmd |= (ushort)(key << 16 & 0x7FFF);

Danil0v3s avatar Jan 08 '21 22:01 Danil0v3s

That's how it works. Basically, there's 3 keys, which get shuffles everytime a packet is sent (you might get to know logic in rA/herc code)

Cmd = PacketID. That is, only packet id gets encrypted and the encryption starts only from map-server.

Also, new clients don't have encryption enabled, and it's useless to implement badly implemented things that were added in official clients.

I would say focus on core features or implement custom asymmetric packet encryption logic

dastgirp avatar Jan 08 '21 22:01 dastgirp

🤔 thanks for the insights, we might leave it for later then.

Would you believe rA/herc would embrace a custom feature like this? Since the official clients don't have it. Or even that eventually there will emerge another fork of those emulators?

Danil0v3s avatar Jan 08 '21 22:01 Danil0v3s

You can create packet encryption as optional features and diff/plugin for rA/hercules.

Most likely it won't make into official repo in the current state of client, but diff files can exist to easily implement the changes.

dastgirp avatar Jan 08 '21 22:01 dastgirp