#Thank you nTL3fTy, converting the password encryption to rc5 did the trick. It's now reading the pass correctly.
Now my goal is to successfully get into the game.
Upon logging in my client crashed, thats due to packets being off right?
It might be crashing because your game server cipher is wrong. It crashes when the length of the packet in offset 0 + 8 is smaller than the size of the packet; so if your cipher is wrong, it'll try reading in a wrong number as the packet length. Breakpoint it and see if the first packet comes in alright and such.
It might be crashing because your game server cipher is wrong. It crashes when the length of the packet in offset 0 + 8 is smaller than the size of the packet; so if your cipher is wrong, it'll try reading in a wrong number as the packet length. Breakpoint it and see if the first packet comes in alright and such.
I keep getting a console message of "Unknown Login packet type: 1052"..
I keep getting a console message of "Unknown Login packet type: 1052"..
If that's the account server, it doesn't matter at all. It's just an old packet that sends the version of conquer in binary (1.0 or 2.0). It does matter in the game server though.
Take a look at what I got so far and tell me what could be going wrong.
And tell me if I have the right idea.
1. -> Server receives an authentication packet
[Modified LoginServer.cs]
Code:
public override void OnPacketReceive(IClientWrapper client, byte[] buffer)
{
try
{
if (buffer.Length < 4)
return;
var Hero = client as Player;
if (Hero == null) return;
lock (Hero.Cryptographer)
{
Hero.Cryptographer.Decrypt(buffer, buffer.Length);
}
Console.WriteLine(BitConverter.ToUInt16(buffer, 2));
switch (BitConverter.ToUInt16(buffer, 2))
{
case 1051://auth request
case 1060:
case 1086:
Hero.Username = Encoding.ASCII.GetString(Kernel.ReadByteArray(buffer, 4, 16)).TrimEnd('\0');
Hero.Password = "";
byte[] pw = new byte[16];
Buffer.BlockCopy(buffer, 20, pw, 0, 16);
RC5 Crypto = new RC5(new Byte[] { 0x3C, 0xDC, 0xFE, 0xE8, 0xC4, 0x54, 0xD6, 0x7E, 0x16, 0xA6, 0xF8, 0x1A, 0xE8, 0xD0, 0x38, 0xBE }); // mm wait, first data is key what';s the key? O_Ocheck it out in other server
pw = Crypto.Decrypt(pw);
Hero.Password = Encoding.ASCII.GetString(pw).Trim('\0');
Console.WriteLine("user: " + Hero.Username + ", pass: " + Hero.Password);
MySqlHandler.MySqlCommand cmd = new MySqlHandler.MySqlCommand(MySqlHandler.MySqlCommandType.SELECT);
cmd.Select("accounts").Where("username", Hero.Username);
MySqlReader reader = new MySqlReader(cmd);
if (reader.Read())
{
Hero.UID = reader.ReadUInt32("UID");
Console.WriteLine(reader.ReadUInt32("UID"));
}
var account = ServerDatabase.Context.Accounts.GetByName(Hero.Username);
if (account != null)
{
if (account.Permission == PlayerPermission.Banned)
{
Console.WriteLine("Failed connection with credentials: " + account.Username + "," + account.Password + ", Reason: Banned.");
Hero.Send(AuthResponsePacket.AuthResponse(22));
Hero.Disconnect();
return;
}
else if (Game.Kernel.Clients.ContainsKey(account.UID))
{
Game.Kernel.Clients[account.UID].Disconnect(false);
Hero.Send(AuthResponsePacket.AuthResponse(22));
return;
}
else if (Hero.Password == account.Password && account.Permission > PlayerPermission.Error)
{
if (client.Client.RemoteEndPoint.ToString().Split(':')[0] != "127.0.0.1")
{
Console.WriteLine(Hero.UID + Hero.Username + Hero.Password + " is attempting to connect to host IP: " + GameIP.ToString().Split(':')[0]);
Console.WriteLine(GameIP + Hero.UID + "255" + "5816");
Hero.Send(AuthResponsePacket.AuthResponse(GameIP, Hero.UID, 255, 5816));
}
}
else
{
Console.WriteLine("Failed connection with credentials: " + account.Username + "," + account.Password + ", Reason: Invalid Account.");
Hero.Send(AuthResponsePacket.AuthResponse(1));
Hero.Disconnect();
return;
}
}
break;
default:
Console.WriteLine(Kernel.ProgramTitle + " Unknown Login packet type: " + BitConverter.ToUInt16(buffer, 2));
break;
}
}
catch { }
}
2. -> Client requests an authentication response from the server with the information sent in "(user/pass/UID)"
[Modified AuthResponse.cs]
Code:
public unsafe struct AuthResponsePacket
{
public static byte[] AuthResponse(string ServerIP, uint Key1, uint Key2, ushort Port)
{
byte[] Packet = new byte[33];
WriteUshort(32, Packet, 0);
WriteUshort(1055, Packet, 2);
WriteUInt(Key2, Packet, 4);
WriteUInt(Key1, Packet, 8);
WriteString(ServerIP, Packet, 12);
WriteUshort(Port, Packet, 28);
Console.WriteLine("Returning AuthResponse Packet: why is it failing at packet return?");
return Packet;
}
}
3. -> Server handles login request packet?
[Modified PacketHandler.cs]
Code:
case 1052://login request
{
Console.WriteLine("Working");
user.UID = BitConverter.ToUInt32(packet, 8);
uint Key2 = BitConverter.ToUInt32(packet, 4);
if (Kernel.Clients.ContainsKey(user.UID)) { Kernel.Clients[user.UID].Disconnect(true); user.Client.Disconnect(false); return; }
if (user.UID == 0 || user.Permission == PlayerPermission.Banned)
{
user.Disconnect(false);
return;
}
break;
}
//Still Working on this, But I can't even get to this part..
Lol that is what I've got so far, I'm really trying hard guys. Need some more guidance, My clients crashing upon login. Did some breakpoints and it's crashing on the Packet return. Look at the code below.
Code:
Hero.Send(AuthResponsePacket.AuthResponse(GameIP, Hero.UID, 255, 5816));
//This is the function that triggers the coding below.
public static byte[] AuthResponse(string ServerIP, uint Key1, uint Key2, ushort Port)
{
byte[] Packet = new byte[33];
WriteUshort(32, Packet, 0);
WriteUshort(1055, Packet, 2);
WriteUInt(Key2, Packet, 4);
WriteUInt(Key1, Packet, 8);
WriteString(ServerIP, Packet, 12);
WriteUshort(Port, Packet, 28);
Console.WriteLine("Returning AuthResponse Packet");
return Packet;//It's crashing right here..
}
[CO2_CORE_DLL] Updated CAST5 S-Boxes for 569X+ 03/07/2013 - CO2 PServer Guides & Releases - 10 Replies First of all, I want to thanks Angelius for the new CAST5 keys. The following S-Boxes code must replace the old one in the CO2_CORE_DLL to work on the lastest patch. Plus, you'll have to change the key used to generate the CAST5 key.
The new key seed is : C238xs65pjy7HU9Q
The new S-Boxes are :
private readonly UInt32 SBoxes = new UInt32 {
new UInt32
{ 0x5C8165BF, 0x30FB40D4, 0x9FA0FF0B, 0x6BECCD2F, 0x3F258C7A, 0x1E213F2F, 0x9C004DD3, 0x6003E540,
...
CAST-128 (CAST5) Cipher Feedback 04/07/2012 - CO2 PServer Guides & Releases - 10 Replies Similar to my other work in ciphers, here a CAST-128 cipher for the game encryption. It uses the Cipher Feedback (CFB64) method like the OpenSSL implementation used by TQ in CO2. My implementation uses pointers, so it can be considered as unsafe.
I decided to release it independently of the CO2_CORE_DLL project. As it is part of the library, you must add the Kernel file.
PS. I updated the CO2_CORE_DLL too, with a revised Blowfish cipher.
// *...
Cast128/cast5 encryption 09/20/2011 - CO2 Programming - 3 Replies Maybe some1 can explain how it works ? bcouse wih my cast5 cipher i can decrypt serverdh packet but can decrypt client dh packet.
public byte Decrypt(byte buffer) {
//System.out.println(Arrays.toString(Security.ge tProviders()));
cii = Cipher.getInstance("CAST5/CFB64/NoPadding&quo t;, "BC");
byte buff = buffer.clone();
ivs = new IvParameterSpec(" ".getBytes());
byte b = cryptkey.getBytes("ASCII");
key = new SecretKeySpec(b, "CAST5");
cii.init(Cipher.DECRYPT_MODE, key,ivs);
downgrading gg 04/03/2008 - Dekaron - 0 Replies i've managed to downgrade gg to 1059 and can use uce with no bans, currently working on getting old client to work if anyone wants to help pm me