Ejemplo n.º 1
0
 private void TestFcrtDoWork(object sender, DoWorkEventArgs e)
 {
     try {
         var args = e.Argument as EventArg <string, string>;
         if (args != null)
         {
             using (var reader = new NANDReader(args.Data1)) {
                 AddOutput("Looking for FCRT.bin in NAND:{0}", Environment.NewLine);
                 var data     = _x360NAND.GetFcrt(reader);
                 var keyutils = new CpukeyUtils();
                 var key      = keyutils.GetCPUKeyFromTextFile(args.Data2);
                 AddOutput("{0}Decrypting FCRT.bin...{0}", Environment.NewLine);
                 var crypt = new Cryptography();
                 crypt.DecryptFcrt(ref data, StringUtils.HexToArray(key));
                 AddOutput("Verifying FCRT.bin... Result: ");
                 AddOutput(crypt.VerifyFcrtDecrypted(ref data) ? "OK!" : "Failed!");
             }
         }
     }
     catch (Exception ex) {
         AddOutput("FAILED!");
         AddException(ex.ToString());
     }
     AddOutput(Environment.NewLine);
     AddDone();
 }
Ejemplo n.º 2
0
        private void testKvInfobtn_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";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var bw = new BackgroundWorker();

            bw.DoWork += (o, args) => {
                try {
                    var keyutils = new CpukeyUtils();
                    var key      = keyutils.GetCPUKeyFromTextFile(ofd.FileName);
                    using (var reader = new NANDReader(nand)) {
                        AddOutput("Grabbing & Decrypting KV From NAND: ");
                        var kv     = _x360NAND.GetKeyVault(reader, key);
                        var kvinfo = new Keyvault();
                        AddOutput(Environment.NewLine);
                        AddOutput("Console ID: {0}", kvinfo.GetConsoleID(ref kv));
                        AddOutput(Environment.NewLine);
                        AddOutput("Console Serial: {0}", kvinfo.GetConsoleSerial(ref kv));
                        AddOutput(Environment.NewLine);
                        AddOutput("DVDKey: {0}", kvinfo.GetDVDKey(ref kv));
                        AddOutput(Environment.NewLine);
                        AddOutput("FCRT Flag: 0x{0:X}", kvinfo.GetFCRTFlag(ref kv));
                        AddOutput(Environment.NewLine);
                        AddOutput("FCRT Required: {0}", kvinfo.FCRTRequired(ref kv));
                        AddOutput(Environment.NewLine);
                        AddOutput("FCRT Used: {0}", kvinfo.FCRTUsed(ref kv));
                        AddOutput(Environment.NewLine);
                        AddOutput("Game Region: {0}", kvinfo.GetGameRegion(ref kv, true));
                        AddOutput(Environment.NewLine);
                        AddOutput("MFR-Date (DDMMYY): {0}", kvinfo.GetMfrDate(ref kv, Keyvault.DateFormats.DDMMYY));
                        AddOutput(Environment.NewLine);
                        AddOutput("OSIG: {0}", kvinfo.GetOSIGData(ref kv));
                    }
                }
                catch (X360UtilsException ex) {
                    AddOutput("FAILED!");
                    AddException(ex.ToString());
                }
                AddOutput(Environment.NewLine);
                AddDone();
            };
            bw.RunWorkerCompleted += BwCompleted;
            bw.RunWorkerAsync();
        }
Ejemplo n.º 3
0
        public string GetKeyFromXeLL(IPAddress ipadrAddress)
        {
            switch (ipadrAddress.AddressFamily)
            {
            case AddressFamily.InterNetwork:
                var pinger = new Ping();
                var reply  = pinger.Send(ipadrAddress, 1000);
                if (reply != null && reply.Status != IPStatus.Success)
                {
                    reply = pinger.Send(ipadrAddress, 1000);
                }
                if (reply == null || reply.Status != IPStatus.Success)
                {
                    throw new TimeoutException(string.Format("Ping Timeout for {0}", ipadrAddress));
                }
                FuseDownloader(ipadrAddress);
                var keyutils = new CpukeyUtils();
                return(keyutils.GetCPUKeyFromTextFile("FUSE.txt"));

            default:
                throw new NotSupportedException("IP Must be IPv4!");
            }
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        private void Process(bool jf, bool spider = false)
        {
            var ofd = new OpenFileDialog {
                FileName = "flashdmp.bin"
            };

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

            ofd.FileName = "cpukey.txt";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var key = _keyUtils.GetCPUKeyFromTextFile(ofd.FileName);
            var fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var outdir = fbd.SelectedPath;
            var bw     = new BackgroundWorker();

            bw.RunWorkerCompleted += (sender, args) => {
                if (args.Error != null)
                {
                    throw args.Error;
                }
            };
            if (jf && !spider)
            {
                bw.DoWork += (o, eventArgs) => _jf.ExtractJungleFlasherData(nand, key, outdir);
            }
            else if (!spider)
            {
                bw.DoWork += (o, eventArgs) => _xk.ExtractXk3yCompatibleFiles(nand, key, outdir);
            }
            else
            {
                bw.DoWork += (sender, args) => {
                    Directory.SetCurrentDirectory(outdir);
                    var reader = new NANDReader(nand);
                    var fcrt   = _nand.GetFcrt(reader);
                    _crypto.DecryptFcrt(ref fcrt, x360Utils.Common.StringUtils.HexToArray(key));
                    if (_crypto.VerifyFcrtDecrypted(ref fcrt))
                    {
                        File.WriteAllBytes("fcrt_dec.bin", fcrt);
                    }
                    var kv = _nand.GetKeyVault(reader, key);
                    if (_crypto.VerifyKvDecrypted(ref kv, key))
                    {
                        File.WriteAllText("dvdkey.txt", _kv.GetDVDKey(ref kv));
                    }
                };
            }
            bw.RunWorkerAsync();
        }