bool xEncrypt(ref DJsIO xNewPayload) { try { if (!xSuccess) { return(false); } if (xIsLive) { byte[] xService = (ThisType == AccountType.Stock ? new byte[] { 0x50, 0x52, 0x4F, 0x44 } : // PROD new byte[] { 0x50, 0x41, 0x53, 0x54 }); // PART xNewPayload.Position = 0x34; xNewPayload.Write(xService); xNewPayload.Flush(); } List <byte> xReturn = new List <byte>(); byte[] xConfounder = xRC4.NewConfounder(8); byte[] NewPay = xNewPayload.ReadStream(); xNewPayload.Dispose(); byte[] xHeaderKey = xComputeHeaderKey(xConfounder, NewPay); xRC4.KeyBinary = xComputeRC4Key(xHeaderKey); xReturn.AddRange(xHeaderKey); xReturn.AddRange(xRC4.KerberosEncrypt(ref xConfounder, ref NewPay)); IO.Position = 0; IO.Write(xReturn.ToArray()); IO.Flush(); return(true); } catch { return(false); } }
/// <summary> /// Initializes this object /// </summary> /// <param name="FileLocale"></param> public MusicFile(string FileLocale) { xActive = true; DJsIO xIO = new DJsIO(FileLocale, DJFileMode.Open, true); if (!xIO.Accessed) { throw STFSExcepts.ParseError; } try { xIO.Position = 0; xIO.IsBigEndian = true; if (xIO.ReadUInt32() != 0x464D494D) { throw MusicExcepts.NotMusic; } xIO.Position = 0xC; so = xIO.ReadString(StringForm.Unicode, 0x100); al = xIO.ReadString(StringForm.Unicode, 0x100); ar = xIO.ReadString(StringForm.Unicode, 0x100); xIO.Position += 0x200; ge = xIO.ReadString(StringForm.Unicode, 0x100); IO = xIO; xActive = false; } catch { xIO.Dispose(); throw STFSExcepts.ParseError; } }
bool xExtract(string xOut, bool Sub) { if (!VariousFunctions.xCheckDirectory(xOut)) { return(false); } FATXReadContents xread = xRead(); if (xread == null) { return(false); } foreach (FATXFileEntry x in xread.Files) { DJsIO xIOOut = new DJsIO(xOut + "/" + x.Name, DJFileMode.Create, true); if (!xIOOut.Accessed) { continue; } x.xExtract(ref xIOOut); xIOOut.Dispose(); } if (!Sub) { return(true); } foreach (FATXFolderEntry x in xread.Folders) { x.xExtract(xOut + "/" + x.Name, Sub); } return(true); }
private void listBox1_DragDrop(object sender, DragEventArgs e) { menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = false; string[] xfiles = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string x in xfiles) { DJsIO y = null; try { y = new DJsIO(x, DJFileMode.Open, true); } catch { continue; } if (!y.Accessed) { continue; } y.Position = 0; if (y.ReadUInt32() == (uint)AllMagic.CON) { listBox1.Items.Add(x); } y.Dispose(); listBox1.SelectedIndex = listBox1.Items.Count - 1; Application.DoEvents(); if (checkBoxX3.Checked) { fix(listBox1.Items.Count - 1); } } menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = true; }
/// <summary> /// Overwrite the file /// </summary> /// <param name="FileLocale"></param> /// <returns></returns> public bool Inject(string FileLocale) { if (!xref.ActiveCheck()) { return(false); } DJsIO xIO = null; bool success = false; try { xIO = new DJsIO(FileLocale, DJFileMode.Open, true); if (!xIO.Accessed) { throw new Exception(); } success = xInject(xIO); } catch { success = false; } if (xIO != null) { xIO.Dispose(); } return(success & !(xref.xActive = false)); }
/// <summary> /// Initializes a Strong Signed key type of Kit 360's /// </summary> /// <param name="xTypeIn"></param> public RSAParams(StrongSigned xTypeIn) { DJsIO xReader; switch (xTypeIn) { case StrongSigned.LIVE: xReader = new DJsIO(Properties.Resources.XK4, true); break; case StrongSigned.PIRS: xReader = new DJsIO(Properties.Resources.XK5, true); break; default: throw STFSExcepts.NotStrong; } xK.Exponent = new byte[] { 0, 0, 0, 3 }; xK.D = Properties.Resources.XK3; xReader.Position = 0; xK.Modulus = xReader.ReadBytes(0x100); xK.P = xReader.ReadBytes(0x80); xK.Q = xReader.ReadBytes(0x80); xK.DP = xReader.ReadBytes(0x80); xK.DQ = xReader.ReadBytes(0x80); xK.InverseQ = xReader.ReadBytes(0x80); xReader.Dispose(); xM = xTypeIn == StrongSigned.LIVE ? PackageMagic.LIVE : PackageMagic.PIRS; xV = true; }
/// <summary> /// Closes the stream /// </summary> public void Close() { xIO.Dispose(); foreach (FATXPartition x in Partitions) { x.xTable.xAllocTable.Dispose(true); } }
/// <summary> /// Closes the stream /// </summary> public void Close() { if (xIO != null) { xIO.Dispose(); } if (Partitions != null) { foreach (FATXPartition x in Partitions) { x.xTable.xAllocTable.Dispose(true); } } }
/// <summary> /// Runs a Kerberos implemented RC4 decryption /// </summary> /// <param name="xConfounder">The confounder input</param> /// <param name="xPayload">The payload input</param> /// <param name="x">RC4 reference</param> /// <param name="xData">Data to be decrypted</param> /// <param name="xConLen">Length of the Confounder</param> /// <returns></returns> public static bool KerberosDecrypt(this RC4 x, byte[] xData, out byte[] xConfounder, int xConLen, out byte[] xPayload) { xPayload = new byte[0]; xConfounder = new byte[0]; try { DJsIO xOut = new DJsIO(x.RunAlgorithm(xData), true); xOut.Position = 0; xConfounder = xOut.ReadBytes(xConLen); xPayload = xOut.ReadBytes(xData.Length - xConLen); xOut.Dispose(); } catch { return(false); } return(true); }
bool xWriteHeader(RSAParams xParams) { try { DJsIO xio = new DJsIO(true); xHeaderData.Write(ref xio); xio.SetLength(0xB000); xio.Position = 0x340; xio.Write((uint)0xAD0E); xio.Position = 0x379; xio.Write(new byte[] { 0x24, 5, 5, 0x11 }); IO.Position = 0x37D; xio.Write(IO.ReadBytes(20)); xio.Write((byte)((xIsShifted ? 1 : 0) << 6)); xio.WriteUInt24(xBlockCount); xio.Write(xDeviation); xio.Flush(); xio.Position = 0x344; byte[] xHash = SHA1Quick.ComputeHash(xio.ReadBytes((int)(xio.Length - 0x344))); xio.Position = 0x32C; xio.Write(xHash); xio.Flush(); xio.Position = 0x22C; xHash = SHA1Quick.ComputeHash(xio.ReadBytes(0x118)); xio.Position = 4; if (xParams.Type == PackageMagic.CON) { xio.Write(xParams.Certificate); xio.Write(ScrambleMethods.StockScramble(RSAQuick.SignatureGenerate(xParams.RSAKeys, xHash), true)); } else { xio.Write(ScrambleMethods.DevScramble(RSAQuick.SignatureGenerate(xParams.RSAKeys, xHash))); xio.Write(new byte[0x128]); } xio.IsBigEndian = true; xio.Position = 0; xio.Write(((uint)xParams.Type)); xio.Flush(); xHeaderData.xMagic = xParams.Type; IO.Position = 0; IO.Write(xio.ReadStream()); IO.Flush(); xio.Dispose(); return(true); } catch { return(false); } }
/// <summary> /// Extracts the image via a file location /// </summary> /// <param name="fileOut"></param> /// <returns></returns> public bool ExtractImage(string fileOut) { if (ActiveCheck()) { return(false); } DJsIO xIOOut = null; try { xIOOut = new DJsIO(fileOut, DJFileMode.Create, true); } catch { return(xactive = false); } if (!xIOOut.Accessed) { return(xactive = false); } bool result = extractimg(xIOOut); xIOOut.Dispose(); return(result); }
private void AddFiles(IEnumerable <string> files) { var existing = false; foreach (var file in files) { if (string.IsNullOrWhiteSpace(file)) { return; } for (var i = 0; i < fileList.Items.Count; i++) { if (!String.Equals(fileList.Items[i].Text, Path.GetFileName(file), StringComparison.InvariantCultureIgnoreCase)) { continue; } MessageBox.Show("There is already a file with the name " + Path.GetFileName(file) + "!\nIf you want to overwrite that file, right click on it and choose\n'Replace selected file'", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); existing = true; } if (existing) { continue; } if (Path.GetExtension(file) == ".mogg") { Tools.WriteOutData(Tools.DeObfM(File.ReadAllBytes(file)), file); } var x = new DJsIO(file, DJFileMode.Open, true); if (!x.Accessed) { return; } xPackage.MakeFile(x.FileNameShort, x, ((FolderEntry)folderTree.SelectedNode.Tag).EntryID, AddType.NoOverWrite); x.Dispose(); xReturn_NodeClick(folderTree.SelectedNode, null); Log("Added file " + x.FileNameShort + " successfully"); ShowChanges(true); } }
/// <summary> /// Writes the legal documentation to a local location /// </summary> public static void WriteLegalLocally() { DJsIO xIO = new DJsIO(Application.StartupPath + "/" + "X360 READ ME.txt", DJFileMode.Create, true); if (!xIO.Accessed) { return; } xIO.Position = 0; xIO.Write("------------ Legal Info ------------" + Environment.NewLine); xIO.Write(Legal + Environment.NewLine); xIO.Write("------------------------------------" + Environment.NewLine); xIO.Write("------- Terms and Conditions -------" + Environment.NewLine); xIO.Write(GNUProtected + Environment.NewLine); xIO.Write("------------------------------------" + Environment.NewLine); xIO.Write("----------- GNU License ------------" + Environment.NewLine); xIO.Write(PublicResources.GPL + Environment.NewLine); xIO.Write("------------------------------------"); xIO.Flush(); xIO.Dispose(); }
private void addFileToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; ofd.Title = "Open Xbox Live Packages"; ofd.Filter = ""; if (ofd.ShowDialog() != DialogResult.OK) { return; } menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = false; progressBarX1.Value = 0; progressBarX1.Maximum = ofd.FileNames.Length; foreach (string x in ofd.FileNames) { DJsIO y = null; try { y = new DJsIO(x, DJFileMode.Open, true); } catch { progressBarX1.Value++; continue; } if (!y.Accessed) { progressBarX1.Value++; continue; } y.Position = 0; if (y.ReadUInt32() == (uint)AllMagic.CON) { listBox1.Items.Add(x); } y.Dispose(); if (checkBoxX3.Checked) { fix(listBox1.Items.Count - 1); } progressBarX1.Value++; } menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = true; }
/// <summary> /// Attempts to find the type of the file /// </summary> /// <param name="FileLocale"></param> /// <returns></returns> public static XboxFileType ReadFileType(string FileLocale) { /* ADD FATX SUPPORT */ DJsIO xIO = new DJsIO(FileLocale, DJFileMode.Open, true); try { XboxFileType xReturn = XboxFileType.None; xIO.Position = 0; uint sig = xIO.ReadUInt32(); switch (sig) { case (uint)AllMagic.CON: case (uint)AllMagic.LIVE: case (uint)AllMagic.PIRS: { if (xIO.Length < 0x37C) { break; } xIO.Position = 0x379; byte[] desc = xIO.ReadBytes(3); if (desc[0] == 0x24 && desc[1] == 0 && (desc[2] == 0 || desc[2] == 1 || desc[2] == 2)) { xReturn = XboxFileType.STFS; } else if (desc[0] == 0x24 && desc[1] == 5 && desc[2] == 5) { xReturn = XboxFileType.SVOD; } } break; case (uint)AllMagic.Music: { xReturn = XboxFileType.Music; } break; case (uint)AllMagic.XDBF: { xReturn = XboxFileType.GPD; } break; case 0: { if (xIO.Length < 0x130EB0004) { break; } xIO.Position = 0x130EB0000; if (xIO.ReadUInt32() != (uint)AllMagic.FATX) { break; } xReturn = XboxFileType.FATX; } break; case (uint)AllMagic.XSF: { xReturn = XboxFileType.GDF; } break; default: break; } if (xReturn == XboxFileType.None) { try { xIO.Position = 0; if (xIO.ReadBytes(20).HexString() != GDFX.GDFMagic.XMedia.HexString()) { xIO.Position = 0x1FB20; if (xIO.ReadBytes(20).HexString() != GDFX.GDFMagic.XMedia.HexString()) { xIO.Position = 0x30600; if (xIO.ReadBytes(20).HexString() != GDFX.GDFMagic.XMedia.HexString()) { xIO.Position = 0x7FF000; if (xIO.ReadUInt32() != (uint)AllMagic.FATX) { xIO.Position = 0xFDA0000; if (xIO.ReadBytes(20).HexString() != GDFX.GDFMagic.XMedia.HexString()) { xIO.Position = 0x130EB0000; if (xIO.ReadUInt32() == (uint)AllMagic.FATX) { xReturn = XboxFileType.FATX; } } else { xReturn = XboxFileType.GDF; } } else { xReturn = XboxFileType.FATX; } } else { xReturn = XboxFileType.GDF; } } else { xReturn = XboxFileType.GDF; } } else { xReturn = XboxFileType.GDF; } } catch { } } xIO.Dispose(); return(xReturn); } catch (Exception x) { xIO.Close(); throw x; } }
/// <summary> /// Attempts to find the type of the file /// </summary> /// <param name="FileLocale"></param> /// <returns></returns> public static XboxFileType ReadFileType(string FileLocale) { /* ADD FATX SUPPORT */ var xIO = new DJsIO(FileLocale, DJFileMode.Open, true); try { var xReturn = XboxFileType.None; xIO.Position = 0; var sig = xIO.ReadUInt32(); switch (sig) { case (uint)AllMagic.CON: case (uint)AllMagic.LIVE: case (uint)AllMagic.PIRS: { if (xIO.Length < 0x37C) { break; } xIO.Position = 0x379; var desc = xIO.ReadBytes(3); if (desc[0] == 0x24 && desc[1] == 0 && (desc[2] == 0 || desc[2] == 1 || desc[2] == 2)) { xReturn = XboxFileType.STFS; } else if (desc[0] == 0x24 && desc[1] == 5 && desc[2] == 5) { xReturn = XboxFileType.SVOD; } } break; case (uint)AllMagic.Music: { xReturn = XboxFileType.Music; } break; case (uint)AllMagic.XDBF: { xReturn = XboxFileType.GPD; } break; case 0: { if (xIO.Length < 0x130EB0004) { break; } xIO.Position = 0x130EB0000; if (xIO.ReadUInt32() != (uint)AllMagic.FATX) { break; } xReturn = XboxFileType.FATX; } break; case (uint)AllMagic.XSF: { xReturn = XboxFileType.GDF; } break; } xIO.Dispose(); return(xReturn); } catch (Exception) { xIO.Close(); return(XboxFileType.None); //throw; } }
/// <summary> /// Loads the profile information from the package /// </summary> /// <param name="xboth"></param> /// <returns></returns> bool LoadProfile(bool xboth) { if (!ParseCheck()) { return(false); } new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(System.DLLIdentify.PrivilegeCheck)).Start(System.Threading.Thread.CurrentThread); bool xreturn = true; if (xboth) { FileEntry xacct = GetFile("Account"); if (xacct != null && xacct.Size == 404) { if (HasValidAccount) { xUserFile.IO.Dispose(); } AddToLog("Parsing Account file"); DJsIO xAcctIO = xacct.GetTempIO(true); if (xAcctIO == null || !xAcctIO.Accessed) { if (xAcctIO != null) { xAcctIO.Dispose(); VariousFunctions.DeleteFile(xAcctIO.FileNameLong); } } else { xUserFile = new UserAccount(xAcctIO, AccountType.Stock, true); xreturn = xUserFile.Success; if (!xUserFile.Success) { xUserFile = new UserAccount(xAcctIO, AccountType.Kits, true); xreturn = xUserFile.Success; if (!xUserFile.Success) { xUserFile = null; } } } } } FileEntry xdash = GetFile("FFFE07D1.gpd"); if (xdash != null) { AddToLog("Parsing User GPD"); DJsIO xFFIO = xdash.GetTempIO(true); if (xFFIO == null || !xFFIO.Accessed) { if (xFFIO != null) { VariousFunctions.DeleteFile(xFFIO.FileNameLong); } } else { try { xFFIO.Close(); if (HasDashGPD) { xUserGPD.xIO.Dispose(); } xUserGPD = new DashGPD(xFFIO.FileNameLong); xreturn &= xUserGPD.IsValid; if (!xUserGPD.IsValid) { xUserGPD = null; xFFIO.Dispose(); VariousFunctions.DeleteFile(xFFIO.FileNameLong); } } catch { xUserGPD = null; } } } return(xreturn); }
/// <summary> /// Determins if a Drive is FATX format /// </summary> /// <param name="xIO">Stream to check</param> /// <param name="xType">Grabs the type of drive</param> /// <returns></returns> public static bool IsFATX(ref DJsIO xIO, out DriveTypes xType) { // Tries to read the offsets of Xbox 360 drives to see if the magic's match xType = DriveTypes.Unknown; try { xIO.Position = (long)MU.Partition2; if (xIO.ReadUInt32() == (uint)AllMagic.FATX) { xType = DriveTypes.MemoryUnit; return(true); } } catch { } try { if (xIO.IOType != DataType.Drive || ((DriveIO)xIO).xDrive.Type != DeviceType.LogicalDrive) { throw new Exception(); } string dat0 = ((DriveIO)xIO).xDrive.DeviceName + @"\Xbox360\Data0000"; if (!File.Exists(dat0)) { throw new Exception(); } DJsIO xio = new DJsIO(dat0, DJFileMode.Open, true); if (!xio.Accessed) { throw new Exception(); } xio.Position = (long)USB.Partition1; try { if (xio.ReadUInt32() == (uint)AllMagic.FATX) { xType = DriveTypes.USBFlashDrive; xio.Dispose(); return(true); } } catch { } xio.Dispose(); } catch { } try { xIO.Position = (long)HDD.Partition5; if (xIO.ReadUInt32() == (uint)AllMagic.FATX) { xType = DriveTypes.HardDrive; return(true); } } catch { } try { xIO.Position = 8; xIO.Position = (xIO.ReadUInt32() * 0x200); if (xIO.ReadUInt32() == (uint)AllMagic.FATX) { xType = DriveTypes.DevHardDrive; return(true); } } catch { } return(false); }