forked from kinnay/NintendoClients
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_smm_server.py
715 lines (618 loc) · 31.2 KB
/
example_smm_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
from typing import List
from nintendo.nex import backend, service, kerberos, \
authentication, secure, datastoresmm, common, messagedelivery, streams
from nintendo.games import SMM
import collections
import itertools
import secrets
import time
import argparse
import logging
import base64
import json
import jsons
import copy
from smm_dataprovider import SmmDataProvider
import pathlib
# https://stackoverflow.com/a/44175370/1806760
logging.basicConfig(
format="[%(asctime)s] %(levelname)s: %(message)s",
level=logging.INFO,
datefmt="%Y-%m-%d %H:%M:%S")
logger = logging.getLogger(__name__)
User = collections.namedtuple("User", "pid name password")
users = [
User(1, "unknown", "password"),
User(2, "Quazal Rendez-Vous", "password"),
User(100, "guest", "MMQea3n!fsik"),
User(1337, "1337", "password"),
# More accounts here
]
def get_user_by_name(name):
for user in users:
if user.name == name:
return user
def get_user_by_pid(pid):
for user in users:
if user.pid == pid:
return user
def derive_key(settings, user):
if settings.get("kerberos.key_derivation") == 0:
key_derivation = kerberos.KeyDerivationOld(65000, 1024)
else:
key_derivation = kerberos.KeyDerivationNew(1, 1)
return key_derivation.derive_key(user.password.encode("ascii"), user.pid)
SECURE_SERVER = "Quazal Rendez-Vous"
class AuthenticationServer(authentication.AuthenticationServer):
def __init__(self, settings, secure_host, secure_port):
super().__init__()
self.settings = settings
self.secure_host = secure_host
self.secure_port = secure_port
def login_ex(self, context, username, extra_data):
return self.login(context, username)
def login(self, context, username):
logger.info("User trying to log in: {}".format(username))
user = get_user_by_name(username)
if not user:
logger.error("Did you check Options -> General settings -> Account -> 'Enable online mode' in Cemu?")
raise common.RMCError("RendezVous::InvalidUsername")
server = get_user_by_name(SECURE_SERVER)
url = common.StationURL(
scheme="prudps", address=self.secure_host, port=self.secure_port,
PID=server.pid, CID=1, type=2,
sid=1, stream=10
)
conn_data = authentication.RVConnectionData()
conn_data.server_time = common.DateTime.fromtimestamp(time.time())
conn_data.main_station = url
conn_data.special_protocols = []
conn_data.special_station = common.StationURL()
response = common.RMCResponse()
response.result = common.Result(0x10001) # Success
response.pid = user.pid
response.ticket = self.generate_ticket(user, server)
response.connection_data = conn_data
response.server_name = "branch:origin/project/wup-ama build:3_8_27_3022_0"
return response
def request_ticket(self, context, source, target):
source = get_user_by_pid(source)
target = get_user_by_pid(target)
response = common.RMCResponse()
response.result = common.Result(0x10001) # Success
response.ticket = self.generate_ticket(source, target)
return response
def generate_ticket(self, source, target):
settings = self.settings
user_key = derive_key(settings, source)
server_key = derive_key(settings, target)
session_key = secrets.token_bytes(settings.get("kerberos.key_size"))
internal = kerberos.ServerTicket()
internal.expiration = common.DateTime.fromtimestamp(time.time() + 120)
internal.source_pid = source.pid
internal.session_key = session_key
ticket = kerberos.ClientTicket()
ticket.session_key = session_key
ticket.target_pid = 1
ticket.internal = internal.encrypt(server_key, settings)
return ticket.encrypt(user_key, settings)
class SecureConnectionServer(secure.SecureConnectionServer):
def __init__(self):
super().__init__()
self.connection_id = itertools.count(10)
def register(self, context, urls):
addr = context.client.remote_address()
station = urls[0].copy()
station["address"] = addr[0]
station["port"] = addr[1]
station["type"] = 3
response = common.RMCResponse()
response.result = common.Result(0x10001) # Success
response.connection_id = next(self.connection_id)
response.public_station = station
return response
def register_ex(self, context, urls, login_data):
return self.register(context, urls)
class DataStoreSmmServer(datastoresmm.DataStoreSmmServer):
def __init__(self, settings):
super(DataStoreSmmServer, self).__init__()
self.settings = settings
self.data_provider = SmmDataProvider(self.settings)
def dump(self, data):
return json.dumps(jsons.dump(data))
def get_meta(self, context, param):
logger.info(f"param: {self.dump(param)}")
if param.data_id == 0: # mii data
owner_id = param.persistence_target.owner_id
res = self.data_provider.get_mii_data_pid(owner_id)
if not res:
logger.info("get_meta, no info for {}, using fake 1781058687".format(owner_id))
res = self.data_provider.get_mii_data_pid(1781058687)
res = copy.deepcopy(res.meta_info)
res.owner_id = param.persistence_target.owner_id
res.tags = []
res.ratings = []
logger.info("res: %s" % json.dumps(jsons.dump(res)))
return res
elif param.data_id == 900000: # when you click 'Play' this is requested, appears to be some dummy data
res = datastoresmm.DataStoreMetaInfo()
res.data_id = 900000
res.owner_id = 2
res.size = 450068
res.name = ""
res.data_type = 50
res.meta_binary = b""
res.permission = datastoresmm.DataStorePermission()
res.permission.permission = 0
res.permission.recipients = []
res.delete_permission = datastoresmm.DataStorePermission()
res.delete_permission.permission = 0
res.delete_permission.recipients = []
res.create_time = common.DateTime(0x1F7EC8FC86)
res.update_time = common.DateTime(0x1F86A20516)
res.period = 0xFB32
res.status = 0
res.referred_count = 0
res.refer_data_id = 0
res.flag = 0x100
res.referred_time = res.create_time
res.expire_time = common.DateTime(0x9C3F3E0000)
res.tags = []
res.ratings = []
logger.info("res: %s" % json.dumps(jsons.dump(res)))
return res
else:
logger.warning("DataStoreSmmServer.get_meta not implemented (data_id: {})".format(param.data_id))
raise common.RMCError("DataStore::NotFound")
def prepare_post_object(self, context, param):
logger.info("param: %s" % json.dumps(jsons.dump(param)))
info = datastoresmm.DataStoreReqPostInfo()
info.data_id = 1337
info.url = "http://account.nintendo.net/post"
info.headers = []
info.form = []
info.root_ca_cert = b""
return info
def prepare_attach_file(self, context, param):
logger.info("param: %s" % json.dumps(jsons.dump(param)))
return self.prepare_post_object(context, param.unk1)
def complete_attach_file(self, context, param):
logger.info("param: %s" % json.dumps(jsons.dump(param)))
return "kurwa"
def complete_post_object(self, context, param):
logger.info("param: %s" % json.dumps(jsons.dump(param)))
def get_req_info(self, data_id):
res = datastoresmm.DataStoreReqGetInfo()
res.root_ca_cert = b""
res.data_id = data_id
res.headers = []
if data_id == 900000:
res.url = "http://account.nintendo.net/datastore/00000900000-00045"
res.size = 450068 # hardcoded event course
else: # course download url by data_id
course_data: datastoresmm.DataStoreCustomRankingResult
course_data = self.data_provider.get_course_data(data_id)
if not course_data:
raise common.RMCError("DataStore::NotFound")
res.url = self.data_provider.get_course_url(data_id)
if not res.url:
raise common.RMCError("DataStore::NotFound")
res.size = course_data.meta_info.size
return res
def prepare_get_object(self, context, param):
logger.info("param: %s" % json.dumps(jsons.dump(param)))
res = self.get_req_info(param.data_id)
logger.info("res: %s" % json.dumps(jsons.dump(res)))
return res
def get_file_server_object_infos(self, context, params):
logger.info("params: {}".format(json.dumps(params)))
infos = []
for data_id in params:
info = datastoresmm.DataStoreFileServerObjectInfo()
info.data_id = data_id
info.info = self.get_req_info(data_id)
infos.append(info)
return infos
def get_metas_multiple_param(self, context, params: List[datastoresmm.DataStoreGetMetaParam]):
logger.info("params: %s" % json.dumps(jsons.dump(params)))
res = common.RMCResponse()
res.result = common.Result(0x10001) # Success
res.infos = []
res.results = []
if not params: # empty params -> empty response (wtf, smm actually sends this request)
pass
else: # get mii data in bulk
data: datastoresmm.DataStoreGetMetaParam
for data in params:
if data.result_option in [4, 0]: # mii data (TODO: 0 isn't verified)
# TODO: somehow involve the disk database to have proper mii names for course creators
mii_data = self.data_provider.get_mii_data_pid(data.persistence_target.owner_id)
if not mii_data:
raise common.RMCError("DataStore::NotFound")
mii_data = copy.deepcopy(mii_data.meta_info)
mii_data.tags = []
mii_data.ratings = []
res.infos.append(mii_data)
res.results.append(common.Result(0x690001))
elif data.result_option == 6: # event courses
# TODO: implement
pass
else:
logger.critical(f"result_option: {data.result_option}")
raise common.RMCError("Core::NotImplemented")
return res
def change_meta(self, context, param):
logger.info("param: %s" % json.dumps(jsons.dump(param)))
def rate_objects(self, context, targets, params, transactional, fetch_ratings):
"""
Adds to the rating slot for either course or mii info
"""
logger.info("targets: %s\nparams: %s\ntransactional: %s\nfetch_ratings: %s" % (json.dumps(jsons.dump(targets)), json.dumps(jsons.dump(params)), transactional, fetch_ratings))
res = common.RMCResponse()
res.result = common.Result(0x10001) # Success
res.ratings = []
res.results = []
for i in range(0, len(targets)):
rating = datastoresmm.DataStoreRatingInfo()
rating.initial_value = 0
rating.total_value = rating.count = params[i].rating_value
res.results.append(common.Result(0x690001))
return res
def rate_custom_ranking(self, context, param):
logger.info("param: %s" % json.dumps(jsons.dump(param)))
def get_custom_ranking_by_data_id(self, context, param):
"""
Appears to get Mii data, but with SMM ratings(?) and tags
It also gets course metadata?
Rating slot information (for Mii/player data):
0: 1529 1529 -> courses played / courses played
1: 1153 1153 -> courses cleared / courses cleared
2: 608 608 -> unknown / unknown
3: 5732 1529 -> total plays / courses played
4: 4579 1529 -> lives lost / courses played
5: 0 0 -> normal clears / normal clears
6: 0 0 -> unknown
7: 1 1 -> easy clears / easy clears
8: 0 0 -> unknown
Tag is a country string. Known values:
["1"] -> Japan
["97"] -> Poland
["49"] -> USA
["77"] -> France
["78"] -> Germany
Rating slot information (for Courses):
0: 40 40 plays / plays
1: 843 40
2: 38 40 clears / plays
3: 59 40 attempts / plays
4: 21 40 fails / plays
5: 39 39 recent players / recent players
6: 0 0 shared / shared (uncertain)
"""
logger.info("param: %s" % json.dumps(jsons.dump(param)))
if param.result_option != 0x27: # Game version?
logger.info("unknown version!")
raise common.RMCError("DataStore::InvalidArgument")
res = common.RMCResponse()
res.result = common.Result(0x10001) # Success
res.infos = []
res.results = []
def rating_slot(slot, total_value, count, initial_value):
rating = datastoresmm.DataStoreRatingInfoWithSlot()
rating.slot = slot
rating.info = datastoresmm.DataStoreRatingInfo()
rating.info.total_value = total_value
rating.info.count = count
rating.info.initial_value = initial_value
return rating
if param.application_id == 300000000: # Mii data with SMM ratings
for data_id in param.data_ids:
mii_data: datastoresmm.DataStoreCustomRankingResult
mii_data = self.data_provider.get_mii_data_id(data_id)
if not mii_data:
logger.info("get_custom_ranking_by_data_id(mii) unknown data_id: {}".format(data_id))
raise common.RMCError("DataStore::NotFound")
res.infos.append(mii_data)
res.results.append(common.Result(0x690001))
elif param.application_id == 0: # Course metadata?
if not param.data_ids:
# TODO: implement (bookmarks?)
param.data_ids = [10000000200]
for data_id in param.data_ids:
# definitely involve course metadata!
course_data: datastoresmm.DataStoreCustomRankingResult
course_data = self.data_provider.get_course_data(data_id)
if not course_data:
logger.info("get_custom_ranking_by_data_id(course) unknown data_id: {}".format(data_id))
raise common.RMCError("DataStore::NotFound")
res.infos.append(course_data)
res.results.append(common.Result(0x690001))
else:
logger.info("unknown magic!")
raise common.RMCError("DataStore::InvalidArgument")
#logger.info("res: %s" % json.dumps(jsons.dump(res)))
return res
# called when a course is completed
def add_to_buffer_queues(self, context, params: List[datastoresmm.BufferQueueParam], buffers: List[bytes]):
"""
if you die in a course your last death will be in unknown2[2]
the first two parameters are unclear
"""
logger.info(f"params: {self.dump(params)}\nbuffers: {self.dump(buffers)}")
res = []
for i in range(0, len(params)):
res.append(common.Result(0x690001))
return res
# called if you click 'Course World'
# also called before you start a course
# it looks like coordinates of where people died (those red crosses)
# this information appears to be provided by add_to_buffer_queues (in the third parameter of unknown2?)
def get_buffer_queue(self, context, param: datastoresmm.BufferQueueParam):
logger.info(f"param: {self.dump(param)}")
if param.slot == 0: # potentially data ids?
#TODO: implement (starred courses)
logger.info("slot==0")
res = []
data_id = 10000000200 # data_id of starred course
res.append(data_id.to_bytes(8, byteorder='little'))
elif param.slot == 3: # locations where players last died before they finished the course
self.data_provider.mark_course_played(param.data_id) # this also happens to be the point where you know someone played a course
res = self.data_provider.get_unkdata(param.data_id)
if res is None:
logger.info("get_buffer_queue, fake unknown data (empty)")
res = []
else:
logger.warning("DataStoreSmmServer.get_buffer_queue not implemented (data_id: {})".format(param.data_id))
raise common.RMCError("DataStore::NotFound")
logger.info("res: %s" % json.dumps(jsons.dump(res)))
return res
def get_application_config(self, context, param):
logger.info("get_application_config({})".format(param))
if param == 0:
res = [0x1, 0x32, 0x96, 0x12C, 0x1F4, 0x320, 0x514, 0x7D0, 0xBB8, 0x1388, 0xA, 0x14, 0x1E, 0x28, 0x32, 0x3C, 0x46, 0x50, 0x5A, 0x64, 0x23, 0x4B, 0x23, 0x4B, 0x32, 0x0, 0x3, 0x3, 0x64, 0x6, 0x1, 0x60, 0x5, 0x60, 0x0, 0x7E4, 0x1, 0x1, 0xC, 0x0]
elif param == 1:
# Event courses?
res = [0x2, 0x6982CC70, 0x6982CC50, 0x6982CC38, 0x6982D0DB, 0x6982D0A9, 0x6982D089, 0x6982C459, 0x6982C436]
elif param == 2:
res = [0x7DF, 0xC, 0x16, 0x5, 0x0]
else:
raise common.RMCError("DataStore::InvalidArgument")
logger.info("res: {}".format(repr(res)))
return res
def recommended_course_search_object(self, context, unknown1, unknown2):
"""
Function related to 100 Mario Challenge and course browser
Observed values:
["1", "0", "34", "", "0"] # easy
["1", "0", "29", "", "0"] # easy(?) (conditions unknown)
["1", "0", "74", "", "0"] # normal
["1", "0", "69", "", "0"] # normal(?) (conditions unknown)
["1", "75", "95", "", "0"] # expert
["1", "70", "100", "", "0"] # expert(?) (conditions unknown)
["1", "96", "100", "", "0"] # super expert
Rambo6Glaz derived the following:
Maybe it's the minimum and maximum clear rate for the difficulty
Or fail rate
Easy: 0-34% fails
Normal: 0-74% people failed
Expert: 75-95%
Super expert: 95-100%
It would actually make sense considering the average success rate for expert and super-expert.
For the last course of easy it looks like:
["1", "0", "34", "", "0", "12"]
so far it is unclear what this parameter is about
When using course browser (highlights):
["", "", "", "0", "0"] # Filter: all
["1", "0", "34", "0", "0"] # Filter: easy
["1", "35", "74", "0", "0"] # Filter: normal
["1", "75", "95", "0", "0"] # Filter: expert
["1", "96", "100", "0", "0"] # Filter: super expert
"""
logger.info("unknown1: %s\nunknown2: %s" % (json.dumps(jsons.dump(unknown1)), json.dumps(jsons.dump(unknown2))))
if len(unknown2) >= 5 and unknown2[0] in ["", "1"] and unknown2[4] == "0":
if unknown2[3] == "":
# Little bit of a hack, in the wild different values have been observed (see method comment).
# The workaround is to check if the difficulty parameter is 'close', which might work.
def is_close(a, b):
return abs(a - b) <= 10
fail_rate_min, fail_rate_max = int(unknown2[1]), int(unknown2[2])
logger.info("min: {}, max: {}".format(fail_rate_min, fail_rate_max))
logger.info("detected 100 mario")
if is_close(fail_rate_min, 0) and is_close(fail_rate_max, 34): # easy
difficulty = 0
elif is_close(fail_rate_min, 0) and is_close(fail_rate_max, 74): # normal
difficulty = 1
elif is_close(fail_rate_min, 75) and is_close(fail_rate_max, 95): # expert
difficulty = 2
elif is_close(fail_rate_min, 96) and is_close(fail_rate_max, 100): # super expert
difficulty = 3
else:
raise common.RMCError("DataStore::InvalidArgument")
# Use the random course ids from disk
return self.data_provider.get_random_courses_by_difficulty(difficulty, 50)
elif unknown2[3] == "0":
logger.info("detected course browser (highlights, normal)")
return self.data_provider.get_random_courses_by_difficulty(1, 10)
else:
logger.info("recommended_course_search_object with unexpected unknown2 parameter")
raise common.RMCError("DataStore::InvalidArgument")
def followings_latest_course_search_object(self, context, param: datastoresmm.DataStoreSearchParam, extra_data: List[str]):
logger.info(f"param: {self.dump(param)}, extra_data: {self.dump(extra_data)}")
if extra_data == ["0", "3", "10", "4", "11", "5", "12", "6", "13", "7", "14", "8", "15"]:
if param.owner_pids == [1337]:
# TODO: implement (uploaded course metadata)
res = []
return res
else:
# TODO: implement (uploaded courses from user)
logger.error("followings_latest_course_search_object with unknown pids {}".format(param.owner_pids))
res = []
return res
else:
logger.info("followings_latest_course_search_object with unexpected extra_data parameter")
raise common.RMCError("DataStore::InvalidArgument")
def latest_course_search_object(self, context, unknown1, unknown2):
# TODO: implement (Courses -> New Arrivals)
logger.info("unknown1: {}\nunknown2: {}".format(json.dumps(jsons.dump(unknown1)), json.dumps(jsons.dump(unknown2))))
res = []
return res
def best_score_rate_course_search_object(self, context, unknown1, unknown2):
# TODO: implement (Courses -> Star Ranking)
logger.info("unknown1: {}\nunknown2: {}".format(json.dumps(jsons.dump(unknown1)), json.dumps(jsons.dump(unknown2))))
res = []
return res
def method49(self, context, unknown):
# TODO: implement (Makers -> Star Ranking)
logger.info(f"unknown: {json.dumps(jsons.dump(unknown))}")
res = common.RMCResponse()
res.result = common.Result(0x10001) # Success
res.infos = []
res.results = []
return res
def score_range_cascaded_search_object(self, context, unknown1, unknown2):
# TODO: implement (100 mario v16)
logger.error("Super Mario Maker version 16 is not working properly, please install version 272!")
logger.info("unknown1: {}\nunknown2: {}".format(json.dumps(jsons.dump(unknown1)), json.dumps(jsons.dump(unknown2))))
res = []
return res
def upload_course_record(self, context, param):
logger.info("param: {}".format(json.dumps(jsons.dump(param))))
def get_course_record(self, context, param):
"""
Method that fetched the current record
"""
logger.info("get_course_record({})".format(json.dumps(jsons.dump(param))))
if param.unk2 == 0:
ranking = self.data_provider.get_ranking(param.data_id)
if not ranking:
logger.info("get_course_record, fake ranking")
res = datastoresmm.CourseRecordInfo()
res.data_id = param.data_id
res.unk2 = 0 # uncleared?
res.first_clear_pid = 1781058687
res.world_record_pid = 1781058687
res.world_record = 40320
res.first_clear_date = common.DateTime(0x6A28CC7F) # or null for uncleared date?
res.world_record_date = common.DateTime(0x6A28CC7F)
return res
else:
return ranking
else:
logger.info("get_course_record with unexpected unk2")
raise common.RMCError("DataStore::InvalidArgument")
def get_application_config_string(self, context, param):
"""
Probably a function related to a word blacklist.
"""
logger.info("param: %u (0x%X)" % (param, param))
if param == 128:
res = [u"けされ", u"消され", u"削除され", u"リセットされ", u"BANされ", u"BANされ", u"キミのコース", u"君のコース", u"きみのコース", u"い い ね", u"遊びます", u"地震", u"震災", u"被災", u"津波", u"バンされ", u"い~ね", u"震度", u"じしん", u"banされ", u"くわしくは", u"詳しくは", u"ちんちん", u"ち0こ", u"bicth", u"い.い.ね", u"ナイ~ス", u"い&い", u"い-いね", u"いぃね", u"nigger", u"ngger", u"star if u", u"Star if u", u"Star if you", u"star if you", u"PENlS", u"マンコ", u"butthole", u"LILI", u"vagina", u"vagyna", u"うんち", u"うんこ", u"ウンコ", u"Iine", u"EENE", u"まんこ", u"ウンチ", u"niglet", u"nigglet", u"please like", u"きんたま", u"Butthole", u"llね", u"iいね", u"give a star", u"ちんぽ", u"亀頭", u"penis", u"ウンコ", u"plz more stars", u"star plz", u"い()ね", u"PLEASE star", u"Bitte Sterne"]
elif param == 129:
res = [u"ゼロから", u"0から", u"0から", u"い い ね", u"いい", u"東日本", u"大震"]
elif param == 130:
res = [u"いいね", u"下さい", u"ください", u"押して", u"おして", u"返す", u"かえす", u"星", u"してくれ", u"するよ", u"☆くれたら", u"☆あげます", u"★くれたら", u"★あげます", u"しね", u"ころす", u"ころされた", u"アナル", u"ファック", u"キンタマ", u"○ね", u"キチガイ", u"うんこ", u"KITIGAI", u"金玉", u"おっぱい", u"☆おす", u"☆押す", u"★おす", u"★押す", u"いいする", u"いいよ", u"イイネ", u"ケツ", u"うんち", u"かくせいざい", u"覚せい剤", u"シャブ", u"きんたま", u"ちんちん", u"おしっこ", u"ちんぽこ", u"ころして", u"グッド", u"グット", u"レ●プ", u"バーカ", u"きちがい", u"ちんげ", u"マンコ", u"まんこ", u"チンポ", u"クズ", u"ウンコ", u"ナイスおねがいします", u"penis", u"イイね", u"☆よろ"]
else:
logger.info("get_application_config_string with unknown parameter")
raise common.RMCError("DataStore::InvalidArgument")
return res
def get_metas_with_course_record(self, context, unknown, get_meta_param):
logger.info("unknown: {}".format(json.dumps(jsons.dump(unknown))))
logger.info("get_meta_param: {}".format(json.dumps(jsons.dump(get_meta_param))))
res = common.RMCResponse()
res.result = common.Result(0x10001) # Success
res.infos = []
res.unknown = []
res.results = []
if unknown == [] and get_meta_param.data_id == 0 and get_meta_param.result_option == 4:
# TODO: implement (nobody knows)
res.infos.append(self.data_provider.get_course_data(10000000200))
record = datastoresmm.CourseRecordInfo()
record.data_id = 10000000200 # TODO
record.unk2 = 0 # uncleared?
record.first_clear_pid = 1781058687
record.world_record_pid = 1781058687
record.world_record = 40320
record.first_clear_date = common.DateTime(0x6A28CC7F) # or null for uncleared date?
record.world_record_date = common.DateTime(0x6A28CC7F)
res.unknown.append(record)
res.results.append(common.Result(0x690001))
pass
else:
logger.info("UNSUPPORTED")
logger.info("res: %s" % json.dumps(jsons.dump(res)))
return res
def check_rate_custom_ranking_counter(self, context, unk1):
logging.info("dummy check_rate_custom_ranking_counter({})".format(unk1))
return True
def get_deletion_reason(self, context, param):
logger.info("param: {}".format(json.dumps(jsons.dump(param))))
res = []
for data_id in param:
res.append(0x80690007)
return res
class MessageDeliveryServer(messagedelivery.MessageDeliveryServer):
def __init__(self, settings):
super(MessageDeliveryServer, self).__init__()
self.settings = settings
def deliver_message(self, context, message):
logger.info(f"message: {json.dumps(jsons.dump(message))}")
class MessageRecipient:
def load(self, stream: streams.StreamIn):
self.recipient_type = stream.u16()
self.principal_id = stream.pid()
self.gathering_id = stream.u32()
def save(self, stream: streams.StreamOut):
raise NotImplementedError("%s.save()" % self.__class__.__name__)
class UserMessage(common.Data):
def load(self, stream: streams.StreamIn):
self.id = stream.u32()
self.parent_id = stream.u32()
self.pid_sender = stream.pid()
self.reception_time = stream.datetime()
self.life_time = stream.u32()
self.flags = stream.u32()
self.subject = stream.string()
self.sender = stream.string()
# TODO: https://github.com/kinnay/NintendoClients/issues/86
self.message_recipient = MessageRecipient()
self.message_recipient.load(stream)
def save(self, stream: streams.StreamOut):
raise NotImplementedError("%s.save()" % self.__class__.__name__)
class BinaryMessage(UserMessage):
def load(self, stream: streams.StreamIn):
self.binary_body = stream.qbuffer()
def save(self, stream: streams.StreamOut):
raise NotImplementedError("%s.save()" % self.__class__.__name__)
common.DataHolder.register(BinaryMessage, "BinaryMessage")
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-host", default="127.0.0.1", help="hostname/ip to host the server on")
parser.add_argument("-pid", type=int, help="additional user pid")
parser.add_argument("-username", help="additional user username")
parser.add_argument("-password", help="additional user password")
args = parser.parse_args()
host = args.host
if args.pid and args.username and args.password:
users.append(User(args.pid, args.username, args.password))
settings = backend.Settings("default.cfg")
settings.set("nex.access_key", SMM.ACCESS_KEY)
settings.set("nex.version", SMM.NEX_VERSION)
settings.set("prudp.ping_timeout", 10.0)
secure_server_port = 59921
server_key = derive_key(settings, get_user_by_name(SECURE_SERVER))
secure_server = service.RMCServer(settings)
secure_server.register_protocol(SecureConnectionServer())
secure_server.register_protocol(DataStoreSmmServer(settings))
secure_server.register_protocol(MessageDeliveryServer(settings))
secure_server.start(host, secure_server_port, key=server_key)
logger.info("smm secure server {}:{}".format(host, secure_server_port))
auth_server_port = 59900
auth_server = service.RMCServer(settings)
auth_server.register_protocol(AuthenticationServer(settings, host, secure_server_port))
auth_server.start(host, auth_server_port)
logger.info("smm auth server {}:{}".format(host, auth_server_port))
logger.info("Press Ctrl+C to exit...")
while True:
time.sleep(1)
if __name__ == "__main__":
main()