Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server > CO2 PServer Guides & Releases
You last visited: Today at 23:07

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Comet, Open Source Server (Multiple Patches)

Discussion on Comet, Open Source Server (Multiple Patches) within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old 04/22/2020, 08:10   #46
 
elite*gold: 80
Join Date: Sep 2007
Posts: 642
Received Thanks: 168
Cool, I don't know must about tasks and threading so think will be a decent way for me to learn. The database call for checking account credentials can now be made async, yea? Well really all db calls should be async but this will enable that a bit easier?
Santa is offline  
Old 04/22/2020, 08:59   #47
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by StarBucks View Post
Cool, I don't know must about tasks and threading so think will be a decent way for me to learn. The database call for checking account credentials can now be made async, yea? Well really all db calls should be async but this will enable that a bit easier?
I made all database calls async in my most recent commit about an hour ago. The credential check doesn't do any communication outside the service, so I kept that synchronous. I'm not too too familiar with async-await, but I'm fixing my mistakes where I see them. I fixed the merge request permissions on the repo as well (I just saw your comment, sorry that took so long).
Spirited is offline  
Old 04/23/2020, 09:03   #48
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
This is going to be my last modification with Comet for a while, besides basic branch maintenance. I improved character creation by randomizing character appearances and spawning new characters in Birth Village. Random numbers are being generated by a new service using the async-await pattern and a bound channel. That way, the server can generate random numbers reliably across multiple threads without locking. And with that, Chimera calls. Thanks for the feedback I've gotten, and I hope you all contribute to the project. Cheers.
Spirited is offline  
Thanks
1 User
Old 06/15/2020, 01:47   #49
 
elite*gold: 0
Join Date: Feb 2013
Posts: 42
Received Thanks: 3
thx for help bro
coder5017 is offline  
Old 03/29/2021, 03:43   #50
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
So great to see the title still hasn't been updated after months of reporting.

New article for Comet here:
Comet now supports multiple patches (you'd know that months ago though if you follow elsewhere).
Spirited is offline  
Thanks
2 Users
Old 04/05/2021, 21:55   #51
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
In honor of diversity month and International Transgender day, I updated the contribution guide for Comet to include more inclusive terminology. You can find all replacements . Throughout the week (really whenever I get time), I'll be updating the code to reflect these new requirements. Thanks, and remember to be kind to one another.
Spirited is offline  
Thanks
1 User
Old 04/15/2021, 21:27   #52
 
elite*gold: 0
Join Date: Jan 2013
Posts: 89
Received Thanks: 27
Quote:
Originally Posted by Spirited View Post
In honor of diversity month and International Transgender day, I updated the contribution guide for Comet to include more inclusive terminology. You can find all replacements . Throughout the week (really whenever I get time), I'll be updating the code to reflect these new requirements. Thanks, and remember to be kind to one another.
Thank you for releasing this source. Do you have any recommendations on a gameplan for building out more functionality? I guess I'm wondering in your shoes what would a roadmap look like of what you would implement to get this source to a state where players can login and play normally etc.. an MVP if you will.
thisismyaccountokay is offline  
Old 04/19/2021, 21:11   #53
 
elite*gold: 0
Join Date: Jan 2013
Posts: 89
Received Thanks: 27
Quote:
Originally Posted by Spirited View Post
I don't discuss anything on this board. Please go to my website for a link to appropriate discussion areas.
I understand, I actually frequent your board often. Your patch notes list is phenomenal. I'll make a thread over there shortly. Thanks!
thisismyaccountokay is offline  
Old 10/18/2022, 22:35   #54
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Some updates, first: this is an appropriate area to discuss this source. You can discuss it wherever I have it posted.

Second: Comet has been upgraded to .NET 6 / C# 10. Some asynchronous patterns have been updated, but should be easy to merge into existing projects. I also added docker support for those interested in trying that out. Main thread updated, main branch added, readmes updated... and a few other small improvements. Cheers.
Spirited is offline  
Thanks
1 User
Old 10/20/2022, 11:00   #55
 
elite*gold: 0
Join Date: Oct 2022
Posts: 36
Received Thanks: 2
Hello spirited, I hope asking a generic question about the login sequence is fine as this is a base for learning.

I tried to implement the DH Key Exchange and Blowfish by reading your code, but I've run into a curious issue I can't seem to figure out the past two days.

Code:
                // Decrypt traffic by first discarding the first 7 bytes, as per TQ Digital's
                // exchange protocol, then decrypting only what is necessary for the exchange.
                // This is to prevent the next packet from being decrypted with the wrong key.
                actor.Cipher.Decrypt(
                    actor.Buffer.Slice(0, 9).Span,
                    actor.Buffer.Slice(0, 9).Span);
It looks like you are not discarding anything here, instead decrypting just the first 8 bytes? Why? I've replicated your approach just in case, as my issue is related to the first 8 bytes of the next packet, but I'm getting the exact same result if I decrypt the entire buffer. You are saying 'This is to prevent the next packet from being decrypted with the wrong key.' which seems to be related to my issue, if you wouldn't re-create the gamecrypto after receiving the DH response with the new IVs - resetting the counters.

Code:
net.DiffieHellman.ComputePublicKeyAsync();
            Memory<byte> dhx = MsgDHX.Create(net.ServerIV, net.ClientIV, DiffieHellman.P, DiffieHellman.G, net.DiffieHellman.GetPublicKey());

            net.GameCrypto.Encrypt(dhx.Span, dhx.Span);
            player.NetSync(dhx);

            var count = reader.Read(net.RecvBuffer.Span);
            var packet = net.RecvBuffer[..count];
            net.GameCrypto.Decrypt(packet.Span, packet.Span);
            var pubkey = Encoding.ASCII.GetString(ParseResponse(packet));
            Console.WriteLine(GamePacketHandler.Dump(packet.ToArray()));
            Console.WriteLine($"Pubkey: {pubkey}");

            net.DiffieHellman.ComputePrivateKey(pubkey);
            net.GameCrypto.GenerateKeys(net.DiffieHellman.GetPrivateKey());
            net.GameCrypto.SetIVs(net.ClientIV, net.ServerIV);

            count = reader.Read(net.RecvBuffer.Span);
            packet = net.RecvBuffer[..count];
            net.GameCrypto.Decrypt(packet.Span, packet.Span);

            GamePacketHandler.Process(in player, packet);
This is my code, I've done it sequentially and synchronously to make it easier to understand whats happening as my problem is very hard to understand for me.

Code:
[LOGIN] Client connected: 192.168.0.10:58146
[LOGIN/1051] Account: asdasdasd, Pass: asdasdasd, Server: Light
[GAME] Client connected: 192.168.0.10:53050
[LOGIN/1052] Client Id: 499999, File: res.dat
54 39 40 E1 B9 8D B2 A6 00 00 00 12 00 00 00 3A             T9@............:
6F BF 1C 0A A3 BE 32 34 05 11 CF 7C ED D1 20 76             o.....24...|.. v
FF 80 00 00 00 42 39 39 35 45 33 30 35 39 38 41             .....B995E30598A
38 44 46 31 39 37 33 30 37 43 33 33 44 39 39 31             8DF197307C33D991
32 41 35 38 31 34 30 38 34 37 31 44 39 45 31 46             2A581408471D9E1F
31 35 30 31 37 46 43 30 41 30 39 43 43 38 45 39             15017FC0A09CC8E9
35 30 36 37 42 31 34 45 33 45 44 35 38 37 46 31             5067B14E3ED587F1
42 42 35 36 46 37 34 35 35 32 43 32 35 45 35 34             BB56F74552C25E54
36 36 39 45 46 42 44 35 31 46 34 38 33 41 42 44             669EFBD51F483ABD
38 32 35 31 44 35 32 35 35 36 39 37 43 46 37 30             8251D5255697CF70
42 35 31 42 35 54 51 43 6C 69 65 6E 74                      B51B5TQClient

Pubkey: B995E30598A8DF197307C33D9912A581408471D9E1F15017FC0A09CC8E95067B14E3ED587F1BB56F74552C25E54669EFBD51F483ABD8251D5255697CF70B51B5
[GAME] Unknown packet ID: 23953
FF 4F 91 5D E1 08 CD 26 02 00 00 00 7B 00 45 6E             .O.]...&....{.En
00 00 00 00 00 00 00 00 0A 00 00 00 54 51 43 6C             ............TQCl
69 65 6E 74                                                 ient
Game Server Packet 1052 is corrupted. The first couple bytes return garbage, but starting at offset 8, the data is valid. I even get the correct footer (TQClient)

Do you have any idea what's the cause?

Edit 4h later: I'm going to get bald tearing out my hair here jfc. I'd have used a lower client version but 5065 is the only one I could get to run on linux...
.Nostalgia is offline  
Old 10/20/2022, 18:28   #56
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by .Nostalgia View Post
Hello spirited, I hope asking a generic question about the login sequence is fine as this is a base for learning.

I tried to implement the DH Key Exchange and Blowfish by reading your code, but I've run into a curious issue I can't seem to figure out the past two days.

Code:
                // Decrypt traffic by first discarding the first 7 bytes, as per TQ Digital's
                // exchange protocol, then decrypting only what is necessary for the exchange.
                // This is to prevent the next packet from being decrypted with the wrong key.
                actor.Cipher.Decrypt(
                    actor.Buffer.Slice(0, 9).Span,
                    actor.Buffer.Slice(0, 9).Span);
It looks like you are not discarding anything here, instead decrypting just the first 8 bytes? Why? I've replicated your approach just in case, as my issue is related to the first 8 bytes of the next packet, but I'm getting the exact same result if I decrypt the entire buffer.
A slice in C# is different than other languages. It accepts a start index (0) and a length (9). So the code above decrypts 9 bytes. The line that follows is what ignores the first 7 bytes. The reason why we have to decrypt all bytes is so Blowfish's counters don't get desynchronized from the client's counters.

Quote:
Originally Posted by .Nostalgia View Post
You are saying 'This is to prevent the next packet from being decrypted with the wrong key.' which seems to be related to my issue, if you wouldn't re-create the gamecrypto after receiving the DH response with the new IVs - resetting the counters.
The reason why we get the length from offset 7 is because Blowfish's key is going to change after the DHKE. So we don't want to decrypt any packets that queue up after the DHKE response until the response has been processed. See the socket event for that: .

Quote:
Originally Posted by .Nostalgia View Post
Code:
net.DiffieHellman.ComputePublicKeyAsync();
            Memory<byte> dhx = MsgDHX.Create(net.ServerIV, net.ClientIV, DiffieHellman.P, DiffieHellman.G, net.DiffieHellman.GetPublicKey());

            net.GameCrypto.Encrypt(dhx.Span, dhx.Span);
            player.NetSync(dhx);

            var count = reader.Read(net.RecvBuffer.Span);
            var packet = net.RecvBuffer[..count];
            net.GameCrypto.Decrypt(packet.Span, packet.Span);
            var pubkey = Encoding.ASCII.GetString(ParseResponse(packet));
            Console.WriteLine(GamePacketHandler.Dump(packet.ToArray()));
            Console.WriteLine($"Pubkey: {pubkey}");

            net.DiffieHellman.ComputePrivateKey(pubkey);
            net.GameCrypto.GenerateKeys(net.DiffieHellman.GetPrivateKey());
            net.GameCrypto.SetIVs(net.ClientIV, net.ServerIV);

            count = reader.Read(net.RecvBuffer.Span);
            packet = net.RecvBuffer[..count];
            net.GameCrypto.Decrypt(packet.Span, packet.Span);

            GamePacketHandler.Process(in player, packet);
This is my code, I've done it sequentially and synchronously to make it easier to understand whats happening as my problem is very hard to understand for me.

Code:
[LOGIN] Client connected: 192.168.0.10:58146
[LOGIN/1051] Account: asdasdasd, Pass: asdasdasd, Server: Light
[GAME] Client connected: 192.168.0.10:53050
[LOGIN/1052] Client Id: 499999, File: res.dat
54 39 40 E1 B9 8D B2 A6 00 00 00 12 00 00 00 3A             T9@............:
6F BF 1C 0A A3 BE 32 34 05 11 CF 7C ED D1 20 76             o.....24...|.. v
FF 80 00 00 00 42 39 39 35 45 33 30 35 39 38 41             .....B995E30598A
38 44 46 31 39 37 33 30 37 43 33 33 44 39 39 31             8DF197307C33D991
32 41 35 38 31 34 30 38 34 37 31 44 39 45 31 46             2A581408471D9E1F
31 35 30 31 37 46 43 30 41 30 39 43 43 38 45 39             15017FC0A09CC8E9
35 30 36 37 42 31 34 45 33 45 44 35 38 37 46 31             5067B14E3ED587F1
42 42 35 36 46 37 34 35 35 32 43 32 35 45 35 34             BB56F74552C25E54
36 36 39 45 46 42 44 35 31 46 34 38 33 41 42 44             669EFBD51F483ABD
38 32 35 31 44 35 32 35 35 36 39 37 43 46 37 30             8251D5255697CF70
42 35 31 42 35 54 51 43 6C 69 65 6E 74                      B51B5TQClient

Pubkey: B995E30598A8DF197307C33D9912A581408471D9E1F15017FC0A09CC8E95067B14E3ED587F1BB56F74552C25E54669EFBD51F483ABD8251D5255697CF70B51B5
[GAME] Unknown packet ID: 23953
FF 4F 91 5D E1 08 CD 26 02 00 00 00 7B 00 45 6E             .O.]...&....{.En
00 00 00 00 00 00 00 00 0A 00 00 00 54 51 43 6C             ............TQCl
69 65 6E 74                                                 ient
Game Server Packet 1052 is corrupted. The first couple bytes return garbage, but starting at offset 8, the data is valid. I even get the correct footer (TQClient)

Do you have any idea what's the cause?

Edit 4h later: I'm going to get bald tearing out my hair here jfc. I'd have used a lower client version but 5065 is the only one I could get to run on linux...
It can unfortunately be a number of things. I'd say make sure your lengths are correct and you're waiting to decrypt that packet until your Blowfish cipher has been re-keyed.
Spirited is offline  
Old 10/20/2022, 22:08   #57
 
elite*gold: 0
Join Date: Oct 2022
Posts: 36
Received Thanks: 2
The lengths are fine, as you can see in the hexdumps. both packets (DH and 1052) end with TQClient. The code is synchronous, so there's nothing else going on with the crypto.
.Nostalgia is offline  
Old 10/21/2022, 01:45   #58
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by .Nostalgia View Post
The lengths are fine, as you can see in the hexdumps. both packets (DH and 1052) end with TQClient. The code is synchronous, so there's nothing else going on with the crypto.
Hmm... It seems like you have the bug I just mentioned where you're decrypting the entire receive buffer (which probably includes part of MsgConnect, depending on how big your buffer size is)... But I don't really know since I don't know what your classes do. I'm also not sure how you copied my DHKE class either without an await on the prime generator background service. Since this problem isn't related with Comet, though... could you make a new thread about this so we can dive deeper into your code?
Spirited is offline  
Old 10/21/2022, 09:10   #59
 
elite*gold: 0
Join Date: Oct 2022
Posts: 36
Received Thanks: 2
Quote:
Originally Posted by Spirited View Post
Hmm... It seems like you have the bug I just mentioned where you're decrypting the entire receive buffer (which probably includes part of MsgConnect, depending on how big your buffer size is).
no I do not. You can see in my code i have once receive operation for DH, which i then decrypt and one operation for the first real game packet, which i decrypt afterwards. The 2nd packet is always 36 bytes - 28 + TQClient.

Quote:
Originally Posted by Spirited View Post
.. But I don't really know since I don't know what your classes do. I'm also not sure how you copied my DHKE class either without an await on the prime generator background service. Since this problem isn't related with Comet, though... could you make a new thread about this so we can dive deeper into your code?
The reason im posting in this thread is because I am using your classes for blowfish and DH. There's no await because I just pulled out the pime generation from the background service to make it synchronous.


The only changes I made to your code were those that gave me compiler warnings about uninitialized variables / possible null de-referencing / naming rules / making it compatible with ECS architecture.

If you still want me to create a thread let me know
.Nostalgia is offline  
Old 10/21/2022, 10:35   #60
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
Quote:
Originally Posted by .Nostalgia View Post
If you still want me to create a thread let me know
Yes, please. Since the code does work in Comet, I suspect it's something else. I don't mind helping you investigate, but I don't wanna hijack this thread for that discussion. Much appreciated.

Edit: I did also improve the reliability of the DHKE after a separate complaint on it sometimes failing (was a problem with the packet on send). It wouldn't cause the error you're seeing, though. Just bringing it to your attention.
Spirited is offline  
Reply


Similar Threads Similar Threads
[Open-Source][C#] EloBuddy, open source League of Legends Bot
05/27/2014 - League of Legends Hacks, Bots, Cheats & Exploits - 8 Replies
-- Snipped --
Patches, Patches, OMG Patches
08/21/2010 - EO PServer Hosting - 3 Replies
A certain someone reckons I make good guides, so heres my second effort. PATCHES! How I made One. Prerequisites 1- Computer, sorry for the sarcasm. 2- Winrar 1-Select all the files you wish to use in the patch. Include the version.dat file which needs to be edited through notepad to higher number. (EG 1001 to 1002). Important, every folder you edit in anyway must be included in the patch!



All times are GMT +1. The time now is 23:09.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.