Quote:
Originally Posted by cobr_h
Well, if there is an use for this WPE thing, it could be, knowing the negotiated key during the beginning of the game connection session, and now knowing that variation of whatever-crypting-algorythm, use some kind of script to pick um the packet with WPE, open it, change what is wanted, then pack it back and send thru. Heh, nothing I could wonder how to do as I don't even know how this WPe looks like. ;)
|
Encryption method... ;)
For getting to the packets before there encrypted...
[Only registered and activated users can see links. Click Here To Register...]
Code:
namespace Ant1_V3n0M
{
class Encryption
{
public byte[] MainKey;
uint[] Keys2 = { 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF0000, 0xFF000000 };
public void Decrypt(ref byte[] packet)
{
uint size = (uint)packet.Length;
Array.Resize(ref packet, packet.Length + 4);
uint i = 4;
uint Key = BitConverter.ToUInt32(MainKey, (BitConverter.ToInt32(packet, 0) & 0x3FFF) * 4);
BitConverter.GetBytes(BitConverter.ToInt32(packet, 0) ^ 0x7AB38CF1).CopyTo(packet, 0);
uint t = (size - 4) >> 2; //Shift right 2 = divide by 4
uint t1;
while (t > 0)
{
t1 = BitConverter.ToUInt32(packet, (int)i);
Key = Key ^ t1;
BitConverter.GetBytes(Key).CopyTo(packet, i);
t1 = t1 & 0x3FFF;
Key = BitConverter.ToUInt32(MainKey, (int)(t1 * 4));
i += 4;
t--;
}
t1 = Keys2[((size - 4) & 3)];
t1 = ~t1;
t1 = t1 & Key;
BitConverter.GetBytes(BitConverter.ToUInt32(packet, (int)i) ^ t1).CopyTo(packet, i);
Array.Resize(ref packet, (int)size);
}
public struct PacketInfo
{
public uint Key; //Encryption basekey
public uint Step; //Encryption Step
public uint Mul; //Encryption Multiplier
public PacketInfo(bool setup)
{
Key = 0x6EC03CB4;
Step = 0;
Mul = 1;
}
}
public void Encrypt(ref byte[] packet, ref PacketInfo PI)
{
uint size = (uint)packet.Length;
Array.Resize(ref packet, packet.Length + 4);
if (size < 0x0A)
return;
BitConverter.GetBytes(BitConverter.ToInt32(packet, 0) ^ PI.Key).CopyTo(packet, 0);
uint Key = (BitConverter.ToUInt32(packet, 0) & 0x3FFF) * (uint)PI.Mul;
Key = BitConverter.ToUInt32(MainKey, (int)(Key * 4));
uint t = (size - 8) >> 2; //Shift right 2 = divide by 4
uint t1;
uint i = 8;
while (t > 0)
{
t1 = BitConverter.ToUInt32(packet, (int)i);
t1 = t1 ^ Key;
BitConverter.GetBytes(t1).CopyTo(packet, i);
t1 = (t1 & 0x3FFF) * (uint)PI.Mul;
Key = BitConverter.ToUInt32(MainKey, (int)(t1 * 4));
i += 4;
t--;
}
t1 = Keys2[((size - 8) & 3)];
t1 = ~t1;
uint t2 = (t1 & Key) ^ BitConverter.ToUInt32(packet, (int)i);
BitConverter.GetBytes(t2).CopyTo(packet, i);
Array.Resize(ref packet, packet.Length - 4);
t1 = (Key & 0x3FFF) * (uint)PI.Mul;
t1 = t2 ^ BitConverter.ToUInt32(MainKey, (int)(t1 * 4));
BitConverter.GetBytes(t1).CopyTo(packet, 4);
PI.Step = ((PI.Step + 1) & 0x3FFF);
PI.Key = BitConverter.ToUInt32(MainKey, (int)((PI.Step * PI.Mul) * 4));
}
}
}