Game reverse engineering question about encryption/decryption

Newbie Spellweaver
Joined
Jan 13, 2025
Messages
14
Reaction score
0
Hi, I am trying to learn reverse engineer a game that no longer has active server (I know this is almost impossible since you can't sniff packets from login protocol). The way i understand it the first step is the figure out the encryption/decryption logic by tracing recv and send and create a tool to decrypt and re encrypt data, next i need to find opcode handler to figure out what packets the client is expecting from server and use decryption/encryption tool to craft packets to see how client responds. NOW my question is: can't you just trace recv and create a decryption tool, then just create an encryption tool based on the decryption tool? Sorry for my ignorance and thank you for any knowledge you can give me :)
 
As far as I know, you would have to find out the encryption algorithm first. In Priston Tale for example, it was only a XoR "encryption". So, technically, you could create a reverse function by knowing just one of them. Because it wasn't really an encryption.

Do you already know what encryption this game is using?
 
Last edited:
As far as I know, you would have to find out the encryption algorithm first. In Priston Tale for example, it was only a XoR "encryption". So, technically, you could create a reverse function by knowing just one of them. Because it wasn't really an encryption.

Do you already know what encryption this game is using?
It uses XOR with specific constants, shifts and randomizations. I was able to find find find decrypting logic in memory dump '00b10000' that contained PE file. I made a tool that decrypts the data using XOR with the different constants.
 
So I guess you can make an encryption function with just the decryption one.
Just another question, the encryption is because you have to encrypt the packets before sending them because the client expect encrypted packets? You cant just send unencrypted packets?
 
That would highly depend in how your game specifically is designed. In priston tale for example it could sometimes handle both encrypted/not encrypted packets. While other times, sending them encrypted would be mandatory. But that's just how this game works.

In my experience I would start with the premise that the client expects encrypted packets. You can find that out by analyzing the recv functions. When you find out how client handles the received packets, you will probably find some comparison to discard invalid packets, not encrypted ones, etc.

I tried similar thing in the past, analyzing LaxeLore game. It doesn't have a working server too. All I can say you must really love the game because the process is frustrating sometimes and time consuming. But the reward is great too!
 
Last edited:
Find where the non-obfuscated packet buffer is being built, find where it's stored/where it's passed, hook that. You now have the full buffer before it reaches the encryption routine.
 
As far as I know, you would have to find out the encryption algorithm first. In Priston Tale for example, it was only a XoR "encryption". So, technically, you could create a reverse function by knowing just one of them. Because it wasn't really an encryption.

Do you already know what encryption this game is using?
Or NOP the encryption and decryption methods, just forward the send and received buffer to the right buffers.

If the server is not available you can start with removing the encryption. then just restore it when you figure it out the encryption or put your own.

A method to reverse a server that is not available is to brute force the OP codes(operation code) and debug the client to see how the packet looks and what effect has to the client in that state(the client ca permit different op codes in different states) then document the packet structure
 
Last edited:
Or NOP the encryption and decryption methods, just forward the send and received buffer to the right buffers.

If the server is not available you can start with removing the encryption. then just restore it when you figure it out the encryption or put your own.

A method to reverse a server that is not available is to brute force the OP codes(operation code) and debug the client to see how the packet looks and what effect has to the client in that state(the client ca permit different op codes in different states) then document the packet structure
I am currently having trouble with the debugger terminating before relevant code, I have tried to trace back : debugactiveprocess debugactiveprocessstop debugbreak debugbreakprocess debugsetprocesskillonexit debugger and NOP them with no good results, have also tried to hook them also no good results so far. The debugger keeps getting stopped at specific jump instructions, such as the ones at ntdll.77158AF8 and ntdll.77158B01 and always ends by ZwTerminateProcess.
 
I am currently having trouble with the debugger terminating before relevant code, I have tried to trace back : debugactiveprocess debugactiveprocessstop debugbreak debugbreakprocess debugsetprocesskillonexit debugger and NOP them with no good results, have also tried to hook them also no good results so far. The debugger keeps getting stopped at specific jump instructions, such as the ones at ntdll.77158AF8 and ntdll.77158B01 and always ends by ZwTerminateProcess.
Breakpoint NtSetInformationThread.

If you pass 0x11 to the second parameter of NtSetInformationThread, the thread will be hidden from debuggers. If any trace routes into code running within that thread, or a breakpoint is hit within that thread, the program terminates.

You have to breakpoint it as soon as the program starts.

(There's a chance they could set it from TLS callbacks as well, at which point make sure you have TLS callback exceptions enabled in x64dbg)

Also, just post the binaries.
 
Last edited:
Breakpoint NtSetInformationThread.

If you pass 0x11 to the second parameter of NtSetInformationThread, the thread will be hidden from debuggers. If any trace routes into code running within that thread, or a breakpoint is hit within that thread, the program terminates.

You have to breakpoint it as soon as the program starts.

(There's a chance they could set it from TLS callbacks as well, at which point make sure you have TLS callback exceptions enabled in x64dbg)

Also, just post the binaries.
 

Attachments

Or NOP the encryption and decryption methods, just forward the send and received buffer to the right buffers.

If the server is not available you can start with removing the encryption. then just restore it when you figure it out the encryption or put your own.

A method to reverse a server that is not available is to brute force the OP codes(operation code) and debug the client to see how the packet looks and what effect has to the client in that state(the client ca permit different op codes in different states) then document the packet structure
I saw your profile on the forum. You are a real expert. Can you add your instant message? Anything is fine. I guess we are from the same country.
 
Back