Can anyone help me convert lotf packet functions from pointers to the method Hybrid used in his source, there a lot better and easier to do.
Even I understand them, any ideas?
Obviously I will need to edit there encrypt thing I think, but I have no idea how.
Any ideas?
Even I understand them, any ideas?
Code:
public byte[] AuthResponse(string ip, byte[] key1, byte[] key2)
{
ushort PacketType = 0x41f;
byte[] Packet = new byte[32];
fixed (byte* p = Packet)
{
*((ushort*)p) = (ushort)Packet.Length;
*((ushort*)(p + 2)) = (ushort)PacketType;
*(p + 4) = key2[3];
*(p + 5) = key2[2];
*(p + 6) = key2[1];
*(p + 7) = key2[0];
*(p + 8) = key1[3];
*(p + 9) = key1[2];
*(p + 10) = key1[1];
*(p + 11) = key1[0];
for (int i = 0; i < ip.Length; i++)
{
*(p + 12 + i) = Convert.ToByte(ip[i]);
}
*(p + 28) = 0xb8;
*(p + 29) = 0x16;
}
return Packet;
}
/*public static byte[] AuthResponseEx(string ServerIP, uint Key1, uint Key2, ushort Port)
{
byte[] Packet = new byte[33];
WriteUInt16(32, Packet, 0);
WriteUInt16(1055, Packet, 2);
WriteUInt32(Key2, Packet, 4);
WriteUInt32(Key1, Packet, 8);
WriteString(ServerIP, Packet, 12);
WriteUInt16(Port, Packet, 28);
return Packet;
}*/
Code:
public void Encrypt(ref byte[] Data)
{
try
{
//Monitor.Enter(this);
for (int b = 0; b < Data.Length; b++)
{
Data[b] = (byte)(Data[b] ^ 0xab);
Data[b] = (byte)(Data[b] << 4 | Data[b] >> 4);
Data[b] = (byte)(m_Key2[m_OutCounter >> 8] ^ Data[b]);
Data[b] = (byte)(m_Key1[m_OutCounter & 0x00ff] ^ Data[b]);
m_OutCounter++;
}
//General.WriteLine("OutCounter = " + m_OutCounter);
//Monitor.Exit(this);
}
catch (Exception e)
{
General.WriteLine(e.ToString());
}
}
public void Decrypt(ref byte[] Data)
{
try
{
byte[] Key1;
byte[] Key2;
if (m_UseAlt)
{
Key1 = m_Key3;
Key2 = m_Key4;
}
else
{
Key1 = m_Key1;
Key2 = m_Key2;
}
//Monitor.Enter(this);
for (int b = 0; b < Data.Length; b++)
{
Data[b] = (byte)(Data[b] ^ 0xab);
Data[b] = (byte)(Data[b] << 4 | Data[b] >> 4);
Data[b] = (byte)(Key2[m_InCounter >> 8] ^ Data[b]);
Data[b] = (byte)(Key1[(m_InCounter & 0x00ff)] ^ Data[b]);
m_InCounter++;
}
//Monitor.Exit(this);
}
catch (Exception e)
{
General.WriteLine(e.ToString());
}
}
Code:
try
{
byte[] Pack = MyPackets.AuthResponse(ServerIP, Key1, Key2);
TheClient.Crypto.Encrypt(ref Pack);
Sock.Send(Pack);
}