Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tatsunoko vs Capcom support? Here's a pcap file to help maybe. #29

Closed
SMTDDR opened this issue May 28, 2014 · 67 comments
Closed

Tatsunoko vs Capcom support? Here's a pcap file to help maybe. #29

SMTDDR opened this issue May 28, 2014 · 67 comments

Comments

@SMTDDR
Copy link
Contributor

SMTDDR commented May 28, 2014

When my proxy server for TvC was running, a pcap file I used as research to figure out some things: https://www.cloudshark.org/captures/d94462c4f238 This is from the moment that the Wii goes online to finding an opponent in freeBattle mode I believe. Just thought I'd offer this up.

@polaris-
Copy link
Collaborator

Have you tried playing Tatsunoko vs Capcom on our server? From what I can tell everything seems pretty standard in this packet dump, so it might work without any additional changes. If you've tried playing TvC on our server and it didn't work, could you please provide a pcap file of that, too? Thanks.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented May 28, 2014

Cool, I'll try it out. Looks like the DNS server is down at the moment.

pi@raspberrypi ~ $  dig @75.127.5.21 nas.nintendowifi.net

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> @75.127.5.21 nas.nintendowifi.net
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached

@ToadKing
Copy link
Collaborator

The DNS server is 75.127.5.215, not 75.127.5.21

@SMTDDR
Copy link
Contributor Author

SMTDDR commented May 28, 2014

Oh! sorry about that, it works now.
I will give this a shot.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented May 30, 2014

nas.nintendowifi.net's POST /ac returns 404 on your server, https://www.cloudshark.org/captures/cb0be7af11db

The shows on screen:

""""
error code: 23404

Either nintendo wi-fi connection is experiencing high traffic volumes or the service is down. please try again later. For help, visit spport.nintendo.com

""""

From older records, this is what I got from the official servers. Note that until recently(?), http://nas.nintendowifi.net was accessible on port 80 so I was able to patch the game with riivolution to go there without SSL and watch all the NAS communication between the game and the official NAS server.

    POST /ac HTTP/1.1
    Host: nas.nintendowifi.net
    User-Agent: RVL SDK/1.0
    Host: nas.nintendowifi.net
    HTTP_X_GAMECD: STKE
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 309

    action=bG9naW4%2A&gsbrcd=U1RLSjBsbzRjOXI%2A&userid=MTYwODEzMjkwNjg4Mw%2A%2A&ingamesn=AFMATQBUAEAARABEAFIAIAAg&sdkver=MDAxMDAw&gamecd=U1RLRQ%2A%2A&makercd=MDg%2A&unitcd=MQ%2A%2A&macadr=MDAxN2FiNDQ3N2M5&lang=MDE%2A&devtime=MTExMDE1MDgyOTQ4&csnum=TFUxMDM0MjE4ODc%2A&cfc=NjIzNjM1OTUzNTYxNTg5MQ%2A%2A&region=MDE%2A


    HTTP/1.1 200 OK
    NODE: wifiappe2
    Content-Type: text/plain
    Content-Length: 287
    Date: Sat, 15 Oct 2011 15:26:27 GMT
    Server: GameCube

    challenge=WjAyQUFCMDA*&locator=Z2FtZXNweS5jb20*&retry=MA**&returncd=MDAx&token=TkRTeXJlVGFRWWROQi93ZjlWcEJIc215SmZaQUZwZmpJUUljRnBQY3hYSnVIQnpIZVZ3NUhraXZXNzJnTDFjaEErT3NmUHNVYXk3a1J1SXhUSUk4RXV3d1NwVStEcm1sbmRzenprS2EzUjJRdll0ckxPR1N1VmdkU096RW0vZlQ3Qnc*&datetime=MjAxMTEwMTUxNTI2Mjc*


    POST /pr HTTP/1.1
    Host: nas.nintendowifi.net
    User-Agent: RVL SDK/1.0
    Host: nas.nintendowifi.net
    HTTP_X_GAMECD: STKE
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 267

    userid=MTYwODEzMjkwNjg4Mw%2A%2A&wregion=QQ%2A%2A&wtype=&wenc=VVRGLTE2QkU%2A&words=AFMATQBUAEAARABEAFIAIAAg&sdkver=MDAxMDAw&gamecd=U1RLRQ%2A%2A&makercd=MDg%2A&unitcd=MQ%2A%2A&macadr=MDAxN2FiNDQ3N2M5&lang=MDE%2A&csnum=TFUxMDM0MjE4ODc%2A&cfc=NjIzNjM1OTUzNTYxNTg5MQ%2A%2A


    HTTP/1.1 200 OK
    NODE: wifiappe3
    Content-Type: text/plain
    Content-Length: 142
    Date: Sat, 15 Oct 2011 15:26:28 GMT
    Server: GameCube

    prwords=MA**&prwordsA=MA**&prwordsC=MA**&prwordsE=MA**&prwordsJ=MA**&prwordsK=MA**&prwordsP=MA**&returncd=MDAw&datetime=MjAxMTEwMTUxNTI2Mjg*

You can still use the server via SSL at this moment:

myheaders = {'User-Agent':'RVL SDK/1.0','HTTP_X_GAMECD':'STKE','Content-Type':'application/x-www-form-urlencoded','Connection':'close'}
ac_postdata = "action=bG9naW4%2A&gsbrcd=U1RLSjBsbzRjOXI%2A&userid=MTYwODEzMjkwNjg4Mw%2A%2A&ingamesn=AFMATQBUAEAARABEAFIAIAAg&sdkver=MDAxMDAw&gamecd=U1RLRQ%2A%2A&makercd=MDg%2A&unitcd=MQ%2A%2A&macadr=MDAxN2FiNDQ3N2M5&lang=MDE%2A&devtime=MTExMDE1MDgyOTQ4&csnum=TFUxMDM0MjE4ODc%2A&cfc=NjIzNjM1OTUzNTYxNTg5MQ%2A%2A&region=MDE%2A"

import httplib
print "INFO: Connecting to nas.nintendowifi.net..."
conn = httplib.HTTPSConnection("nas.nintendowifi.net")
print "INFO: POST /ac",ac_postdata
conn.request("POST","/ac",ac_postdata,myheaders)
resp = conn.getresponse()
responsedata = resp.read()
print "INFO: NAS response:", responsedata

I should probably note that I'm not using your NoSSL patch because my Wii doesn't have the homebrew channel. I only put Riivolution on it via smashbros custom-stage exploit a long time ago... but I no longer have smashbros disc. So I use network-redirection to send all the UDP port 53 packets coming from my Wii to your DNS server and my TVC-specific noSSL patch to produce the pcap file I linked to above. If I were to alter my Wii's DNS settings in the WiiMenu it'll attempt the connection test which apparently will fail according to your wiki.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Hello again,

I guess I could start doing pullrequests to you folks, but just so you know...

https://github.com/polaris-/dwc_network_server_emulator/blob/master/nas_server.py#L260

That line of code cannot handle how Tatsunoko-vs-Capcom does things. In the network capture I pasted above, note action=bG9naW4%2A ...that "%2A" is an equal-sign. So the first thing that should happen is a .replace('%2A','=') for all parameter values.

>>> base64.b64decode('bG9naW4%2A'.replace('%2A','=').replace("*", "=").replace("?", "/").replace(">","+").replace("-","/"))
'login'
>>>

@AdmiralCurtiss
Copy link
Collaborator

Try if it works now.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Same thing as before; 404.

@polaris-
Copy link
Collaborator

polaris- commented Jun 2, 2014

Are you sure you tried the right server just now? I don't see any hits in the logs for the NAS server for TvC.

Edit: Oh wait, 404. I think I might see your connection in the error logs for Apache. I'll have to look into it more.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Checking...

@polaris-
Copy link
Collaborator

polaris- commented Jun 2, 2014

I just noticed something weird about the packet capture you posted before. For some reason your game is trying to connect to nas.nintendowifi.net (which should still be a valid server), but I think there might be something weird going on with your game. Either the way you have everything configured or something.

Anyway, I made the necessary changes to Apache that should allow you to connect now.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Oh yes, you're right.... an unpatched TvC will actually go to naswii.nintendowifi.net ...I had to patch it to go to nas.nintendowifi.net because on that server, port 80 was open, so I sent the game there to watch all of its NAS communication unencrypted thus allowing me to have that capture log above.

Trying..... this might be awhile, my Wii has issues from when Wii Connect24 Overheating issues toasted it. Every once in awhile it freezes up and it just decided that now would be one of those times.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Okay, 200 OK response this time but the game complained with error code: 60000.

https://www.cloudshark.org/captures/767c3fc3c9e2

One thing that immediately jumps out at me is your server's response content-length

Content-Length: 221

versus my logs of the official server

Content-Length: 287

@AdmiralCurtiss
Copy link
Collaborator

60000 is a user profile error, delete your save and try again.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

https://www.cloudshark.org/captures/f7ea3ddab8f6

Okay, after removing my savedata and allowing the game to recreate it(game refuses to go online without creating savedata) the game moved further into the online process. The game showed "downloading data...", which is past the naswii server auth. But after awhile I get a generic "Communication error" with no error number.

Normally during the "Downloading data..." phase, the game is doing the following for every profileid on my friends & rivals list after first fetching the profileid of my own savedata(XOR'ed "encryption"):

GameSpy: \lc\1\challenge\NUXMISLISY\id\1\final\
Client: \auth\\gamename\tatvscapwii\response\22de1344eea12b68dedd9268440ade49\port\0\id\1\final\
GameSpy: \lc\2\sesskey\1482017401\proof\0\id\1\final\
Client: \authp\\authtoken\NDSgpft+GTMfk1Wh6Veh2hrAKkC2C8uZAH2AfkhdF+klNZap76ri7ujgCV0EgbCI2Pxir9FAMxxHLp82lRlmX8iMBk+9lppTXw23KeGu/KEceAaVBHXJ481k+IBonCHG1H6\resp\ba4980a8f1f639b374f05f2e7ed49c18\lid\0\final\
GameSpy: \pauthr\249190728\lid\0\final\
Client: \getpd\\pid\249190728\ptype\3\dindex\0\keys\\final\
GameSpy: \getpdr\1\lid\\pid\249190728\mod\1400723261\length\630\data\\record\3MRWZ0gyumuH4kUwtnVck2idXKbvVwTjWXCek+CYtlgQy8zk+wCGKch5zlZjRddLlAEyVwJ5C6qPcSqOITNsSGx2M35OA3CAktNrshI2DTBMlDE_ElZGH8JVmbUH7gfOJp9hhC+7BEC6z1TghszCo+1FM42HUekj4EKceXCFPtowQXBMfuT5AZ7r90pHfI6Ap1+fky6WBg12nzbf\msg\5mh1aqu8FxpzOvyEG89qmUQObpd2B4Mg\friends\5q9cqW3nQLJfyLfhLBIxY1xFF2VK0jatfd2X+wZbTJd0kIWGgPRqbPQTdnyLfoSk0THMUEBlrPnO25oUusgKU9pbkpeL+FGUXBS2zgrtY30dH9IoB1ePI_FQNnvA6ymxO8hfyfDKi0WAignrVLtOg9VIs3E9Y1Xxn1oy0ITL9R5mHSO9Y18Kh3+BXGX+uZQPHLmPSCQ+rn+DFGAoBfRo+FSTGxEm3OvxF5qhPJMuHAKh57_+fBSakSdAWtsMib+QC9U0vuPOtiVVoPZzSWVO_9sLhivIfUBdn8LIZGdMmCdw8HCkpG2wvb3jWn4o4dn_Z3XeX8kVNSO6xWaxWIZaGiZOOi63GQ03iAP3I98jmT8bsrX4\final\

I'm trying to see what the difference is between the pcap I just captured on your server versus the official server's pcap file I posted in my original comment that has me going online and completing a match against a random person online in FreePlayer mode.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

I'm not sure, but the emulation of gpcm.gs.nintendowifi.net doesn't quite match what the official server did for the game. But it could be that I no longer have buddies since erasing savedata

Filtered packets of official server:

https://www.cloudshark.org/captures/d94462c4f238?filter=tcp.port%20%3D%3D%2029900

Versus the emulation-server:

https://www.cloudshark.org/captures/f7ea3ddab8f6?filter=tcp.port%20%3D%3D%2029900

Packet 69 of official server's response to \login\ differs from how the emulation-server responded in packet 49.

Still looking for other stuff since I'm kinda thinking that if the game was able to reply the emulation-server(packet 65 in emulation-server capture) then the game isn't confused and still going forward.

@polaris-
Copy link
Collaborator

polaris- commented Jun 2, 2014

Ah, I see what the problem there is. I made a mistake in the code earlier when I added in the response for blk and bdy. I fixed it and updated the server. Try again whenever you can, please.

@polaris-
Copy link
Collaborator

polaris- commented Jun 2, 2014

Looking at your packet captures again, you actually have a lot more buddies than I could find a packet capture of before. I made an assumption before that seems to be incorrect, so that should be fixed now too! Thanks for the packet capture from the official server. :D That problem is now fixed, too.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Heh, no problem. :)

Let's see, now I get:

Error 61010

https://www.cloudshark.org/captures/d94462c4f238?filter=tcp.port%20%3D%3D%2029900

Looks closer to official but not exactly. After \login, Gamespy responds with "\blk\0\list\final"

Check out my python script's output(http://pastebin.com/raw.php?i=38uGiwY4) This script still works as of this moment. The pastebin will expire in 1 week.

    pikachu@BATTLEGYM ~/Documents/TVC_gamespy/TATVSCAP/sandbox $ python testgpcmcomm.py
    Client: \ka\\final\
    GameSpy: \lc\1\challenge\OIRCXHBOIX\id\1\final\
    Client: \login\\challenge\WueRfHcc0laFAgNzgYS2gJuuZY8kN5WJ\authtoken\NDSp+SJutMdDcX8ncs5Ox6owQXEGPWj6HzHxbtWoN1Nvu5M4IEWFLK4E0X0iRY8ARbIhi0sy/5UyDS+Bt4RLzNMx9Xs4eMMwrI2XAto6z2359MaTWjVMJmMKOdSFLMzbKil\partnerid\11\response\4568462df6b3a1e7ceae711085417c73\firewall\1\port\0\productid\11887\gamename\tatvscapwii\namespaceid\16\sdkrevision\11\quiet\1\id\1\final\
    GameSpy: \blk\0\list\\final\
    Client: \ka\\final\
    GameSpy: \bdy\18\list\247139466,247534627,247554192,248394815,248422570,249880693,251459139,252923888,259124585,303087293,316057353,320089100,347624982,359064000,364871100,365547557,381463363,382779405\final\\lc\2\sesskey\8617024\proof\8e75d4e6ee33730bbbf4320a432b32da\userid\225099072\profileid\249190728\uniquenick\1epm31js3STKJ0lo4c9r\lt\KH3kDWaA5fY4YiZtZLrbpm__\id\1\final\\bm\100\f\247139466\msg\|s|0|ss|Offline\final\\bm\100\f\247554192\msg\|s|0|ss|Offline\final\\bm\100\f\249880693\msg\|s|0|ss|Offline\final\\bm\100\f\247534627\msg\|s|0|ss|Offline\final\\bm\100\f\320089100\msg\|s|0|ss|Offline\final\\bm\100\f\259124585\msg\|s|0|ss|Offline\final\\bm\100\f\347624982\msg\|s|0|ss|Offline\final\
    Client: \ka\\final\
    Gamespy: \bm\100\f\251459139\msg\|s|0|ss|Offline\final\\bm\100\f\381463363\msg\|s|0|ss|Offline\final\\bm\100\f\252923888\msg\|s|0|ss|Offline\final\\bm\100\f\359064000\msg\|s|0|ss|Offline\final\\bm\100\f\248394815\msg\|s|0|ss|Offline\final\\bm\100\f\364871100\msg\|s|0|ss|Offline\final\\bm\100\f\248422570\msg\|s|0|ss|Offline\final\\bm\100\f\303087293\msg\|s|0|ss|Offline\final\\bm\100\f\316057353\msg\|s|0|ss|Offline\final\\bm\100\f\365547557\msg\|s|0|ss|Offline\final\\bm\100\f\382779405\msg\|s|0|ss|Offline\final\
    Client: \ka\\final\
    WARN: timed out
    Client: \status\1\sesskey\8617024\statstring\/SCM/1/SCN/0/VER/90/LCK/0\locstring\\final\
    Client: \updatepro\\sesskey\8617024\firstname\Wii:6236359535615891\aim\1epm31js3\zipcode\STKE\partnerid\11\final\
    Client: \getprofile\\sesskey\8617024\profileid\249190728\id\2\final\
    GameSpy: \pi\\profileid\249190728\nick\1epm31js3STKJ0lo4c9r\userid\225099072\email\1epm31js3stkj0lo4c9r@nds\sig\c2065cf93f0b4c2567ddfa5ecde99bbd\uniquenick\1epm31js3STKJ0lo4c9r\pid\11\firstname\Wii:6236359535615891\lastname\000000000STKJ0lo4c9r\zipcode\STKE\aim\1epm31js3\lon\0.000000\lat\0.000000\loc\\id\2\final\
    Client: \getprofile\\sesskey\8617024\profileid\259106339\id\2\final\
    GameSpy: \pi\\profileid\259106339\nick\1vqtdb9nlSTKJ1tonqhg\userid\234598763\sig\a651c90faf010d4e69e78b641061161f\uniquenick\1vqtdb9nlSTKJ1tonqhg\pid\11\firstname\Wii:7194885338688391\lastname\000000000STKJ1tonqhg\aim\1vqtdb9nl\lon\0.000000\lat\0.000000\loc\\id\2\final\
    Client: \logout\\sesskey\8617024\final\
    GameSpy: 
    pikachu@BATTLEGYM ~/Documents/TVC_gamespy/TATVSCAP/sandbox $

EDIT: tvcsecrets.gpcm_response code is...

def gpcm_response(naschallenge,tvcchallenge,gpcmchallenge,authtoken):
    responsehash = hashlib.md5(naschallenge).hexdigest()+('\x20' * 48)+\
    authtoken+tvcchallenge+gpcmchallenge+hashlib.md5(naschallenge).hexdigest()
    return hashlib.md5(responsehash).hexdigest()

@polaris-
Copy link
Collaborator

polaris- commented Jun 2, 2014

Oops. I've removed the id fields now. Those were copy/paste leftovers. :P

Could you upload another packet capture of you using the altwfc server now if it still doesn't work?

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Generic "Communication Error"

https://www.cloudshark.org/captures/be9edf4bb846

The response for \login\ on the official servers contains a \proof\ field =^/ ...that's kinda scary 'cuz I'm not entirely sure how to generate that. Checking Luigi Auriemma's docs...

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Ok...

http://aluigi.altervista.org/papers/gs_login_server.zip

The file: gs_login_proof.h

That's probably it. I'm testing it to see if I can produce the same proof hash as the ones in my various pcap files. And for TvC, anytime Luigi mentions user's password it's usually the decoded challenge that comes back from the action=login sent to the naswii

EDIT: ....oh wait... https://github.com/polaris-/dwc_network_server_emulator/blob/master/gamespy/gs_utility.py#L93

Okay, trying...

EDIT2: Hooray! That code really works. Just need that hash in a proof field in the response.

@polaris-
Copy link
Collaborator

polaris- commented Jun 2, 2014

Try again, please. I think I found the error (it was never sending the return data from the getpd command).

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 2, 2014

Excellent. TvC now goes online all the way. Error 84020 while searching for an opponent.

https://www.cloudshark.org/captures/045e79178e2c

I'm going to need to find somebody out there so that 2 of us can be searching at the same time and actually find each other for an online fight. But still, even if I'm the only one online the official servers wouldn't error so I'll be examining the packets for differences.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 3, 2014

Another TVCplayer tried using the server with Brainslug debugging console enabled. Looking at it I noticed that it didn't appear the game was getting responses to opponent-search.

Indeed...

    pikachu@BATTLEGYM ~/Documents/TVC_gamespy $  ./gslist -n tatvscapwii -Y tatvscapwii eJMWz4 -t -1 -X \\numplayers\\maxplayers\\dwc_pid\\dwc_mtype\\dwc_mver\\dwc_eval\\dwc_groupid\\dwc_hoststate\\dwc_suspend\\str\\mode\\lv\\mp\\cnt\\wrld\\

    Gslist 0.8.10a
    by Luigi Auriemma
    e-mail: aluigi@autistici.org
    web:    aluigi.org

    Gamename:    tatvscapwii
    Enctype:     -1
    Filter:
    Resolving    tatvscapwii.ms19.gamespy.com ... 69.10.30.247:28910
    Gamename:    tatvscapwii
    MSgamename:  tatvscapwii
    MSgamekey:   eJMWz4
    Random id:   103*Etgx
    Info query:  \numplayers\maxplayers\dwc_pid\dwc_mtype\dwc_mver\dwc_eval\dwc_groupid\dwc_hoststate\dwc_suspend\str\mode\lv\mp\cnt\wrld\
    Receiving:   . 169 bytes
    -----------------------

    0 servers found

    pikachu@BATTLEGYM ~/Documents/TVC_gamespy $  ./gslist -x 75.127.5.215 -n tatvscapwii -Y tatvscapwii eJMWz4 -t -1 -X \\numplayers\\maxplayers\\dwc_pid\\dwc_mtype\\dwc_mver\\dwc_eval\\dwc_groupid\\dwc_hoststate\\dwc_suspend\\str\\mode\\lv\\mp\\cnt\\wrld\\

    Gslist 0.8.10a
    by Luigi Auriemma
    e-mail: aluigi@autistici.org
    web:    aluigi.org

    Gamename:    tatvscapwii
    Enctype:     -1
    Filter:      
    Resolving    75.127.5.215 ... 75.127.5.215:28910
    Gamename:    tatvscapwii
    ^C (program hangs)

So for sure the emulation server should allow Luigi's program to work.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 3, 2014

Looks like you're working on it, I see the emulationServer beginning to reply to the gslist program and TvC no longer gives me 84020. It just searches forever(so far over 20mins).

fyi, The WII freezes up if you send it too much data for a response. In the query, the game specifies the max result rows it can handle - the official servers obeyed that limit. See screenshot highlighting the byte in question.

http://i.imgur.com/r65YVvs.png

The byte I highlighted in green shows that TvC can only handle 6 records returned to it. Go over that(about 8 or 9 records) and the game freezes.

Here's what mariokartwii looked like to gslist

Gslist 0.8.10a
by Luigi Auriemma
e-mail: aluigi@autistici.org
web:    aluigi.org

Gamename:    mariokartwii
Enctype:     -1
Filter:      
Resolving    mariokartwii.ms19.gamespy.com ... 69.10.30.247:28910
Gamename:    mariokartwii
MSgamename:  mariokartwii
MSgamekey:   9r3Rmy
Random id:   Hk=f%TGn
Info query:  \numplayers\maxplayers\dwc_pid\dwc_mtype\dwc_mver\dwc_eval\dwc_groupid\dwc_hoststate\dwc_suspend\str\mode\lv\mp\cnt\wrld\    Receiving:   ................................................................................................................. 200436 bytes
-----------------------

3061 servers found

184.57.237.26:19376 \numplayers\0\maxplayers\0\dwc_pid\278129127\dwc_mtype\0\dwc_mver\90\dwc_eval\1\dwc_groupid\0\dwc_hoststate\0\dwc_suspend\0\str\\mode\\lv\\mp\\cnt\\wrld\
60.239.82.227:23906 \numplayers\3\maxplayers\11\dwc_pid\339879582\dwc_mtype\0\dwc_mver\90\dwc_eval\1\dwc_groupid\0\dwc_hoststate\1\dwc_suspend\0\str\\mode\\lv\\mp\\cnt\\wrld\
68.51.130.49:52026 \numplayers\0\maxplayers\0\dwc_pid\355492412\dwc_mtype\0\dwc_mver\90\dwc_eval\1\dwc_groupid\0\dwc_hoststate\0\dwc_suspend\0\str\\mode\\lv\\mp\\cnt\\wrld\
24.112.67.145:55269 \numplayers\6\maxplayers\11\dwc_pid\212763010\dwc_mtype\0\dwc_mver\90\dwc_eval\1\dwc_groupid\0\dwc_hoststate\1\dwc_suspend\0\str\\mode\\lv\\mp\\cnt\\wrld\
115.39.211.203:55318 \numplayers\1\maxplayers\11\dwc_pid\357632818\dwc_mtype\2\dwc_mver\90\dwc_eval\1\dwc_groupid\463150520\dwc_hoststate\2\dwc_suspend\1\str\\mode\\lv\\mp\\cnt\\wrld\

...etc...

Also, the info that's in the list comes from what the game sends to the master server in a UDP packet.

Packet # 503 in https://www.cloudshark.org/captures/d94462c4f238

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 3, 2014

More Info, I don't see any code in this repo for encrypting/decrypting player search in TvC's format.

http://aluigi.altervista.org/papers/enctypex_decoder.c

Luigi's C code above is how it's done for TvC. That code is pretty complex and porting to python would be quite a task. As such, I went the route of using SWIG to turn that code into something python could use without calling popen2 to run the program in a separate process.

import gamespyenctypex
decrypted_data = gamespyenctypex.decryptdata(tvcsecrets.gamecdkey,arbitrarykey,ms19data,len(ms19data))
playerlist = gamespyenctypex.convert_to_ipportparams(decrypted_data,len(decrypted_data))

The variable playerlist will now contain a big string in the output format of the mariokartwii query in my previous comment. There is also an encrypt method. The arbitrarykey value is generated by the game randomly for each query; In the screenshot provide previously that particular query's encryption key is ?@(pBYzU , starting at offset 0x00000021 . The key will always be eight bytes.

If you jump to 53min-mark in my youtube video, you can see me explaining how this works with code examples and official server data:

https://www.youtube.com/watch?v=YiKnblnRCA8

If you need any assistance, I can provide the files shown in that vid so you can compile your own python module to support this part of the game.

@polaris-
Copy link
Collaborator

polaris- commented Jun 3, 2014

All of the games use the EncTypeX code for the server list response. it's in gamespy/gs_utility.py. So that's not the issue, I think.

I think the problem is that the filter is empty in the query. My server doesn't handle that properly I guess. If you specify a filter it works properly.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 4, 2014

Oh wow, that's quite a feat porting that C to python!

Emulation-server is getting very close to supporting this game. Now the problem is that my Wii isn't returned in search results.

https://www.cloudshark.org/captures/9e8a10ab8e2a

When the opponent search begins the game tells master server new state info so other WIIs can find it as well. It's in packet # 164. I understand that the game filters itself out of the results with "dwc_pid != 2287" so it doesn't try to initiate a match with itself, but then I should be able find my WII with gslist using a different filter. After waiting at least 10 seconds go by while the game searches for opponents, and I left it to continue its search, I issued the following command with a custom filter that should have returned a record for my game.

    pikachu@BATTLEGYM ~/Documents/TVC_gamespy $  ./gslist -f "dwc_pid != 0" -x 75.127.5.215 -n tatvscapwii -Y tatvscapwii eJMWz4 -t -1 -X \\numplayers\\maxplayers\\dwc_pid\\dwc_mtype\\dwc_mver\\dwc_eval\\dwc_groupid\\dwc_hoststate\\dwc_suspend\\str\\mode\\lv\\mp\\cnt\\wrld\\

    Gslist 0.8.10a
    by Luigi Auriemma
    e-mail: aluigi@autistici.org
    web:    aluigi.org

    Gamename:    tatvscapwii
    Enctype:     -1
    Filter:      dwc_pid != 0
    Resolving    75.127.5.215 ... 75.127.5.215:28910
    Gamename:    tatvscapwii
    MSgamename:  tatvscapwii
    MSgamekey:   eJMWz4
    Random id:   UDw^)Hk=
    Info query:  \numplayers\maxplayers\dwc_pid\dwc_mtype\dwc_mver\dwc_eval\dwc_groupid\dwc_hoststate\dwc_suspend\str\mode\lv\mp\cnt\wrld\
    Receiving:   . 168 bytes
    -----------------------

    0 servers found

Once I verify that the above gslist command returns my WII as an available server, next will be actually starting an online battle and see how that goes.

@polaris-
Copy link
Collaborator

polaris- commented Jun 5, 2014

If you can get it to the point where it accepts packets from the natneg server then it should work I think. You're just barely a step away from getting it to work. All that's left is that natneg needs to give both clients packets so they can try connecting to each other. The next possible point of failure is that one or both of the clients do not have their network setup in a way that allows for the UDP ports to be opened as needed. If both clients can successfully communicate with each other then it should technically work, assuming the game doesn't disconnect you due to lag or something like that.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 6, 2014

okay, figured out how I solved the ICMP thing to capture the official servers.

sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv4.conf.all.secure_redirects=0
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.all.send_redirects=0
sysctl -w net.ipv4.conf.wlan0.accept_redirects=0
sysctl -w net.ipv4.conf.wlan0.secure_redirects=0
sysctl -w net.ipv4.conf.wlan0.send_redirects=0
sysctl -w net.ipv4.conf.eth0.accept_redirects=0
sysctl -w net.ipv4.conf.eth0.secure_redirects=0
sysctl -w net.ipv4.conf.eth0.send_redirects=0

Even closer than yesterday, the two WIIs actually started talking to each other, just like the official-server pcap file, before getting generic "Communication error" after an abnormally long wait.

https://www.cloudshark.org/captures/6a99e641e28e
and
https://www.cloudshark.org/captures/e1b260e8dcd2

Once again I'm comparing these pcap files to the official servers.

EDIT:

Just fyi, the IPaddress that begins with 50. in your server-logs is me. ...and both WIIs showed the message "Opponent found." So they're really both aware of what's happening.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 6, 2014

Hmm... potential difference. In the first pcap in my previous comment, packet # 335 to 349 . That little back 'n forth between my WII and the emulation-server that's a constant 115 byte UDP packets looks suspicious. In the official-server pcap, packet # 611 ...the UDP packet of 115 bytes is sent once by my WII and the natneg responds once with a 63 byte packet. After that it appears my WII just continues on to communicate directly with the other WII and the fight goes on. No more talk with the natneg servers.

@polaris-
Copy link
Collaborator

polaris- commented Jun 6, 2014

Alright. I've modified the server to respond properly during the 115 byte packet part.

If the packet response is as expected and it still gives you a "communication error" then I think you should try playing with someone else since it's most likely a connection problem at that point.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 7, 2014

Closer, starting at packet # 273

https://www.cloudshark.org/captures/f76c22bb4f6c

Now I get opponent found and error 91010 at the exact time the Wii-to-Wii connection would have completed and both Wiis shown the player names of the match; e.g. "Bob vs. Alice". I see the change in the UDP packets to be a bit closer to the official-servers but the back-n-forth of 115-byte UDP packets still end up happening. It appears to me that the emulation-server's UDP reply, at packet # 274, is 62 bytes. One byte shorter than what is found in the official-server capture at packet # 612.... but then the emulation-server quickly follows it with a proper sized packet. It appears the WII asks again 2 more times or so.... then we're back to the 115 byte UDP exchange.
Also, even though the 62 byte packet is shorter the actual bytes in it look more correct than the 63 byte one, which is the correct size but significantly different from what the official server sent.

Since this change altered what happened after "Opponent found" I'm feeling more confident that getting those UDP packets perfectly in sync with the official servers' pcap example will allow me to fight someone.

@polaris-
Copy link
Collaborator

polaris- commented Jun 7, 2014

I see the problem. I forgot to change the buffer sent to the client, even though I made the buffer. You'll have to wait for the server to come back up before it can be tested, though. :(

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

Oh dear,

https://www.cloudshark.org/captures/9af246e37b4d
and
https://www.cloudshark.org/captures/18cea3d63acf

Generic "Communication Error" after opponent found. Nothing jumps out at me as incorrect here, but I'll keep searching & trying...

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

I think I see it. I had to decode the XOR data. The 2nd pcap file I mentioned, TCP stream starting at packet # 542

\lc\1\challenge\VAREPWGDAQ\id\1\final\
\auth\\gamename\tatvscapwii\response\a077aa0e61f9e5fe0e28dbdafabf944e\port\0\id\1
\lc\2\sesskey\5560796469\proof\0\id\1\final\
\authp\\authtoken\NDSEZOIDVGmVKKzdtKhjdmcbsIveWVWhF6OMMiYTGuQDbHflan4X1K27Z31KvQ8jF84GdXrjtwaSGq2P1Xg\resp\c4d5d910704d662ce17dcf4974c03c64\lid\0\final\
\pauthr\2523\lid\0\final\
\getpd\\pid\2523\ptype\3\dindex\0\keys\�record\lid\0\final\

I don't see a reply to this getpd query. Also note that there's a 0x01 just before the "r" in record. That's normal, the game can ask for multiple things and it's delimited by 0x01.

Here's an example of what the official servers did for this game.

\lc\1\challenge\JPQMDSNFCR\id\1\final\
\auth\\gamename\tatvscapwii\response\0271b171b8cdedfc1c069ca1dafadde4\port\0\id\1\final\
\lc\2\sesskey\1030454987\proof\0\id\1\final\
\authp\\authtoken\NDSKO+C1qtnOjY5okmGL+Cbju9bEMBBFVFFINp4B1zvx9BUPOc4dVEGfDk04uaBAK/3xy9/PycuqpKV1VgJSVDKiuoEwPNTfS6LrNxQP1k44OMd1rWJBDecZxvLbd7mdtkq\resp\a0a1ee87eeb2b2025a5e07116ebbc3f6\lid\0\final\
\pauthr\249190728\lid\0\final\
\getpd\\pid\249190728\ptype\3\dindex\0\keys\�record\lid\0\final\
\getpdr\1\lid\0\pid\249190728\mod\1333250100\length\216\data\\record\3MRWZ0gyumuH4kUwtnVck2idXKbvVwTjWXCek+CYtlgQy8zk+wCGKch5zlZjRddLlAEyVwJ5C6qPcSqOITNsSGx2M35OA3CAktNrshI2DTBMlDE_ElZGH8JVmbUH7gfOJp9hhC+7BEC6z1TghszCo+1FM42HUekj4EKceXCFPtowQXBMfuT5AZ7r90pHfI6Ap1+fky6WBg12nzbf\final\

There's nothing about that record string that ties it to a profile id. I can take any other players record string and give it to any profileID; giving the target profileID all the online stats of the source profileID.

@polaris-
Copy link
Collaborator

polaris- commented Jun 8, 2014

I saw an exception at that point which stopped it from sending the response. I've tried fixing it. Please test the server again when you have a chance.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

I'm using python to test this. It appears that after I did a setpd to the profileID, getpd on the same id doesn't work anymore. I get socket timeout.

\getpd\\pid\2120\ptype\3\dindex\0\keys\\final\

The socket is set to wait 10 seconds. This probably is part of the reason we have to delete userdata everytime before going online. Before I got error 60000, but after removing the savedata from the official-server I just get a generic Communication error after a long wait unless I delete userdata. If I delete the userdata, the game will just do a setpd because it knows getpd can't have anything for a profileid that was just created. But if the game has userdata, it'll try to fetch the profileid's stats using getpd.

The versus screen that comes after "Opponent found. Now connecting.." displays the player stats of both players, so the game needs getpd to work.

@polaris-
Copy link
Collaborator

polaris- commented Jun 8, 2014

Here's what it said when you did that:
[2014-06-08 10:12:00 | GameSpyGamestatsServer] STATS RESPONSE: \getpd\pid\2120\ptype\3\dindex\0\keys\final
[2014-06-08 10:12:00 | GameSpyGamestatsServer] [50.x.x.x:53753 | 9676136640 | tatvscapwii] Could not find profile for 2120 0 3
[2014-06-08 10:12:00 | GameSpyGamestatsServer] [50.x.x.x:53753 | 9676136640 | tatvscapwii] Could not get data section from profile for 2120
[2014-06-08 10:12:00 | GameSpyGamestatsServer] [50.x.x.x:53753 | 9676136640 | tatvscapwii] SENDING: '\getpdr\1\lid\0\pid\2120\mod\1402236720\length\0\data\final'...

Did you not get that response? It should have been sent.

You will only get a 60000 when the authorization step fails. I think that only applies to the profile server as well, not the gamestats server. So that's an unrelated problem.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

I did get a getpdr the first time, before I did a setpd... but after applying a setpd to a profileID, getpd no longer works for that ID. Also, I suspect that not sending back any record string will be a problem for the online match because that situation can never happen for the official servers. A new account would get a setpd applied to it at the beginning before reaching any of the online fighting options in the game's menu.

I can upload my test code if that's needed.

I've ran the test code a few times since this comment, so hopefully there's something on the server logs showing what's happening.

@polaris-
Copy link
Collaborator

polaris- commented Jun 8, 2014

Please upload your test code.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

http://pastebin.com/raw.php?i=wW8aptGy

And the module tvcsecrets is:

http://pastebin.com/raw.php?i=8yvbnnxf

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

Sorry about the typo in getpd

getpd_cmd = r"\getpd\\pid\MYPID\ptype\3\dindex\0\keys\\final"+"\\"

That "dindex", ...the "d" should be removed. Even after fixing that, the timeout issue remains.

EDIT:

The setpd_cmd has the same typo.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

Oh wait.... the official game does "dindex"... how odd, I guess they're not typos then.

@polaris-
Copy link
Collaborator

polaris- commented Jun 8, 2014

It should work now. The problem was that TvC has a \ at the end of the data field, while all of the other games I've tested so far don't have a trailing . The trailing \ broke the parser so it wouldn't return the data.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

The test code still times out for me. I'll wait a bit; perhaps the server hasn't been restarted yet.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

Oh nevermind, it works. I forgot to put the extra "d" back into index for get/setpd.

@polaris-
Copy link
Collaborator

polaris- commented Jun 8, 2014

Hop on IRC if you want to get some test games going. I've got 2 people testing now.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Jun 8, 2014

Great success, it works. Just did 2 matches in freebattle.

Thank you for all the work.... if I find a bug somewhere else in the game I'll make a new ticket, but this issue is solved! 👍

@jonydark
Copy link

Hello Polaris

Yesterday I Tried to play TVC over Polaris, but didn´t get in it.........................have you made some changes or something in recent days??? That thing was awesome and working sharply, but no longer works?? Just want to know if Polaris will gonna be online anytime?? Or Nintendo banned you???

Thxs See ya

Jonathan, JG

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Aug 21, 2014

@jonydark

There is no "Nintendo banned". None of this stuff is under Nintendo's control anymore. What happens when you try to go online? Error message?

@jonydark
Copy link

when I try to change settings to 75.127.5.215  don´t connect to anything!!!
It is strange 'cause in the past (I mean 10 days ago) I could get in very frequently.
:(

El Jueves, 21 de agosto, 2014 0:17:00, "smtddr @ youtube, twitter, twitch.tv, hackernews" notifications@github.com escribió:

@jonydark
There is no "Nintendo banned". None of this stuff is under Nintendo's control anymore. What happens when you try to go online? Error message?

Reply to this email directly or view it on GitHub.

@SMTDDR
Copy link
Contributor Author

SMTDDR commented Aug 21, 2014

@jonydark

...And the error message is? Step by step, what happens? Don't leave out any details.

@mm201
Copy link

mm201 commented Aug 21, 2014

The server is down right now. Please be patient.

@jonydark
Copy link

OK I will.

But honestly I don´t know what´s going on over Wiimmfi too who always is working and also TVC game is not working yet, at the time I get into "Wi- Fi Battle" and then "Downloading Data" it stays there and shows an error kind of:

"error code 92070
Communication error
You have been disconnected from Nintendo Wi-Fi Connection
Please Try Again"

Also I deleted my old FC but since 5 days is showing this error, the functionality and test I supposed have ended, so...............What the hell is going on??

Thank you!!!
:)

El Jueves, 21 de agosto, 2014 16:39:31, mm201 notifications@github.com escribió:

The server is down right now. Please be patient.

Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants