gamedig / node-gamedig

Query game servers and not only! Node.JS/Deno or Bash (via the CLI).
https://www.npmjs.com/package/gamedig
MIT License
590 stars 144 forks source link

Rules being returned hashed. #287

Open InfamyStudio opened 2 years ago

InfamyStudio commented 2 years ago

How do we solve this as upon looking on the steam docs, the A2S_RULES require a challenge response. So how can I read this data in text format.

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?

InfamyStudio commented 2 years ago

https://developer.valvesoftware.com/wiki/Server_queries#A2S_RULES

mmorrisontx commented 2 years ago

This is unrelated to the A2S_RULES challenge. Different games return different fields in their rules response, there really is no set standard. What game is this?

InfamyStudio commented 2 years ago

This is V Rising, Battlemetrics are doing this with no issue. I am not able to get this response legible and it must be to do with something regarding the challenge if these are being encoded.

mmorrisontx commented 2 years ago

The A2S rule challenge, when incorrect, results in the server responding with an updated challenge response code. That is not what is happening here. If Battlemetrics is able to parse this data, then they know something about v rising's rules encoding that we do not.

InfamyStudio commented 2 years ago

The A2S rule challenge, when incorrect, results in the server responding with an updated challenge response code. That is not what is happening here. If Battlemetrics is able to parse this data, then they know something about v rising's rules encoding that we do not.

We were able to work out how this is being done. This encoded text is nothing more then just a dictionary we believe. Every single rule change has a corresponding position or letter associated. Battlemetrics simply put their team on it to reverse all setting options available. Or they were provided with the answers. I believe this is a way anyone with some spare time can do this job. If you run a server and send a request and download that data you can have the string. Change one rule value and compare the two and start recording or coding in ways to recognise the values. I own an API for making requests on rapid api https://rapidapi.com/InfamyStudio/api/vrising-server-scanner - I will eventually implement this into my system as a paid feature.

mmorrisontx commented 2 years ago

it's certainly base64 encoded, so if you think it's a raw binary blob, it should definitely be base64-decoded prior to trying to figure out the meaning of each byte.

InfamyStudio commented 2 years ago

The hash is base64 but the rules are not. I had some people who specialise in cryptography look at it and also ran some systems against it. It returns garbage if you even attempt to. There is no base64 encoding in my opinion. It looks more custom than that. But as I said there is no need to do this either if the rules do not change from request to request you just gotta play the long game and record each change.

mmorrisontx commented 2 years ago

It's very likely base64 encoded, the character set and trailing + on settings0 is a giveaway. (it also results in many of the bytes being 0, which is probably either string padding or false booleans). That said, you are correct that the decoded data is hard to decypher, and would probably be brute force unless there was a mysterious doc stashed away somewhere :)

podrivo commented 6 months ago

GameDig returns the same info as BattleMetrics, as you can see in this example: https://www.battlemetrics.com/servers/vrising/24885357

The "BattleMetrics Server Description" is being pulled by state.raw.rules.desc0 and state.raw.rules.desc1. All the other info is not being used by BattleMetrics, so I'm not sure there's anything else to do here.

gamedig --type vrising --requestRules --pretty 176.57.143.58:32015

{
  "name": "(NA) Throne of Shards - PvP - 2X - Solo/Duo",
  "map": "VRisingWorld",
  "password": false,
  "raw": {
    "protocol": 17,
    "folder": "V Rising",
    "game": "0dcb8690-7785-4ce9-b2bc-5f898be34db6",
    "appId": 1604030,
    "numplayers": 4,
    "numbots": 0,
    "listentype": "d",
    "environment": "w",
    "secure": 1,
    "version": "0.0.0.1",
    "steamid": "90179543930759168",
    "tags": [
      "pvp",
      "cs2",
      "ded",
      "sea",
      "sal_mi"
    ],
    "rules": {
      "blood-bound-enabled": "True",
      "castle-heart-damage-mode": "CanBeDestroyedOnlyWhenDecaying",
      "days-runningv2": "10",
      "days-until-reset": "4",
      "desc0": "-Weekend raids (6pm-9pm CST)\n-Weekday admin-hosted events\n-Shard reset on Monday and Thursday\n-One shard per clan\n-2 wee",
      "desc1": "k wipe\n\nRules:\n-Non-toxic\n-No exploiting\n-No teaming\n\nDiscord: \nhttps://discord.gg/BxRVCh3CZS",
      "game-settings-hash": "40d452650825d2640d637a1b48c56b041f158e1a1a9716a83786d4fcfa65bd81",
      "settings0": "BwAAAAAAAAAAAAAAAAAAAAAAAACgQAEGBAgFATIAAwIDApYABAIDA/oABQIDBF4BBgIDBaQBBgIDBQEBAgEDAQQBBQE4ZGYyCQARAAoSADwAPAA8ADwAPAA8ADwA",
      "settings1": "PAA8ADwAPABFADwAPAA8ADwAPAA8ADwAQgBAAEAAQABAADxATgA8AEWQXoBTAAAAAAAAAMADwAPAA8ADwAPAA8ADAAPAY6ajmQPAA8ADwKOZAxAEEAQABMADwAPA",
      "settings10": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings11": "AA==",
      "settings2": "EyAAABAwAAAAAAAAAAAAAAAAAACAALAAUCAgsBEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings3": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings4": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings5": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings6": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings7": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings8": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings9": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
    }
  },
  "maxplayers": 40,
  "players": [
    {
      "name": "Koi",
      "raw": {
        "score": 0,
        "time": 28124.388671875
      }
    },
    {
      "name": "NubZ",
      "raw": {
        "score": 0,
        "time": 24814.982421875
      }
    },
    {
      "name": "Percy",
      "raw": {
        "score": 0,
        "time": 6121.30419921875
      }
    },
    {
      "name": "BOOTSWITHTHEFUR",
      "raw": {
        "score": 0,
        "time": 1933.0753173828125
      }
    }
  ],
  "bots": [],
  "connect": "176.57.143.58:32000",
  "ping": 183
}
InfamyStudio commented 6 months ago

GameDig returns the same info as BattleMetrics, as you can see in this example: https://www.battlemetrics.com/servers/vrising/24885357

The "BattleMetrics Server Description" is being pulled by state.raw.rules.desc0 and state.raw.rules.desc1. All the other info is not being used by BattleMetrics, so I'm not sure there's anything else to do here.

gamedig --type vrising --requestRules --pretty 176.57.143.58:32015

{
  "name": "(NA) Throne of Shards - PvP - 2X - Solo/Duo",
  "map": "VRisingWorld",
  "password": false,
  "raw": {
    "protocol": 17,
    "folder": "V Rising",
    "game": "0dcb8690-7785-4ce9-b2bc-5f898be34db6",
    "appId": 1604030,
    "numplayers": 4,
    "numbots": 0,
    "listentype": "d",
    "environment": "w",
    "secure": 1,
    "version": "0.0.0.1",
    "steamid": "90179543930759168",
    "tags": [
      "pvp",
      "cs2",
      "ded",
      "sea",
      "sal_mi"
    ],
    "rules": {
      "blood-bound-enabled": "True",
      "castle-heart-damage-mode": "CanBeDestroyedOnlyWhenDecaying",
      "days-runningv2": "10",
      "days-until-reset": "4",
      "desc0": "-Weekend raids (6pm-9pm CST)\n-Weekday admin-hosted events\n-Shard reset on Monday and Thursday\n-One shard per clan\n-2 wee",
      "desc1": "k wipe\n\nRules:\n-Non-toxic\n-No exploiting\n-No teaming\n\nDiscord: \nhttps://discord.gg/BxRVCh3CZS",
      "game-settings-hash": "40d452650825d2640d637a1b48c56b041f158e1a1a9716a83786d4fcfa65bd81",
      "settings0": "BwAAAAAAAAAAAAAAAAAAAAAAAACgQAEGBAgFATIAAwIDApYABAIDA/oABQIDBF4BBgIDBaQBBgIDBQEBAgEDAQQBBQE4ZGYyCQARAAoSADwAPAA8ADwAPAA8ADwA",
      "settings1": "PAA8ADwAPABFADwAPAA8ADwAPAA8ADwAQgBAAEAAQABAADxATgA8AEWQXoBTAAAAAAAAAMADwAPAA8ADwAPAA8ADAAPAY6ajmQPAA8ADwKOZAxAEEAQABMADwAPA",
      "settings10": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings11": "AA==",
      "settings2": "EyAAABAwAAAAAAAAAAAAAAAAAACAALAAUCAgsBEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings3": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings4": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings5": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings6": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings7": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings8": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
      "settings9": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
    }
  },
  "maxplayers": 40,
  "players": [
    {
      "name": "Koi",
      "raw": {
        "score": 0,
        "time": 28124.388671875
      }
    },
    {
      "name": "NubZ",
      "raw": {
        "score": 0,
        "time": 24814.982421875
      }
    },
    {
      "name": "Percy",
      "raw": {
        "score": 0,
        "time": 6121.30419921875
      }
    },
    {
      "name": "BOOTSWITHTHEFUR",
      "raw": {
        "score": 0,
        "time": 1933.0753173828125
      }
    }
  ],
  "bots": [],
  "connect": "176.57.143.58:32000",
  "ping": 183
}

Appreciate the reply but a bit late to the party, the settings were read in plain text by Battle Metrics, they had clearly decoded or mapped how the settings get returned from the query but this no longer seems to be a feature on their site. I think a good extension to these tools would be to build a layer that can map encoded settings to a schema or whatever

CosminPerRam commented 6 months ago

Hey, sorry to reopen this but I am curious to investigate a bit, will report back my findings.