Exemplo n.º 1
0
        private void frm_game_info_multiple_Load(object sender, EventArgs e)
        {
            new Thread(new ThreadStart(delegate {
                for (int i = 0; i < Files.Count(); i++)
                {
                    Image Content  = null, Package = null;
                    bool Error     = false, HasImage = true;
                    string Display = "", Title = "", DeviceID = "", TitleID = "", ConsoleID = "", ProfileID = "", SubFolder = "", TitleFolder = "", ContentRoot = "", FullDirectory = "", Hash = "", Revision = "";

                    STFSP = new STFSPackage(this.Files[i], Logs);
                    if (STFSP.ParseSuccess)
                    {
                        try {
                            try {
                                Content = this.STFSP.Header.ContentImage;
                                Package = this.STFSP.Header.PackageImage;
                            } catch { HasImage = false; }

                            Display  = this.STFSP.Header.Title_Display;
                            Title    = this.STFSP.Header.Title_Package;
                            DeviceID = Conversion.BytesToHexString(this.STFSP.Header.DeviceID);
                            TitleID  = this.STFSP.Header.TitleID.ToString("X2").ToUpper();
                            this.STFSP.CloseIO();

                            List <byte> fileBytes = FileEx.ReadBytes(this.Files[i], 0, 0x9725 /*0x450*/).ToList();
                            string[] accepted     = { "LIVE", "PIRS", "CON " };
                            string fileType       = Encoding.UTF8.GetString(fileBytes.GetRange(0, 0x4).ToArray());
                            if (accepted.Contains(fileType))
                            {
                                ConsoleID     = Conversion.BytesToHexString(fileBytes.GetRange(0x36C, 0x4).ToArray());
                                ProfileID     = Conversion.BytesToHexString(fileBytes.GetRange(0x371, 0x4).ToArray());
                                SubFolder     = Conversion.BytesToHexString(fileBytes.GetRange(0x344, 0x4).ToArray());
                                TitleFolder   = Conversion.BytesToHexString(fileBytes.GetRange(0x360, 0x4).ToArray());
                                Revision      = Convert.ToInt32(fileBytes.GetRange(0x9724, 0x1).ToArray()[0]).ToString();
                                ContentRoot   = this.STFSP.Header.ThisType != PackageType.Profile ? Conversion.BytesToHexString(fileBytes.GetRange(0x364, 0x8).ToArray()) : this.STFSP.Header.Title_Display;
                                FullDirectory = String.Format("HDD:\\Content\\{0}\\{1}\\{2}", ContentRoot, TitleFolder, SubFolder);
                                Hash          = Hashing.MD5(fileBytes.ToArray()).Substring(0, 12).ToUpper();
                            }
                        } catch { Invoke(new MethodInvoker(() => { Error = true; this.Text = String.Format("Game Info - {0}/{1} | Errors: {2}", this.Successes, this.Files.Count(), this.Errors++); })); }
                        Info.Add(new STFSInfo {
                            Display = Display, Title = TitleFolder, DeviceID = DeviceID, TitleID = TitleID, ConsoleID = ConsoleID, ProfileID = ProfileID, Sub = SubFolder, TitleName = Title,
                            Content = Content, FullDirectory = FullDirectory, Package = Package, Root = ContentRoot, Local = this.Files[i], Error = Error, Hash = Hash, HasImage = HasImage, Revision = Revision
                        });
                        Invoke(new MethodInvoker(() => {
                            this.Text = String.Format("Game Info - {0}/{1}{2}{3}", this.Successes++, this.Files.Count(), (Error ? " | Errors: " : ""), (Error ? this.Errors.ToString() : ""));
                            if (!Error)
                            {
                                FormE.ListViews.addToListView(lv_main, TitleID, (Title == "" ? Xbox.HexTitleToName(Convert.ToUInt32(TitleID, 16)) : Title), "Loaded", Hash, Revision);
                            }
                        }));
                    }
                    else
                    {
                        this.Errors++;
                    }
                }
                Invoke(new MethodInvoker(() => { this.Text = "Game Info - Finished Loading Files"; this.Finished = true; Info.ForEach(s => Console.WriteLine(s.ToString())); }));
            })).Start();
        }
Exemplo n.º 2
0
        private void GatherInformation(string Location)
        {
            try {
                this.STFSP = new STFSPackage(Location, this.Log);
                if (this.STFSP.ParseSuccess)
                {
                    try {
                        pb_content.Image = this.STFSP.Header.ContentImage;
                        pb_package.Image = this.STFSP.Header.PackageImage;
                    } catch { }

                    tb_display.Text   = this.STFSP.Header.Title_Display;
                    tb_titleName.Text = this.STFSP.Header.Title_Package;
                    tb_deviceID.Text  = Conversion.BytesToHexString(this.STFSP.Header.DeviceID);
                    tb_titleID.Text   = this.STFSP.Header.TitleID.ToString("X2").ToUpper();
                    this.STFSP.CloseIO();
                    // Now we'll do our own shit to get the location of where this package goes.
                    List <byte> fileBytes = FileEx.ReadBytes(Location, 0, 0x9725).ToList();
                    string[]    accepted  = { "LIVE", "PIRS", "CON " };
                    string      fileType  = Encoding.UTF8.GetString(fileBytes.GetRange(0, 0x4).ToArray());
                    if (accepted.Contains(fileType))
                    {
                        tb_consoleID.Text = Conversion.BytesToHexString(fileBytes.GetRange(0x36C, 0x4).ToArray());
                        tb_profileID.Text = Conversion.BytesToHexString(fileBytes.GetRange(0x371, 0x4).ToArray());
                        string SubFolder   = Conversion.BytesToHexString(fileBytes.GetRange(0x344, 0x4).ToArray());
                        string TitleFolder = Conversion.BytesToHexString(fileBytes.GetRange(0x360, 0x4).ToArray());
                        string ContentRoot = this.STFSP.Header.ThisType != PackageType.Profile ? Conversion.BytesToHexString(fileBytes.GetRange(0x364, 0x8).ToArray()) : this.STFSP.Header.Title_Display;
                        string Revision    = Convert.ToInt32(fileBytes.GetRange(0x9724, 0x1).ToArray()[0]).ToString();
                        lbl_rootFolder.Text   = ContentRoot;
                        lbl_titleFolder.Text  = TitleFolder;
                        lbl_subFolder.Text    = SubFolder;
                        tb_fullDirectory.Text = String.Format("HDD:\\Content\\{0}\\{1}\\{2}", ContentRoot, TitleFolder, SubFolder);
                        this.Text             = String.Format("Game Info - {0}: TU {1}", (tb_titleName.Text != "" ? tb_titleName.Text : Xbox.HexTitleToName(Convert.ToUInt32(tb_titleID.Text, 16))), Revision);
                    }
                    else
                    {
                        if (MessageBox.Show(Location + "\r\n\r\nInvalid file format! " + fileType, "Invalid Format", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
                        {
                            return;
                        }
                    }
                }
            } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error Loading File", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Exemplo n.º 3
0
        private byte[] GetXMACsLogonKey(KVInfo KVI)
        {
            RSACryptoServiceProvider Provider = LoadXMACs();

            byte[] TimeTick = new byte[0x10];
            new Random(Environment.TickCount).NextBytes(TimeTick);

            byte[] EncryptedTick = Provider.Encrypt(TimeTick, true);
            Array.Reverse(EncryptedTick);

            byte[] DestBuffer = Keys.XMACS_REQ;
            Array.Copy(EncryptedTick, 0, DestBuffer, 0x2C, 0x100);
            byte[] InputBuffer = FileEx.ReadBytes(KVI.Location, 0xB0, 12);
            byte[] Source      = FileEx.ReadBytes(KVI.Location, 0x9C8, 0x1A8);
            byte[] Exponent    = FileEx.ReadBytes(KVI.Location, 0x29C, 4);
            byte[] KeyParams   = FileEx.ReadBytes(KVI.Location, 0x2A8, 0x1C0);
            byte[] ConsoleID   = FileEx.ReadBytes(KVI.Location, 0x9CA, 5);
            byte[] ClientName  = ComputeClientName(ConsoleID);
            byte[] UTCTime     = BitConverter.GetBytes(DateTime.UtcNow.ToFileTime());
            Array.Reverse(UTCTime);

            KVI.Serial = Conversion.BytesToHexString(ConsoleID);

            byte[] TimeStamp = Conversion.HexStringToBytes("301aa011180f32303132313231323139303533305aa10502030b3543");
            Array.Copy(Encoding.ASCII.GetBytes(DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmssZ")), 0, TimeStamp, 6, 15);

            byte[] EncryptedHMAC = RC4HMACEncrypt(TimeTick, 0x10, TimeStamp, TimeStamp.Length, 1);
            byte[] TickChecksum  = SHA1.Create().ComputeHash(TimeTick);

            SHA1CryptoServiceProvider SHAProvider = new SHA1CryptoServiceProvider();

            SHAProvider.TransformBlock(TimeTick, 0, 8, null, 0);
            SHAProvider.TransformBlock(InputBuffer, 0, 12, null, 0);
            SHAProvider.TransformFinalBlock(TickChecksum, 0, 20);
            byte[] HeaderChecksum = SHAProvider.Hash;

            RSACryptoServiceProvider   Key       = LoadConsolePrivateKey(Exponent, KeyParams);
            RSAPKCS1SignatureFormatter Formatter = new RSAPKCS1SignatureFormatter(Key);

            Formatter.SetHashAlgorithm("SHA1");
            byte[] Signature = Formatter.CreateSignature(HeaderChecksum);
            Array.Reverse(Signature);
            // Build the final packet
            Array.Copy(TimeTick, 0, DestBuffer, 300, 8);
            Array.Copy(InputBuffer, 0, DestBuffer, 0x134, 12);
            Array.Copy(Signature, 0, DestBuffer, 320, 0x80);
            Array.Copy(Source, 0, DestBuffer, 0x1C0, 0x1A8);
            Array.Copy(EncryptedHMAC, 0, DestBuffer, 0x3E0, 0x34);
            Array.Copy(ClientName, 0, DestBuffer, 0x430, 15);
            // Connect and send packet
            UdpClient XEAS = new UdpClient();

            XEAS.Connect("XEAS.XBOXLIVE.COM", 0x58);
            XEAS.Send(DestBuffer, DestBuffer.Length);
            IPEndPoint RemoteEP = new IPEndPoint(0L, 0);
            int        Wait     = 0;

            while (true)
            {
                try {
                    Thread.Sleep(10);
                    if (XEAS.Available > 0)
                    {
                        byte[] RecBuffer = XEAS.Receive(ref RemoteEP);
                        byte[] Buffer    = new byte[0x6C];
                        Array.Copy(RecBuffer, 0x35, Buffer, 0, 0x6C);
                        byte[] DecryptNoonce   = RC4HMACDecrypt(ComputeKdcNoonce(TimeTick, 0x10), 0x10, RecBuffer, 0x6C, 0x4B3);
                        byte[] SecondaryBuffer = new byte[0x10];
                        Array.Copy(DecryptNoonce, 0x4C, SecondaryBuffer, 0, 0x10);
                        return(SecondaryBuffer);
                    }
                    Thread.Sleep(500);

                    if (Wait++ == 10)
                    {
                        return(null);
                    }
                } catch { }
            }
        }