'How to read Slither IO websocket binary data with c#

I'm trying to build a custom client for a game called slither.io with csharp, but I've run into a small problem: I need to be able to read the binary data sent and received through their websocket.

I should add that you might also need to explain it like I'm dumb.

Here's a screenshot of the binary data I need to decode in C#: screenshot



Solution 1:[1]

Probably no need to reverse engineer it by yourself, there is a github project with some details. You can learn it and try to incrementally write your own code to parse it, probably in some sandbox you construct with technology you feel most familiar with, like winapi, unity or anything else. Later you will be able to move the code you created in proper modules and environment you need to use https://github.com/ClitherProject/Slither.io-Protocol/blob/master/Protocol.md#type_l_detail

To parse binary data you will have to learn some additional stuff, writing your own hex viewer will be a relatively simple but suffficient way to learn how to deal with binary. I think this tutorial is good https://www.taniarascia.com/bits-bytes-bases-and-a-hex-dump-javascript/ although it is javascript. You can write some simple console output of parsed data and compare it to some existing hex viewer like HxD

If you want to master it even better you can quickly inspect some Chip8 or other emulators code to see how they parse commands. But in two words you can mae some parsing with logical ors, ands, binary shifts. For example if you are interested in third and forth byte of int (0x1243 (11A3) 12_12_AF) variable named "a" you can write following:

(a >> 3) & 0xFFFF will have 0x11A3 in a result, so in case of these commands you can check the type of it and values of its arguments with similar approach. By basically shifting bytes and covering them with mask of needed size. If you receive this data in byte array it will be even easier, you will just access the byte you want to check.

But in case you reverse engineer some browser game, you can look into some browser js code, make some source owerrides with logs, sometimes put breakpoints if it is possible from game dynamics side and check received ws data in some hex editor like HxD. In case of the snake it can be useful to see how its segments are placed, mouse position and angle is calculated etc

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1