for sake of simplifying we will split the server to the following main partsconquer server is simply an application that handle connections from clients which sends and receive data, which is why you need the internet connection with other clients also the cryptology part as the packets are always encrypted and then you should handle the data with your server logic to figure out what the client want to do and reply with appropriate respond, and you would always need to verify and store information which why we use the database
- Sockets Connection
- Database Connection
- Cryptology
- Packets handling
- Miscellaneous
what knowledge do you need
- First of all is programming, I'm not asking you to be expert but atleast being able to design such a big project and be able to fix errors, but trust me the more you know the better you will do, every technique of the language and every options becomes handy at some point
- Second is Reverse engineering knowledge to be able to get information from the client such as crypto and other useful information but that is not particularly necessary as others have done that job and released it to public (however there is still a missing part which to why we are using loaders, it has not been released by RE experts to limit the number of proxy bots out there that can use clientless feature)
There is already a topics out there on the same subjects which had been released by great members that you must first read before proceedingSockets Connection : the following links will ease your life and will save your time searching , if you are familiar with C# sockets you can simply quit this part as all of the C# socket classes looks the same to me (with slightly difference) but i would still recommend you visiting those links
text links:video links:
almost an hr explaining everything in details
a video serise with examples
msdn links:
typically we are using a listener Socket instance after using System.Net System.Net.Sockets, then start defining it's properties
Code:_SOC = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _SOC.Bind(new IPEndPoint(IPAddress.Any, Port)); _SOC.Listen(_backlog); then by now you may call the begin accept _SOC.BeginAccept(new AsyncCallback(AcceptConnectionsCallBack), null);
begin accept is having an internal loop which keeps trying to accept new connections, that's why we are passing a void method with IAsyncResult parameter to be called whenever it receives new connectionDatabase Connection :
now we need one more worker socket to keep receiving data while freeing the listener socket to accept more connections by using the EndAccept method with the IAsyncResult parameter you received for passing the connection to our worker socket and then you can begin recieving once more
while the RecieveCallBack is a method to invoke whenever it recieves data which is the same idea, looping trying to recieve data and invoking this void method with IAsyncResult parameterCode:CS.SOC = _SOC.EndAccept(IR); CS.Buffer = new byte[Constants.MAXBUFFERSIZE]; CS.SOC.BeginReceive(CS.Buffer, 0, Constants.MAXBUFFERSIZE, SocketFlags.None, new AsyncCallback(RecieveCallBack), null); _SOC.BeginAccept(new AsyncCallback(AcceptConnectionsCallBack), null);
you may always use it's second overload with passing a reference of integer variable to get the socketerror to verify if it was successful
that is briefly a simple example of async socket, but the links i provide you is way more correct and briefly explaining everythingCode:int size = SOC.EndReceive(IR, out error);
what's left about sockets is having a wrapper class which is used to keep both the socket(connection) and a gameserver/authserver object together so you can figure out whom the data was sent for
at the end you would want to invoke custom methods at accept connection , recv. and end connection for both main sockets you have (game server / auth server) each on it's own port
most of private servers are using custom classes to access the database and CRUD (Change,Read, Update, Delete) techniques
over here you would find 40 tutorial about mysql and c#but for a better database connection and more reliable one you may use NHibernate, everyone is recommending it however it's not used frequently as when it comes to mapping inherited/composted classes as it becomes lil more complicated (maybe not lil but yeah it depends on how familiar are you with the xml) where as of what i know generator won't do the trick, enough about nhibernate cuz i personally duno much about it and lets move to
Cryptology : TQ cryptology is already public (most of it required to go), Reverse Engineering experts could always find there way at the client and find the signature of the encrypting/decrypting, you may even use client methods with a copy past at c++ inline asm with slightly editing and you will end up with perfectly valid method
other than that there is 2 more ways, first is leeching it from some trinity edition with openssl or second to use CptSky dll which is what i recommend
if you would love to dig deeper i would recommend you the following
lena tutorialsyou would maybe quit 2 times, first at the pe header and import tables at tutorial 3, as it's really a big load of information to digest at once and it's kinda "dry" at this subject, that's where you may need to do more searching on google (there is lots of tutorials on this subject) and for saving your time
here is a really nice tiny book from ARTeam that would really help you out at the pe header and structure
and the second quit is at unpacking/unprotecting as it requires a perfect understanding for system stack to be able to do your very first manual unpacking
here is what really helped me out (it's for x64 but it's the same for x32)
for more about RE you may also have a look at
there is tons of tutorials out there, you would need tons of information and even more practice, i would suggest downloading a sit rip of tuts4you (it's provided you tons of research papers and tutorials, also load of keygenme/crackme which some of them are real good
i won't lie but it takes months to be able to be able to dig in conquer executable, that's why i think it's okay to skip this part if you are not really interested
back on the track
Packets handling :
Miscellaneous :packet handling requires packet sniffing to figure out what the server actually does with client packets on original tq servers to be able to copy the same logic
lets say you would want to implement the mentor reward system
you use some packet sniffer and found that client send a packet of type say 1234, you would first try to do something like
then you found that server replies with some packet contains some valuesCode:switch(packet_type) { case 1234: { break; } }
go to the game and find what this values represent, maybe at offset 6 you get the exp, offset 10 you get the +1 stones, ...
so you would make a full structure, create class and then compose that packet the client needs with information from the database
i think you got the idea
you may agree or disagree about the design but most important is to have a design that doesn't eat memory up with nice ping and smooth algorithms
- about the server design, you would need to have something like player object with all members you need (read and write to the database and modified by the client actions) a player having money, you get the amount on login from the database and the client may edit it by buying some item, then you save it back to the database and to have such organized project you would want to compose/inherit any entity have a position of map,x,y so for sake of organization and being able to inherit other classes from it (such as players , monsters and npcs) a poor design would be having a ushort of x,y,map for players and another one for monsters and another one for npcs, instead we could simply inherit them all with those members of lets call it coords class ,i personally having an entity and advanced entity, where entity is child of coords and having basic entity (most common between everything ex. mesh), then advanced entity for monsters and players where it's child of entity where it contains maybe hitpoints , mana , attack and defence ... and so on ,with the following convention, the most common then less common and so on, so you would have to only inherit just one simple class to get all properties you need and having your very own properties at your class without all common properties
- at some point i was also confused to use an instance of some class (kinda composition) or inheriting and i've found is a / has a convention is doing the trick
however it might be confusing
player is not a coords, player has a coords , where it's better here to use inheritance than composition to access it directly player.x not player.coords.x
but i've made my very own convention about this subject, if you need more than one property use instance, if you only need one use inheritance- also an example of a bad design could be trinity interfaces which you have to write the methods at every single class that is inherited from this interface, instead i've had a middle classes inheriting from interfaces the common methods and the real classes are inheriting this middle class so you avoid rewriting methods all over again and still be able to use them all as interface object
- another example of bad design is having maybe 300 property/variable at the gameserver class instead of having ONE property ex. player inherited from more classes to make everything organized
at the end i wish that gave you more information about what a server is and how to create one, please leave your comments if you want me to correct/edit/add something also any questions is welcomed