- Joined
- May 7, 2010
- Messages
- 1,363
- Trophies
- 1
- Age
- 48
- Location
- oklahoma, USA
- Website
- www.wiithemer.org
- XP
- 1,405
- Country
so i am the wantta be dev from the wii forums that has a theme making website.
i am trying to add vwii theme building to site but i am having trouble decryting the .app file.
if any of the real devs could help me out i would appreciate it.
i am trying to add vwii theme building to site but i am having trouble decryting the .app file.
if any of the real devs could help me out i would appreciate it.
C#:
byte[] WiiU_common_key = new byte[] { 0xD7, 0xB0, 0x04, 0x02, 0x65, 0x9B, 0xA2, 0xAB, 0xD2, 0xCB, 0x0D, 0xB2, 0x7F, 0xA2, 0xB6, 0x56 };
byte[] commonkey = new byte[] { 0xeb, 0xe4, 0x2a, 0x22, 0x5e, 0x85, 0x93, 0xe4, 0x48, 0xd9, 0xc5, 0x45, 0x73, 0x81, 0xaa, 0xf7 };
byte[] encTitleKey;
byte[] decTitleKey;
if(vWii)
{
encTitleKey = GetPartOfByteArray(File.ReadAllBytes(tempDir + "cetk"), 0x1BF, 0x10);
decTitleKey = GetTitleKey(encTitleKey, HexStringToByteArray(titleID), WiiU_common_key);
}
else
{
encTitleKey = GetPartOfByteArray(File.ReadAllBytes(tempDir + "cetk"), 447, 16);
decTitleKey = GetTitleKey(encTitleKey, HexStringToByteArray(titleID), commonkey);
}
byte[] tmdHash = HexStringToByteArray(contInfo[contentIndex, 4]);
//int hashLen = tmdHash.Length;
// Console.WriteLine(string.Format("hashlen = {0}", hashLen));
//Decrypt appfile
Console.Write(" Decrypting Content ");
byte[] decContent = DecryptContent(
File.ReadAllBytes(tempDir + fileName), File.ReadAllBytes(tempDir + "tmd"), contentIndex, decTitleKey);
Console.Write("Complete ! \n");
public static byte[] GetPartOfByteArray(byte[] array, int offset, int length)
{
byte[] ret = new byte[length];
for (int i = 0; i < length; i++)
ret[i] = array[offset + i];
return ret;
}
public static byte[] HexStringToByteArray(string hexstring)
{
byte[] ba = new byte[hexstring.Length / 2];
for (int i = 0; i < hexstring.Length / 2; i++)
{
ba[i] = byte.Parse(hexstring.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
}
return ba;
}
public static byte[] GetTitleKey(byte[] encryptedkey, byte[] titleid, byte[] common_key)
{
Array.Resize(ref titleid, 16);
RijndaelManaged decrypt = new RijndaelManaged();
decrypt.Mode = CipherMode.CBC;
decrypt.Padding = PaddingMode.None;
decrypt.KeySize = 128;
decrypt.BlockSize = 128;
decrypt.Key = common_key;
decrypt.IV = titleid;
ICryptoTransform cryptor = decrypt.CreateDecryptor();
MemoryStream memory = new MemoryStream(encryptedkey);
CryptoStream crypto = new CryptoStream(memory, cryptor, CryptoStreamMode.Read);
byte[] decryptedkey = new byte[16];
crypto.Read(decryptedkey, 0, decryptedkey.Length);
crypto.Close();
memory.Close();
return decryptedkey;
}
Last edited by scooby74029,