kinnay / NintendoClients

Python package to communicate with Switch, Wii U and 3DS servers
MIT License
537 stars 63 forks source link

Add support for switch system versions 17.0.1, 18.0.0, 18.0.1 #129

Closed TheGreatRambler closed 1 month ago

kinnay commented 1 month ago

Thank you very much. A few things before I am merging:

  1. Your patch has spaces for indentation in nintendo/switch/common.py. Please use tabs instead.
  2. When I looked at the account sysmodule, it looked like Nintendo forgot to update the key generation in the DAuth client. Have you verified that it uses key generation 18 on system version 18.0.x? This is important because DAuth is the server where Nintendo implements device bans.
  3. The sun and atumn tests are failing. The tests currently set the system version to 17.0.0. Could you either roll back your edits to the expected user agent, or update the tests to use 18.0.1 instead? Unless something has changed significantly, we do not necessarily need to test the latest system version in my opinion, so I would recommend the former.

Do you want to fix these things?

TheGreatRambler commented 1 month ago
  1. Fixed

  2. The SMM2 API operates correctly under keygen 18 for 18.0.1 so I feel reasonably safe about that. yellows8 also notes that the keygen is 0x11 which, going from previous updates, is always 1 less than the keygen used in DAuth.

  3. Reverted

kinnay commented 1 month ago

I believe that the DAuth server accepts any key generation, regardless of the system version. While it may work, I would like to accurately copy the behavior of the client, so I would like to see this verified another way. The fact that the update bot detects key revision 17 doesn't really mean anything, because the key generation that is used by the DAuth client is indepedent from that, and hardcoded into the account sysmodule.

I might have time to check it with a MitM this weekend.

TheGreatRambler commented 1 month ago

After testing you're right that it doesn't matter what keygen I use, the request succeeds (did this change in the 2024 Dragons update? I seem to remember DAuth failing on the wrong keys in the past). I will keep this fork's keygen on 18 until you can verify.

Ixaruz commented 1 month ago

Hi, I checked with a mitm on system version 18.0.1 and it says key_generation 17.

POST /v7/device_auth_token HTTP/1.1
Host: dauth-lp1.ndas.srv.nintendo.net
Accept: */*
Content-Type: application/x-www-form-urlencoded
X-Nintendo-PowerState: FA
Content-Length: 211

challenge=[REDACTED]&client_id=[REDACTED]&ist=false&key_generation=17&system_version=CusHY#00120001#chuxR_O35JFyJq7dIlT8yP1A-j1yBcF-iU4iVDjHt9g=&mac=[REDACTED]
kinnay commented 1 month ago

Thanks for checking.

@TheGreatRambler If you change the key generation to 17 I will accept the PR.

did this change in the 2024 Dragons update?

The server has always accepted different key generations as far as I know. I tested it some time ago when 15.0.0 was the latest system version. Back then, the following key generations were accepted for /v6 and /v7: https://github.com/nintendo-playground/dauth-server/blob/main/dauth/main.py#L49-L52

TheGreatRambler commented 1 month ago

Done, thank you for confirming @Ixaruz