diff --git a/Struct.pyc b/Struct.pyc new file mode 100644 index 0000000..2587439 Binary files /dev/null and b/Struct.pyc differ diff --git a/TPL.pyc b/TPL.pyc new file mode 100644 index 0000000..86fe842 Binary files /dev/null and b/TPL.pyc differ diff --git a/U8.pyc b/U8.pyc new file mode 100644 index 0000000..8e3d3c8 Binary files /dev/null and b/U8.pyc differ diff --git a/__init__.py b/__init__.py index fbccb19..aace4f6 100644 --- a/__init__.py +++ b/__init__.py @@ -1,29 +1,9 @@ -import os, hashlib, struct, subprocess, fnmatch, shutil, urllib, array -import wx -from Crypto.Cipher import AES -import png -from Struct import Struct +__all__ = [] -__all__ = ['TPL', 'U8', 'compression', 'title', 'nand'] - -def align(x, boundary): - return x + (x % boundary) - -class Crypto: - """This is a Cryptographic/hash class used to abstract away things (to make changes easier)""" - def __init__(self): - return - def DecryptContent(self, titlekey, idx, data): - """Decrypts a Content.""" - iv = struct.pack(">H", idx) + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" - if(len(data) % 16 != 0): - return AES.new(titlekey, AES.MODE_CBC, iv).decrypt(data + ("\x00" * (16 - (len(data) % 16))))[:len(data)] - else: - return AES.new(titlekey, AES.MODE_CBC, iv).decrypt(data) - def ValidateHash(self, data, hash): - """Validates a hash. (BROKEN)""" - return 1 #hack -# if(hashlib.sha1(data).digest() == hash): -# return 1 -# else: -# return 0 +from common import * +from compression import * +from disc import * +from nand import * +from title import * +from TPL import * +from U8 import * \ No newline at end of file diff --git a/__init__.pyc b/__init__.pyc new file mode 100644 index 0000000..8a6ef38 Binary files /dev/null and b/__init__.pyc differ diff --git a/common.py b/common.py new file mode 100644 index 0000000..4c5ea38 --- /dev/null +++ b/common.py @@ -0,0 +1,28 @@ +import os, hashlib, struct, subprocess, fnmatch, shutil, urllib, array +import wx +from Crypto.Cipher import AES +import png +from Struct import Struct + +def align(x, boundary): + return x + (x % boundary) + +class Crypto: + """This is a Cryptographic/hash class used to abstract away things (to make changes easier)""" + def __init__(self): + return + def DecryptContent(self, titlekey, idx, data): + """Decrypts a Content.""" + iv = struct.pack(">H", idx) + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + if(len(data) % 16 != 0): + return AES.new(titlekey, AES.MODE_CBC, iv).decrypt(data + ("\x00" * (16 - (len(data) % 16))))[:len(data)] + else: + return AES.new(titlekey, AES.MODE_CBC, iv).decrypt(data) + def ValidateHash(self, data, hash): + """Validates a hash. (BROKEN)""" + return 1 #hack +# if(hashlib.sha1(data).digest() == hash): +# return 1 +# else: +# return 0 + diff --git a/common.pyc b/common.pyc new file mode 100644 index 0000000..2b5ea2b Binary files /dev/null and b/common.pyc differ diff --git a/compression.pyc b/compression.pyc new file mode 100644 index 0000000..1984327 Binary files /dev/null and b/compression.pyc differ diff --git a/disc.py b/disc.py new file mode 100644 index 0000000..9da6a27 --- /dev/null +++ b/disc.py @@ -0,0 +1,97 @@ + +class WOD: #WiiOpticalDisc + def __init__(self, f): + self.f = f + + + class fsentry: + name = "" + parent = None + + def __init__(self, name, parent): + self.name = "" + if(parent != None): + self.parent = parent + def path(self): + return parent.path() + "/" + name + + class fsdir(fsentry): + def __init__(self, name, parent): + fsentry.__init__(self, name, parent) + + class fsfile(fsentry): + size = 0 + offset = 0 + + + def extractPartition(self, index, fn = ""): + self.fp = open(self.f, "rb") + + if(fn == ""): + fn = os.path.dirname(self.f) + "/" + os.path.basename(self.f).replace(".", "_") + "_out" + try: + origdir = os.getcwd() + os.mkdir(fn) + except: + pass + os.chdir(fn) + + self.titleid = self.fp.read(4) + self.publisher = self.fp.read(2) + + self.fp.seek(0x18) + if(struct.unpack(">I", self.fp.read(4))[0] != 0x5D1C9EA3): + self.fp.seek(-4, 1) + raise ValueError("Not a valid Wii Disc (GC not supported)! Magic: %08x" % struct.unpack(">I", self.fp.read(4))[0]) + + self.fp.seek(0x40000) + partitions = struct.unpack(">I", self.fp.read(4))[0] + parttableoffs = struct.unpack(">I", self.fp.read(4))[0] << 2 + + channels = struct.unpack(">I", self.fp.read(4))[0] + chantableoffs = struct.unpack(">I", self.fp.read(4))[0] << 2 + + self.fp.seek(parttableoffs + (8 * index)) + partitionoffs = struct.unpack(">I", self.fp.read(4))[0] << 2 + partitiontype = struct.unpack(">I", self.fp.read(4))[0] #0 is data, 1 is update, 2 is installer + + self.fp.seek(partitionoffs) + + tikdata = self.fp.read(0x2A3) + open("tik").write(tikdata) + self.tik = Ticket("tik") + self.titlekey = self.tik.getTitleKey() + + tmdsz = struct.unpack(">I", self.fp.read(4))[0] + tmdoffs = struct.unpack(">I", self.fp.read(4))[0] + + certsz = struct.unpack(">I", self.fp.read(4))[0] + certoffs = struct.unpack(">I", self.fp.read(4))[0] + + h3offs = struct.unpack(">I", self.fp.read(4))[0] << 2 + h3sz = 0x18000 + + dataoffs = struct.unpack(">I", self.fp.read(4))[0] << 2 + datasz = struct.unpack(">I", self.fp.read(4))[0] << 2 + if(tmdoffs != self.fp.tell()): + raise ValueError("TMD is in wrong place, something is fucked...wtf?") + + tmddata = self.fp.read(tmdsz) + open("tmd").write(tmddata) + + self.tmd = TMD("tmd") + + + + + + fst.seek(dataoffs) + + + + os.chdir("..") + def _recurse(self, parent, names, recursion): + if(recursion == 0): + pass + + diff --git a/disc.pyc b/disc.pyc new file mode 100644 index 0000000..0c58b75 Binary files /dev/null and b/disc.pyc differ diff --git a/nand.pyc b/nand.pyc new file mode 100644 index 0000000..8d41344 Binary files /dev/null and b/nand.pyc differ diff --git a/png.pyc b/png.pyc new file mode 100755 index 0000000..a7d1315 Binary files /dev/null and b/png.pyc differ diff --git a/test.py b/test.py deleted file mode 100644 index 61a911d..0000000 --- a/test.py +++ /dev/null @@ -1,6 +0,0 @@ -import Wii - -try: - Wii.U8("/Users/Xuzz/code/wadder3").pack("testing.u8") -except: - pass \ No newline at end of file diff --git a/title.pyc b/title.pyc new file mode 100644 index 0000000..aeae092 Binary files /dev/null and b/title.pyc differ