ds/dsi unlock code hack
#!/usr/bin/python
# Wii parental control password reset tool
#
# Copyright 2008-2009 Hector Martin Cantero
#
# 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; version 2 or version 3 of the License.
#
# 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.
import time, urlparse
def application(environ, start_response):
start_response("200 OK", [("Content-type","text/html")])
yield """
Wii Parental Control Password Resetter
"""
Wii Parental Control password reset tool
"""
uri = environ["REQUEST_URI"]
qs = urlparse.urlparse(uri).query
form = urlparse.parse_qs(qs)
ctime = time.time()
def opt_date(delta):
t = time.gmtime(ctime + delta * 3600 * 24)
if delta == 0:
selected = ' selected="selected"'
else:
selected = ""
return ''%(t.tm_mon,t.tm_mday,selected,time.strftime("%a, %d %b %Y",t))
class CRC32:
def __init__(self):
self.gentable()
def crc32(self, input, crc=0xffffffffl):
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) ^ 0xEDB88320l
else:
crc >>= 1
self.table.append(crc)
def error(s):
return '%s
'%s
def process():
try:
int(form["number"][0]) #validate
if len(form["number"][0]) != 8 or not all([x in "0123456789" for x in form["number"][0]]):
raise ValueError()
except:
return error("Please provide a valid 8-digit confirmation number")
try:
int(form["date"][0]) #validate
if len(form["date"][0]) != 4 or not all([x in "0123456789" for x in form["date"][0]]):
raise ValueError()
except:
return error("Invalid date")
fullnum = form["date"][0] + form["number"][0][4:8]
crc = CRC32().crc32(fullnum)
code = ((crc ^ 0xaaaa) + 0x14c1) % 100000
return 'Your unlock code:%05d
'%code
if form.has_key("submit"):
yield process()
yield """