Example #1
0
        private void ExtractCurrentFsDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            var reader = new NANDReader(doWorkEventArgs.Argument as string);

            try {
                AddOutput("Scanning for RootFS... {0}", Environment.NewLine);
                reader.ScanForFsRootAndMobile();
                AddOutput("Parsing RootFS @ 0x{0:X}...{1}", reader.FsRoot.Offset, Environment.NewLine);
                var fs      = new NANDFileSystem();
                var entries = fs.ParseFileSystem(ref reader);
                AddOutput("FSEntries found: {0}{1}", entries.Length, Environment.NewLine);
                var dir = (doWorkEventArgs.Argument as string) + "_ExtractedFS";
                Directory.CreateDirectory(dir);
                foreach (var fileSystemEntry in entries)
                {
                    AddOutput("Extracting: {0}...{1}", fileSystemEntry.Filename, Environment.NewLine);
                    fileSystemEntry.ExtractToFile(ref reader, Path.Combine(dir, fileSystemEntry.Filename));
                    //File.WriteAllBytes(Path.Combine(dir, fileSystemEntry.Filename), fileSystemEntry.GetData(ref reader));
                }
            }
            catch (Exception ex) {
                AddException(ex.ToString());
            }
            finally {
                reader.Close();
            }
            AddDone();
        }
Example #2
0
 private void GetBadblocks(object sender, DoWorkEventArgs e)
 {
     _sw = Stopwatch.StartNew();
     try {
         using (var reader = new NANDReader(e.Argument as string)) {
             AddOutput("Grabbing BadBlock info from NAND: ");
             var blocks = reader.FindBadBlocks();
             foreach (var block in blocks)
             {
                 AddOutput("{1}BadBlock @ 0x{0:X}", block, Environment.NewLine);
             }
         }
     }
     catch (X360UtilsException ex) {
         if (ex.ErrorCode != X360UtilsException.X360UtilsErrors.DataNotFound)
         {
             AddOutput("FAILED!\r\n");
             AddException(ex.ToString());
         }
         else
         {
             AddOutput("No BadBlocks Found!\r\n");
         }
     }
     catch (NotSupportedException) {
         AddOutput("Not Supported for this image type!");
     }
     AddOutput(Environment.NewLine);
     AddDone();
 }
Example #3
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();
 }
Example #4
0
        private void GetfusebtnClick(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

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

            bw.DoWork += (o, args) => {
                try {
                    using (var reader = new NANDReader(ofd.FileName)) {
                        AddOutput("Grabbing FUSES from NAND: ");
                        AddOutput(Environment.NewLine);
                        AddOutput(_x360NAND.GetVirtualFuses(reader));
                    }
                }
                catch (X360UtilsException ex) {
                    AddOutput("FAILED!");
                    AddException(ex.ToString());
                }
                AddOutput(Environment.NewLine);
                AddDone();
            };
            bw.RunWorkerCompleted += BwCompleted;
            bw.RunWorkerAsync();
        }
Example #5
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);
            }
        }
Example #6
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();
        }
Example #7
0
 private void Form1_DragDrop(object sender, DragEventArgs e)
 {
     try {
         var file = ((string[])e.Data.GetData(DataFormats.FileDrop, false))[0];
         if (reader != null)
         {
             reader.Close();
         }
         reader        = new NANDReader(file);
         textBox1.Text = file;
         var smc = _nand.GetSmc(reader, true);
         textBox2.Text = _smc.GetVersion(ref smc);
     }
     catch { }
 }
Example #8
0
 private void Getlaunchini(object sender, DoWorkEventArgs e)
 {
     _sw = Stopwatch.StartNew();
     try {
         using (var reader = new NANDReader(e.Argument as string)) {
             AddOutput("Grabbing Launch.ini from NAND: ");
             AddOutput("{0}{0}{1}", Environment.NewLine, _x360NAND.GetLaunchIni(reader));
         }
     }
     catch (X360UtilsException ex) {
         AddOutput("FAILED!");
         AddException(ex.ToString());
     }
     AddOutput(Environment.NewLine);
     AddDone();
 }
Example #9
0
        private void GetsmcconfigbtnClick(object sender, EventArgs e)
        {
            _sw = Stopwatch.StartNew();
            var ofd = new OpenFileDialog();

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

            bw.DoWork += (o, args) => {
                try {
                    using (var reader = new NANDReader(ofd.FileName)) {
                        AddOutput("Grabbing SMC_Config from NAND: ");
                        var cfg    = _x360NAND.GetSmcConfig(reader);
                        var config = new SmcConfig();
                        AddOutput("\r\nChecksum: {0}", config.GetCheckSum(ref cfg));
                        AddOutput("\r\nDVDRegion: {0}", config.GetDVDRegion(ref cfg));
                        AddOutput("\r\nCPUFanSpeed: {0}", config.GetFanSpeed(ref cfg, SmcConfig.SmcConfigFans.Cpu));
                        AddOutput("\r\nGPUFanSpeed: {0}", config.GetFanSpeed(ref cfg, SmcConfig.SmcConfigFans.Gpu));
                        AddOutput("\r\nGameRegion: {0}", config.GetGameRegion(ref cfg));
                        AddOutput("\r\nMACAdress: {0}", config.GetMACAdress(ref cfg));
                        AddOutput("\r\nCPUTemp: {0}", config.GetTempString(ref cfg, SmcConfig.SmcConfigTemps.Cpu));
                        AddOutput("\r\nCPUMaxTemp: {0}", config.GetTempString(ref cfg, SmcConfig.SmcConfigTemps.CpuMax));
                        AddOutput("\r\nGPUTemp: {0}", config.GetTempString(ref cfg, SmcConfig.SmcConfigTemps.Gpu));
                        AddOutput("\r\nGPUMaxTemp: {0}", config.GetTempString(ref cfg, SmcConfig.SmcConfigTemps.GpuMax));
                        AddOutput("\r\nRAMTemp: {0}", config.GetTempString(ref cfg, SmcConfig.SmcConfigTemps.Ram));
                        AddOutput("\r\nRAMMaxTemp: {0}", config.GetTempString(ref cfg, SmcConfig.SmcConfigTemps.RamMax));
                        AddOutput("\r\nVideoRegion: {0}", config.GetVideoRegion(ref cfg));
                        AddOutput("\r\nResetCode: {0} ({1})", config.GetResetCode(ref cfg, true), config.GetResetCode(ref cfg));
                    }
                }
                catch (X360UtilsException ex) {
                    AddOutput("FAILED!");
                    AddException(ex.ToString());
                }
                AddOutput(Environment.NewLine);
                AddDone();
            };
            bw.RunWorkerCompleted += BwCompleted;
            bw.RunWorkerAsync();
        }
Example #10
0
        private void TestFsParserDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            var reader = new NANDReader(doWorkEventArgs.Argument as string);

            try {
                AddOutput("Parsing RootFS @ 0x{0:X}...{1}", reader.FsRoot.Offset, Environment.NewLine);
                var fs      = new NANDFileSystem();
                var entries = fs.ParseFileSystem(ref reader);
                AddOutput("FSEntries found:{0}", Environment.NewLine);
                foreach (var fileSystemEntry in entries)
                {
                    AddOutput("{0}{1}", fileSystemEntry, Environment.NewLine);
                }
            }
            catch (Exception ex) {
                AddException(ex.ToString());
            }
            finally {
                reader.Close();
            }
            AddDone();
        }
Example #11
0
        private void TestFsRootScanDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            var reader = new NANDReader(doWorkEventArgs.Argument as string);

            AddOutput("Testing FSRootScanner... {0}", Environment.NewLine);
            try {
                AddOutput("FSRoot found:{0}", Environment.NewLine);
                AddOutput("{0}{1}", reader.FsRoot, Environment.NewLine);
                AddOutput("Mobiles found:{0}", Environment.NewLine);
                foreach (var mobileEntry in reader.MobileEntries)
                {
                    AddOutput("{0}{1}", mobileEntry, Environment.NewLine);
                }
            }
            catch (Exception ex) {
                AddException(ex.ToString());
            }
            finally {
                reader.Close();
            }
            AddDone();
        }
Example #12
0
        private void GetsmcbtnClick(object sender, EventArgs e)
        {
            _sw = Stopwatch.StartNew();
            var ofd = new OpenFileDialog();

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

            bw.DoWork += (o, args) => {
                try {
                    using (var reader = new NANDReader(ofd.FileName)) {
                        AddOutput("Grabbing SMC from NAND: ");
                        var data = _x360NAND.GetSmc(reader, true);
                        var smc  = new Smc();
                        var type = smc.GetType(ref data);
                        AddOutput("\r\nSMC Version: {0} [{1}]", smc.GetVersion(ref data), smc.GetMotherBoardFromVersion(ref data));
                        AddOutput("\r\nSMC Type: {0}", type);
                        if (type == Smc.SmcTypes.Jtag || type == Smc.SmcTypes.RJtag)
                        {
                            Smc.JtagsmcPatches.AnalyseSmc(ref data);
                        }
                        AddOutput("\r\nSMC Glitch Patched: {0}", smc.CheckGlitchPatch(ref data) ? "Yes" : "No");
                    }
                }
                catch (X360UtilsException ex) {
                    AddOutput("FAILED!");
                    AddException(ex.ToString());
                }
                AddOutput(Environment.NewLine);
                AddDone();
            };
            bw.RunWorkerCompleted += BwCompleted;
            bw.RunWorkerAsync();
        }
Example #13
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();
        }
Example #14
0
 public byte[] GetBlock(ref NANDReader reader)
 {
     reader.Seek(Offset, SeekOrigin.Begin);
     return(reader.ReadBytes(0x4000));
 }
Example #15
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();
        }
Example #16
0
 public void ExtractXk3yCompatibleFiles(NANDReader nandreader, string cpukey, string outdir)
 {
     ExtractXk3yCompatibleFiles(nandreader, StringUtils.HexToArray(cpukey), outdir);
 }