-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
wiipcrt.py
executable file
·171 lines (145 loc) · 5.66 KB
/
wiipcrt.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
#!/usr/bin/python
#
# WiiPCRT
# Wii Parental Control (PIN) Reset Tool - Based on https://wii.marcan.st/parental_src.py
#
# Copyright (C) 2018-2021 Sindastra <https://github.com/sindastra/WiiPCRT>
# Copyright 2008-2009 Hector Martin Cantero <hector@marcansoft.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, os
VERSION = "1.1.2"
def has_arg(string):
return (string in sys.argv or "-"+string in sys.argv or "--"+string in sys.argv or "/"+string in sys.argv)
def has_args(array):
for i in array:
if has_arg(i):
return True
return False
def printhelp():
print ("Usage: "+sys.argv[0]+" [options] <request code>")
print ("The following options are available:")
print ("-h or --help Show this help page.")
print ("-t or --today Only show unlock code for today's date.")
print ("--license Display license information.")
print ("--version Display version information.")
print ("---------------------------------------------------------------------")
print ("WiiPCRT - Wii Parental Control (PIN) Reset Tool v"+VERSION)
print ("Copyright (C) 2018-2021 Sindastra <https://github.com/sindastra/WiiPCRT>")
print ("Official Website: https://sindastra.github.io/WiiPCRT/")
print ("Special thanks to Marcan, who coded the cracking part.")
print ("---------------------------------------------------------------------")
if has_args(["help","h","?"]):
printhelp()
sys.exit(0)
if has_arg("version"):
print("Version: "+VERSION)
sys.exit(0)
only_today = has_args(["today","t"])
show_license = has_arg("license")
if show_license:
print ("This program is free software: you can redistribute it and/or modify")
print ("it under the terms of the GNU General Public License as published by")
print ("the Free Software Foundation, either version 3 of the License, or")
print ("(at your option) any later version.")
print ("")
print ("This program is distributed in the hope that it will be useful,")
print ("but WITHOUT ANY WARRANTY; without even the implied warranty of")
print ("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the")
print ("GNU General Public License for more details.")
if not show_license:
print ("Pass --license for more info.")
if show_license:
print ("")
print ("You should have received a copy of the GNU General Public License")
print ("along with this program. If not, see <http://www.gnu.org/licenses/>.")
if os.name == "nt":
input ("Press Enter to exit.")
sys.exit(0)
print ("---------------------------------------------------------------------")
if len(sys.argv) < 2:
printhelp()
print ("Alternatively:")
sys.stdout.write ("Input your 8 *digit* request code now: ")
sys.stdout.flush()
try:
request_code = sys.stdin.readline().rstrip()
except KeyboardInterrupt:
print ("")
print ("Cancelled by user!")
sys.exit(0)
print ("---------------------------------------------------------------------")
else:
request_code = sys.argv[len(sys.argv)-1]
rcerr = 0
try:
int(request_code)
if len(request_code) != 8:
rcerr = 1
except ValueError:
rcerr = 1
if rcerr :
print ("Please enter an 8 *digit* request code!")
if os.name == "nt":
input ("Press Enter to exit now and try again.")
sys.exit()
import time
ctime = time.time()
def timezone(diff):
t = time.gmtime(ctime + (0 +diff) * 3600 * 24)
return time.strftime("%m%d",t)
timezones = [0,1,2]
timezones[0] = timezone(-1)
timezones[1] = timezone(0)
timezones[2] = timezone(+1)
def opt_date(delta):
t = time.gmtime(ctime + (delta-1) * 3600 * 24)
return time.strftime("%b. %d (%A)",t)
class CRC32:
def __init__(self):
self.gentable()
def crc32(self, input, crc=0xffffffff):
count = len(input)
i = 0
while count != 0:
count -= 1
temp1 = (crc >> 8) & 0xFFFFFF
temp2 = self.table[(crc ^ ord(input[i])) & 0xFF]
crc = temp1 ^ temp2
i += 1
return crc
def gentable(self):
self.table = []
for i in range(256):
crc = i
for j in range(8):
if crc & 1:
crc = (crc >> 1) ^ 0xEDB88320
else:
crc >>= 1
self.table.append(crc)
def output_code(timezone):
fullnum = timezone + request_code[4:8]
crc = CRC32().crc32(fullnum)
code = ((crc ^ 0xaaaa) + 0x14c1) % 100000
return str(code).zfill(5)
print ("Make sure the Wii and this computer have the correct (same) date set!")
if not only_today:
print ("Pick the code for your current time zone (date):")
print ("")
for i in range(1 if only_today else 3):
print ("(" + output_code(timezones[1 if only_today else i]) + ") <- Unlock key for " + opt_date(1 if only_today else i))
if os.name == "nt":
print ("---------------------------------------------------------------------")
input ("Press Enter to exit.")