4 ms·
Reverse Engineering Dark Souls 3 Networking
- ivraatiems 4y agoI read through the whole series of posts in one sitting - impressively thorough! As someone who spends a lot of time writing and structuring regular old REST APIs, it's a lot of fun to see an approach to API design that is rooted in the foreign convention of game design, even if the implementation language is in the ballpark of ones I use. Interestingly, once you get past the authentication, the reliable UDP implementation, and into the "meat" of the behavior, it's the same sort of call-response stuff that anybody else is doing, with the same sort of fairly basic little payloads. The "special sauce" is all the components getting to that point - and the fact you're getting binary data and not JSON or something. Not the most exciting thing, if you're a game developer. Sometimes I wonder what somebody who paid as thorough attention to systems I've worked on would say about them. What would the weird stumbling blocks be? What would the "magic" be that seems to make no sense? ("What are the security holes they find?" goes without saying, but that's feedback I get from our internal pentesters anyway.)
- thejosh 4y agoOne fun project I did a while ago was reverse engineering one of the games from my teens, Runescape 2 (now called Old School Runscape, where the game is a backup from August 2007 with many updates since then). There is a huge interest in the game, with many players still playing it, I had fun for a couple of months for a few hours a week.. but then noticed there was a field in a client you use (nobody uses the official client, they use Runelite, which is an amazing opensource client for OSRS). I reverse engineered the login protocol, it was a lot of fun. Erlang pattern matching on binaries with Elixir made this incredibly easily and very fun to implement.
- FujiApple 4y agoThis part, yikes: > As our encryption is asymmetric, you may be asking how the client decrypts messages send by the server if it only has a public key. To do this the game exploits an interesting quirk of RSA cryptography, its possible to encrypt with the private key and decrypt with the public key. This is exactly what happens when the server sends the client message. For anyone contemplating doing this though, don’t, it’s terrible for a number of reasons. You can read some of these reasons here, written by someone far more knowledgeable about cryptography than myself. Great effort reverse engineering the protocol and producing an enjoyable write up.
- vlovich123 4y agoThat quote doesn’t seem to appear in the article, or at least not anymore? I was curious to read the reasons. The ones that come to mine are the obvious ones that EC is significantly faster and more secure and that you should only use asymmetric to negotiate a symmetric key exchange (eg ECDH) since symmetric is going to be even faster and suitable for real-time streaming.
- cybrox 4y agoThe quote is from the second article in the series. You can find it here: https://timleonard.uk/2022/06/02/reverse-engineering-dark-souls-3-networking-part-2 https://timleonard.uk/2022/06/02/reverse-engineering-dark-so...
- jakobdabo 4y ago> its possible to encrypt with the private key and decrypt with the public key Isn't it just signing/verifying? I.e. "encryption" with a private key is how RSA is being used to sign, and "decryption" with a public key - used to verify the signature.
- jpnc 4y agoI thought so too. Encrypt the hash with private key -> decrypt with public key and check the hash.
- FujiApple 4y agoThis could well be it, though if the plaintext isn’t sent (unclear from the article if it is, I think not?) then all the client can really do is decrypt with public key and check that the output appears well formed, which may be good enough. It would seem odd, however, that client -> server is encrypted but unsigned whereas server -> client is signed but unencrypted. My guess, for what it’s worth, is that somebody at the company insisted that all comes must be encrypted and so they cobbled this together along with the obfuscation of the public key the author describes.
- unnouinceput 4y agoQuote: "However all multiplayer traffic in FromSoftware’s games is actually sent entirely peer-to-peer." This is very important to understand why currently DS3 PC server is closed for half a year now due to cheaters. FromSoftware does a childish attempt at creating a server hence the plague of cheaters. And what they do? They released Elden Ring instead of working to properly create a server. FromSoftware knows how to create console games, but a PC game is outside of their expertise.
- cybrox 4y agoWhat exactly is your point here? Console games need (mostly the same kind of) netcode as well. They are just generally harder to exploit, which dramatically lowers the amount of people trying to do so. They are capable of writing a netcode that is good enough for an environment where it is relatively safe due to the restrictions of the devices it runs on but not for any true open environment. - So they just write bad netcode, that's all.
- Cloudef 4y agoPC gaming unfortunately never evolved in form where games would run in a sandboxed environment. Linux + flatpak steam + proton is probably the closest you can get without too many practical issues.
- cybrox 4y agoThis has its own up- and downsides. While the game not being sandboxed creates risks for the consumers (as demonstrated by FROM with Dark Souls 3) and allows people to more easily exploit the game, it also makes modding and often times supporting a game long past its original lifetime possible. Personally, I would love to have the benefits of sandboxing but I would not want to live without modding and community supported servers. The console market shows us how consumers are abused in an environment where they have no say in what happens to the software that they purchased.
- Cloudef 4y ago
- samwestdev 4y agoAmazing write-up! Any good resource how to do this kind of reverse engineering? Maybe with simpler/older games first.
- Cloudef 4y agoDepends what you want to do. But good debugger is absolutely essential. Reversing communication? MITM the communication. Want to understand the game's logic / find entrypoints? Memory scanner/editor -> breakpoint to a address in debugger. Combine above with disassembler with good code analysis tool and you'll be able to follow the code even without actually having the source. In the end reversing is basically poking around and experimenting, but it is very rewarding and will teach you a lot how software work and how easy it is to actually make them bend to your will. Be wary, you'll need lots of free time for this.
- c7DJTLrn 4y agoI've been reverse engineering another online game and encountered very similar themes in terms of encryption. Lots of weird obfuscation, pseudosecurity, and obvious vulnerabilities. Instead of choosing something battle-tested like TLS they roll their own crypto and fail miserably.
- Cloudef 4y agoLots of f2p mmos still do the good old xor encryption https://git.cloudef.pw/sw-server.git/tree/src/packet.c#n32 https://git.cloudef.pw/sw-server.git/tree/src/packet.c#n32