示例#1
0
 public string GetNandCpuKey(NANDReader reader)
 {
     byte[] key;
     if (!GetByteKey(reader, 0x100, out key))                   // Blakcat XeLL
     {
         if (!GetByteKey(reader, 0x6d0, out key))               // Blakcat Freeboot storage (Spare type offset)
         {
             if (!GetByteKey(reader, 0x700, out key))           // Blakcat Freeboot storage (MMC type offset)
             {
                 if (!GetByteKey(reader, 0x600, out key))       // xeBuild GUI Offset
                 {
                     if (!GetByteKey(reader, 0x95020, out key)) // Virtual Fuses
                     {
                         string keys;
                         if (!GetAsciiKey(reader, 0x600, out keys)) // xeBuild GUI ASCII Method
                         {
                             throw new X360UtilsException(X360UtilsException.X360UtilsErrors.DataNotFound);
                         }
                         return(keys);
                     }
                 }
             }
         }
     }
     return(StringUtils.ArrayToHex(key));
 }
示例#2
0
        public void ExtractXk3yCompatibleFiles(NANDReader nandReader, byte[] cpukey, string outdir)
        {
            var origdir = Directory.GetCurrentDirectory();

            try {
                if (!Directory.Exists(outdir))
                {
                    Directory.CreateDirectory(outdir);
                }
                Directory.SetCurrentDirectory(outdir);
                var fcrt = _nand.GetFcrt(nandReader);
                var tmp  = new byte[fcrt.Length];
                Buffer.BlockCopy(fcrt, 0, tmp, 0, fcrt.Length);
                _crypto.DecryptFcrt(ref tmp, cpukey);
                if (!_crypto.VerifyFcrtDecrypted(ref tmp))
                {
                    throw new X360UtilsException(X360UtilsException.X360UtilsErrors.DataInvalid, "FCRT Can't be verified to be for this cpukey!");
                }
                File.WriteAllBytes("fcrt_enc.bin", fcrt);
                var kv = _nand.GetKeyVault(nandReader, cpukey);
                File.WriteAllText("dvd.txt", _kvutils.GetDVDKey(ref kv));
                File.WriteAllText("cpu.txt", StringUtils.ArrayToHex(cpukey));
                File.WriteAllText(TranslateOsigToFile(_kvutils.GetOSIGData(ref kv)), "");
            }
            finally {
                Directory.SetCurrentDirectory(origdir);
            }
        }
示例#3
0
        private void bootloaderbtn_Click(object sender, EventArgs e)
        {
            _sw = Stopwatch.StartNew();
            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var nand = ofd.FileName;

            ofd.FileName = "cpukey.txt";
            var nokey = ofd.ShowDialog() != DialogResult.OK;
            var bw    = new BackgroundWorker();

            bw.DoWork += (o, args) => {
                try {
                    var keyutils = new CpukeyUtils();
                    var key      = "";
                    if (!nokey)
                    {
                        key = keyutils.GetCPUKeyFromTextFile(ofd.FileName);
                    }
                    using (var reader = new NANDReader(nand)) {
                        AddOutput("Getting bootloaders...{0}", Environment.NewLine);
                        var bls = _x360NAND.GetBootLoaders(reader, true);
                        if (nokey)
                        {
                            try {
                                AddOutput("Attempting to grab key from NAND... {0}", Environment.NewLine);
                                key = _x360NAND.GetNandCpuKey(reader);
                                AddOutput("Key found! {0}{1}", key, Environment.NewLine);
                                nokey = false;
                            }
                            catch (X360UtilsException ex) {
                                if (ex.ErrorCode != X360UtilsException.X360UtilsErrors.DataNotFound)
                                {
                                    throw;
                                }
                            }
                        }
                        byte[] lastkey = null;
                        foreach (var bl in bls)
                        {
                            AddOutput("Bootloader Information for: {0}{1}", bl.Type, Environment.NewLine);
                            AddOutput("Build: {0}{1}", bl.Build, Environment.NewLine);
                            AddOutput("Size: 0x{0:X}{1}", bl.Size, Environment.NewLine);
                            AddOutput("Encryption type: {0}{1}", bl.CryptoType, Environment.NewLine);
                            if (!nokey)
                            {
                                if (lastkey != null)
                                {
                                    bl.Key = lastkey;
                                }
                                if (!bl.Decrypted)
                                {
                                    try {
                                        AddOutput("Decrypting the bootloader...{0}", Environment.NewLine);
                                        if (bl.CryptoType != Cryptography.BlEncryptionTypes.MfgCbb && bl.Type == Bootloader.BootLoaderTypes.CBB)
                                        {
                                            AddOutput("Decrypting with key: {0}{1}", key, Environment.NewLine);
                                            bl.Decrypt(StringUtils.HexToArray(key));
                                            AddOutput("Decryption result: {0}{1}", bl.Decrypted ? "Success!" : "Failed!", Environment.NewLine);
                                        }
                                        else if (bl.CryptoType == Cryptography.BlEncryptionTypes.MfgCbb && bl.Type == Bootloader.BootLoaderTypes.CBB)
                                        {
                                            AddOutput("Decrypting with key: {0}{1}", Main.MfgBlKey, Environment.NewLine);
                                            bl.Decrypt(Main.MfgBlKeyBytes);
                                            AddOutput("Decryption result: {0}{1}", bl.Decrypted ? "Success!" : "Failed!", Environment.NewLine);
                                        }
                                        else
                                        {
                                            AddOutput("Decrypting with key: {0}{1}", Main.FirstBlKey, Environment.NewLine);
                                            bl.Decrypt(Main.FirstBlKeyBytes);
                                            AddOutput("Decryption result: {0}{1}", bl.Decrypted ? "Success!" : "Failed!", Environment.NewLine);
                                        }
                                    }
                                    catch (NotImplementedException) {
                                        AddOutput("Not implemented for this bootloader version...{0}", Environment.NewLine);
                                    }
                                }
                                if (bl.OutKey != null)
                                {
                                    AddOutput("OutKey: {0}{1}", StringUtils.ArrayToHex(bl.OutKey), Environment.NewLine);
                                }
                                if (bl.Key != null)
                                {
                                    AddOutput("Key: {0}{1}", StringUtils.ArrayToHex(bl.Key), Environment.NewLine);
                                }

                                lastkey = bl.OutKey;
                            }
                        }
                    }
                }
                catch (X360UtilsException ex) {
                    AddOutput("FAILED!");
                    AddException(ex.ToString());
                }
                AddOutput(Environment.NewLine);
                AddDone();
            };
            bw.RunWorkerCompleted += BwCompleted;
            bw.RunWorkerAsync();
        }
示例#4
0
 public string GetConsoleID(ref byte[] keyvaultdata)
 {
     return(StringUtils.ArrayToHex(keyvaultdata, 0x9CA, 0x6));
 }
示例#5
0
 public string GetDVDKey(ref byte[] keyvaultdata)
 {
     return(StringUtils.ArrayToHex(keyvaultdata, 0x100, 0x10));
 }