/// <summary>
        /// Get the file list from the mbdb file
        /// </summary>
        /// <param name="BackupPath"></param>
        /// <returns></returns>
        public static List <MBDBFile> ReadMBDB(string iTunesBackupFolder)
        {
            List <MBDBFile>           mbdbFiles = new List <MBDBFile>();
            SHA1CryptoServiceProvider sha1Crypt = new SHA1CryptoServiceProvider();
            FileStream fs = new FileStream(iTunesBackupFolder + "Manifest.mbdb", FileMode.Open, FileAccess.Read);

            byte[] MbdbBuffer = GetBuffer(fs, 6);

            //Check first bytes of mbdb file
            if (GetHexStringByByteArray(MbdbBuffer) != "6d6264620500")
            {
                return(null);
            }
            else
            {
                for (int i = 0; fs.Position < fs.Length; ++i)
                {
                    //Getting the domain and filepath
                    MBDBFile MbdbFile = new MBDBFile()
                    {
                        Domain   = GetNextBufferString(fs),
                        FilePath = GetNextBufferString(fs)
                    };

                    //Encrypting domain and filepath to get the right filename
                    byte[] sha1Buffer = sha1Crypt.ComputeHash(ASCIIEncoding.UTF8.GetBytes(string.Format("{0}-{1}", MbdbFile.Domain, MbdbFile.FilePath)));
                    MbdbFile.EncryptedFilename = GetHexStringByByteArray(sha1Buffer);

#if DEBUG
                    if (MbdbFile.Domain.StartsWith("com.apple.TextEncoding") || MbdbFile.Domain.StartsWith("com.apple.assetsd"))
                    {
                        //Do we need to do anything here??
                    }
                    else
                    {
#endif
                    //Add MbdbFile to list
                    mbdbFiles.Add(MbdbFile);

                    //Ignoring the rest
                    NextFile(fs);
#if DEBUG
                }
#endif
                }

                return(mbdbFiles);
            }
        }
Пример #2
0
        /// <summary>
        /// Get the file list from the mbdb file
        /// </summary>
        /// <param name="BackupPath"></param>
        /// <returns></returns>
        public static List <MBDBFile> ReadMBDB(string iTunesBackupFolder)
        {
            List <MBDBFile>           mbdbFiles = new List <MBDBFile>();
            SHA1CryptoServiceProvider sha1Crypt = new SHA1CryptoServiceProvider();
            FileStream fs = new FileStream(Path.Combine(iTunesBackupFolder, Constants.ManifestFile), FileMode.Open, FileAccess.Read);

            byte[] MbdbBuffer = GetBuffer(fs, 6);

            //Check first bytes of mbdb file
            if (GetHexStringByByteArray(MbdbBuffer) != Constants.MbdbFirstBytes)
            {
                return(null);
            }
            else
            {
                for (int i = 0; fs.Position < fs.Length; ++i)
                {
                    //Getting the domain and filepath
                    MBDBFile MbdbFile = new MBDBFile()
                    {
                        Domain   = GetNextBufferString(fs),
                        FilePath = GetNextBufferString(fs)
                    };

                    //Encrypting domain and filepath to get the right filename
                    byte[] sha1Buffer = sha1Crypt.ComputeHash(ASCIIEncoding.UTF8.GetBytes(string.Format("{0}-{1}", MbdbFile.Domain, MbdbFile.FilePath)));
                    MbdbFile.EncryptedFilename = GetHexStringByByteArray(sha1Buffer);

                    //Add MbdbFile to list
                    mbdbFiles.Add(MbdbFile);

                    //Ignoring the rest
                    NextFile(fs);
                }

                return(mbdbFiles);
            }
        }