diegonc / packet-bnetp

Battle.net and Warcraft 3 Game Protocols Dissector for Wireshark
GNU General Public License v3.0
29 stars 13 forks source link

Update W3GS handling #12

Closed BogdanW3 closed 2 years ago

BogdanW3 commented 2 years ago

This commit improves and corrects W3GS handling. It is verified against all 1.28+ versions of the game, so I was able to unhardcode many assumptions the old code made. Even 1.32's LAN games have been used to verify this code (but it added one new packet for the menu and skin data which I haven't documented yet).

xpeh-owns commented 2 years ago

Hi! Nice to know our project is still used. Where is packet-bnetp.lua? Is there protocol documentation for your changes?

BogdanW3 commented 2 years ago

Hi! Nice to know our project is still used. Where is packet-bnetp.lua? Is there protocol documentation for your changes?

I removed packet-bnetp.lua from the repository as it is the end-product rather than the source, running "make" will still generate it exactly the same, but it won't get into commits (due to the gitignore entry) so you won't see every change twice when comparing commits from now on. I get it now that this is not actually in the scope of what my commit is meant for so I can remove that change if you'd prefer the file to remain.

As for the protocol documentation, I am still using 90% BnetDocs packet info and 10% WireShark dumps of my own games (PvPGN [less authoritative] for 1.28 and LAN for 1.28+). LAN W3GS is still exactly the same other than mDNS being used in place of the gameinfo and searchgame packets so it is where the W3GS protocol is still observed and usable even in 1.32. The few changes to packet definitions are based entirely on real game packets, with care taken to still match BnetDocs definitions where applicable: Chat to host is documented correctly on BnetDocs but the implementation here was incorrect for example, some packets ended prematurely, and a few unknown fields were hardcoded in a manner that would break in 1.28+ so I changed them to match better while also keeping compatibility with at least 1.26 everywhere possible. Other changes mostly do with making W3GS code use newer functionality of the Lua plugin like identifying product ids and setting map hashes to hexadecimal for easier comparison. Adding a sockaddr structure also allowed me to make the code parse the network data more easily as every packet using ips seems to just be sending the sockaddr associated with it.

Apologies for the long message, I hope it clears up some concerns about my changes, and I will very likely also suggest the packet structure changes to BnetDocs for packets that aren't up to date so there is parity between these 2 resources

xpeh-owns commented 2 years ago

This "end product" is what user downloads. Could you upload it so I can test your changes?

We used bnetdocs too. At that moment W3GS documentation was only half working.

Please DO NOT use pvpgn for protocol reversing as it violates it on many places. Test it on BNET if it's still working.

BogdanW3 commented 2 years ago

Here's the file (sadly zipped as Github doesn't allow uploading lua scripts): packet-bnetp.zip, and yea - the W3GS documentation has a few errors and it might have been tailored only for pre-24 versions or something like that. Here's my Suggestions Document to update BnetDocs as well (it was also sent in their Discord server). I have made sure to use LAN games as example (Ghost++ and vanilla vs vanilla as 1.30.2+ allows playing multiple on the same PC very easily). Actually now that I think about it, PvPGN stuff doesn't even affect W3GS because the main server won't be a game host, so I apologise for the incorrect wording. As an after-mention, after 1.30.2, Battle net connections can't be analyzed with Wireshark so this became useful only for LAN but it has been very helpful for my hostbot development. For the main part about end-users downloading the end-product, I assumed that would be done just through the releases tab but I can reintroduce it to the repository if you prefer that method of distribution. Thanks for taking the time to read this, and thank you for the plugin!

xpeh-owns commented 2 years ago

Seems to work. Please include packet-bnetp.lua into commit. Do you have some captures to test it with? You can send it directly to me if you don't want to publish them. Who needs latest Warcraft 3 versions actually? Popular Pvpgn server use 1.26 or something. Right, game connection goes p2p without server. But loaders e.g. could alter game connection traffic.

BogdanW3 commented 2 years ago

I can add more captures if you'd like, and I can squash commits into one so my relatively small (albeit needed for 1.28+ and useful even for 1.26 as some of the packets were simply wrong) changes don't add a lot to history. As for why I'd look at any newer version: 1.30+ is not modifiable by any loader (game was obfuscated, protocol changed and encrypted with certificate pinning) so having hostbots/gproxy++ is the only easy and reliable way to increase functionality and also still allows an (indirect and for now theoretical) way to connect to 3rd party servers. LAN emulators have taken the role PvPGNs had for 1.29+ but they aren't quite as popular so this is moreso a completeness update.

diegonc commented 2 years ago

Thanks for sharing Bogdan! It seems xpeh already handled the testing :smiley: I'll be free on the weekend but it looks good!

It seems github can handle the squashing although I still can't decide whether to create a merge commit. I usually prefer the latter but here we have a file deleted and then recreated so it may justify a squash.

xpeh-owns commented 2 years ago

@diegonc It doesn't crash and it shows something. Would you handle the request and create release?

diegonc commented 2 years ago

After a few edits to keep the last line ending in .gitignore, and generate src/packet-bnetp.lua in the first two commits, I merged this PR.

For some reason the automatic release uploading script stopped working :confused: so I had to do the release manually.