Yepoleb / python-a2s

A2S Query API for Python
MIT License
151 stars 17 forks source link

Settings being returned are encrypted #32

Closed InfamyStudio closed 2 years ago

InfamyStudio commented 2 years ago

I am trying to use this system to build an API to return data to create a server listing site. Currently when I request the server rules I get returned an encrypted response: 'game-settings-hash': 'b6d946d8046638f07908395427ececcbb0a12a06b08306d1537ac34ec2b6389c', 'settings0': 'AgAAAAAAAAAAAAAAAAAAAAAAAACgQAEMBAUAAAAAAAAAAAIAAAAAAwMAAAAABAQAAAAABQUAAAAABv4FAAAAAAAAAAAUAAAAABUyAAAAADNQAAAAAFGgAAAAAKH+', 'settings1': 'BAAAAAEeAwJQBQOWBwT6CQQAAAABAQIBAwEEAThkZjYJABEAChIAPAA8ADwAPAA8ADwAPAA8ADwAPAA8AEUAPAA8ADwAPAA8ADwAPAA8AD0APQA9AD0APEBOAEQA', 'settings2': 'RJBegFMAPAA8ADwAPAA8ADoAPM0wADwAPAA8ADoAPAA8ADoAQAA+ADwBAgACAgQAABEAFwARABcAEgAWABAAFgAEAgSbAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'settings3': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'}

What do I do to be able to read this data, Battlemetrics are doing this with no issue. What is the flaw in the process currently that is not allowing me to see this data in plain text?

Yepoleb commented 2 years ago

That's not encryption, that's base64 encoding from the look of it. Whatever game is using this is returning a game specific encoded binary response. Without knowing the name and finding some documentation this is very hard to decode. But on the part of this library everything is working correctly. I might still be able to help you if you provide me with more information about the application.

InfamyStudio commented 2 years ago

My API, https://rapidapi.com/InfamyStudio/api/vrising-server-scanner - currently I am using Node JS but it is the same query response that your system has. I am experienced with flask so I would rather incorporate your system and not make API calls. So as you can see if you type in my host field: 176.57.173.3 and port: 28615. You can see the response for game settings is what I posted above. If base64 is encoded how do we decode this? Is the hash a key to deciphering that information or not?

InfamyStudio commented 2 years ago

"Returns the server rules, or configuration variables in name/value pairs. This query requires an initial challenge step.

The Console variables included are the ones marked with FCVAR_NOTIFY as well as any additional ones listed in the server configuration."

This is what the documentation states. How do we solve this?

InfamyStudio commented 2 years ago

https://developer.valvesoftware.com/wiki/Server_queries#A2S_RULES - this is the documentation I assume here.

Yepoleb commented 2 years ago

The encoding is specific to V Rising, you will not find any information in the Valve wiki. It does not seem like they have put out any information on the format. To decode the base64 string you can use the module of the same name:

import base64
base64.b64decode("AgAAAAAAAAAAAAAAAAAAAAAAAACgQAEMBAUAAAAAAAAAAAIAAAAAAwMAAAAABAQAAAAABQUAAAAABv4FAAAAAAAAAAAUAAAAABUyAAAAADNQAAAAAFGgAAAAAKH+")

The hash means something else, it is not needed for decoding.

InfamyStudio commented 2 years ago

This is what I did, And it does not have any legible response. This is based on the handshake most definitely, how can we fix this or how can we work out a way to decode the message? Battlemetrics have done this so surely there is an obvious way.

Yepoleb commented 2 years ago

Where do you see this information decoded on Battlemetrics?

InfamyStudio commented 2 years ago

https://www.battlemetrics.com/servers/vrising/15360174

This is my server, if you click server settings you can see all the information decoded. I do not understand how they are pulling this from every server if the rules are encoded.

Yepoleb commented 2 years ago

They probably put in the effort to decode it. The game is made with Unity so decompiling works quite well. But I do not own the game and honestly I'm not willing to spend money and time to reverse engineer this for you.