I'm working on this unofficial launcher for an old multiplayer game that used to be hosted by Gamespy (which is dead now). And we're trying to get it playable again for old times sake. We're using the open source RetroSpyServer to get the server's listed again, but now we want to load-in that information into our launcher.
The encryption class that's used to encrypt the server response list is https://github.com/GameProgressive/RetroSpyServer/blob/master/GameSpyLib/Encryption/GOAEncryption.cs
More specifically the function I need help with is the GOAEncryptByteShift.
private byte GOAEncryptByteShift(byte b)
{
byte swaptemp;
State.ratchet = (byte)(State.ratchet + State.cards[State.rotor++]);
swaptemp = State.cards[State.last_cipher];
State.cards[State.last_cipher] = State.cards[State.ratchet];
State.cards[State.ratchet] = State.cards[State.last_plain];
State.cards[State.last_plain] = State.cards[State.rotor];
State.cards[State.rotor] = swaptemp;
State.avalanche = (byte)(State.avalanche + State.cards[swaptemp]);
State.last_cipher =
(byte)(b ^ State.cards[(State.cards[State.avalanche] + State.cards[State.rotor]) & 0xFF] ^
State.cards[State.cards[(State.cards[State.last_plain] +
State.cards[State.last_cipher] +
State.cards[State.ratchet]) & 0xFF]]);
State.last_plain = b;
return State.last_cipher;
}
It looks like it's an xor & and based encryption, and I have the secretKey, server & clientChallenge. But I can't seem to figure out how to reverse the byte-shift.
Any help would be highly appreciated!