|
You last visited: Today at 17:53
Advertisement
Question
Discussion on Question within the CO2 Private Server forum part of the Conquer Online 2 category.
05/22/2010, 15:57
|
#1
|
elite*gold: 0
Join Date: Dec 2006
Posts: 684
Received Thanks: 238
|
Question
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?
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;
}*/
Obviously I will need to edit there encrypt thing I think, but I have no idea how.
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);
}
Any ideas?
|
|
|
05/22/2010, 18:03
|
#2
|
elite*gold: 0
Join Date: Oct 2009
Posts: 128
Received Thanks: 50
|
I added comments, if you still don't understand, look at my 2nd post.
Quote:
Originally Posted by scottdavey
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) denotes that an unsigned short (the length of the packet: 32) is being written to the array at the index 0. WriteUInt16(32, Packet, 0); takes its place.
*((ushort*)(p + 2)) = (ushort)PacketType; // *((ushort*)(p + 2)) means that another unsigned short (the packet type: 1055 or 0x41f) is being written to the array at index 2. WriteUInt16(1055, Packet, 2); takes its place.
*(p + 4) = key2[3]; // key2 - is being written at index 4. The byte order of Conquer packets is Little Endian.
*(p + 5) = key2[2]; // key2 - has 4 bytes, therefore it is a 32 bit integer since 1 byte has 8 bits, but key2 and key1 are contained in byte arrays in this source. Others might just use 32 bit integers.
*(p + 6) = key2[1]; // key2 - notice that there is no presence of a data type (ex: (ushort*)), this means that a single byte is being written.
*(p + 7) = key2[0]; // key2 - "+ 7" denotes the offset that this element is being written to in the array.
*(p + 8) = key1[3]; // key1 is written just like key2.
*(p + 9) = key1[2]; // WriteUInt32(Key2, Packet, 4); and WriteUInt32(Key1, Packet, 8); would takes its places, but these are byte arrays, and not integers.
*(p + 10) = key1[1];
*(p + 11) = key1[0];
for (int i = 0; i < ip.Length; i++) // ip is a string, and this loop is converting each character in the string to a byte, and writing that byte to the packet array at index 12 + i for each character in the string. WriteString(ServerIP, Packet, 12); takes its place.
{
*(p + 12 + i) = Convert.ToByte(ip[i]);
}
*(p + 28) = 0xb8; // The port is hardcoded into this source at index 28 and 29. The port is a 16 bit unsigned integer (ushort), and there are 8 bits to a byte, therefore it takes 2 bytes to write the port to the array.
*(p + 29) = 0x16; // WriteUInt16(Port, Packet, 28); takes its place, but it could have also been written as *((ushort*)(p + 28)) = 5816 or 0x16b8;
}
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;
}*/
|
Quote:
Originally Posted by scottdavey
Obviously I will need to edit there encrypt thing I think.
|
Why?
|
|
|
05/22/2010, 18:13
|
#3
|
elite*gold: 0
Join Date: Oct 2009
Posts: 128
Received Thanks: 50
|
If you see:
*(p + SOME_OFFSET) = SOME_BYTE;
Then use:
Packet[SOME_OFFSET] = SOME_BYTE;
If you see:
*((ushort*) (p + SOME_OFFSET)) = (ushort) SOME_USHORT;
The use:
WriteUInt16(SOME_USHORT, Packet, SOME_OFFSET);
If you see:
*((uint*) (p + SOME_OFFSET)) = (uint) SOME_UINT;
The use:
WriteUInt32(SOME_UINT, Packet, SOME_OFFSET);
If you see:
for (int i = 0; i < SOME_STRING.Length; i++)
{
*(p + SOME_OFFSET+ i) = Convert.ToByte(SOME_STRING[i]);
}
Then use:
WriteString(SOME_STRING, Packet, SOME_OFFSET);
If you see:
*(p + SOME_OFFSET) = SOME_STRING.Length;
for (int i = 0; i < SOME_STRING.Length; i++)
{
*(p + SOME_OFFSET + 1 + i) = Convert.ToByte(SOME_STRING[i]);
}
Then use:
WriteStringWithLength(SOME_STRING, Packet, SOME_OFFSET);
|
|
|
05/22/2010, 18:20
|
#4
|
elite*gold: 0
Join Date: Dec 2006
Posts: 684
Received Thanks: 238
|
No idea lol, was just an assumption.
Thanks, I'll check it out man!
EDIT:
Code:
byte[] Pack = MyPackets.AuthResponseEx(ServerIP, BitConverter.ToUInt16(Key1, 2), BitConverter.ToUInt16(Key2, 2), AuthServer.Port);
TheClient.Crypto.Encrypt(ref Pack);
Sock.Send(Pack);
Stuck at logging into server with this >.<.
|
|
|
Similar Threads
|
[QUESTION]How do i bypass Xtrap for any private server?[QUESTION]
10/12/2009 - Cabal Online - 3 Replies
Exactly what the title says.
I keep on getting an xTrap error when i try and load ANY private server that uses XTrap and it's driving me absolutely insane.
I cant figure out why it's showing me the error. If anyone has any bypasser for Helix / PaRaDoX
or any other server u know that has xTrap can u either PM me the bypass or post it here pls......this is driving me nuts
Bump.
|
[QUESTION]How do i bypass Xtrap for any private server?[QUESTION]
10/02/2009 - Cabal Private Server - 2 Replies
Exactly what the title says.
I keep on getting an xTrap error when i try and load ANY private server that uses XTrap and it's driving me absolutely insane.
I cant figure out why it's showing me the error. If anyone has any bypasser for Helix / PaRaDoX
or any other server u know that has xTrap can u either PM me the bypass or post it here pls......this is driving me nuts
|
All times are GMT +2. The time now is 17:53.
|
|