コード例 #1
0
        /// <summary>
        /// Reads the information from the given .ab file
        /// </summary>
        /// <param name="path">The path of the .ab file</param>
        /// <param name="password">The password to use</param>
        /// <returns>The BackupFileInfo instance</returns>
        public static BackupFileInfo FromFile(string path, string password = "******")
        {
            BackupFileInfo result = new BackupFileInfo();

            Java.Update();
            string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[] { "-debug", "info", "\"" + path + "\"", password });

            result.magic      = output.Between("Magic: ", "\r\n");
            result.algorithm  = output.Between("Algorithm: ", "\r\n");
            result.compressed = (output.Between("Compressed: ", "\r\n").Contains("1") ? true : false);
            result.version    = (output.Between("Version: ", "\r\n").Contains("1") ? BackupFileVersion.Version1 : BackupFileVersion.Version2);

            BackupFileEncryptedInformation ei = new BackupFileEncryptedInformation();

            if (!output.Contains("Exception") && output.Contains("IV: "))
            {
                ei.iV         = output.Between("IV: ", "\r\n");
                ei.keyBytes   = output.Between("key bytes: ", "\r\n");
                ei.keyFormat  = output.Between("Key format: ", "\r\n");
                ei.mK         = output.Between("MK: ", "\r\n");
                ei.mKAsString = output.Between("MK as string: ", "\r\n");
                ei.mKChecksum = output.Between("MK checksum: ", "\r\n");
                ei.saltBytes  = output.Between("salt bytes: ", "\r\n");
            }
            result.encrytedInformation = ei;

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// When this returns true the system is able to deal with crypted backup files. If not you have to download the files from http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html and put them in the lib/security folder of all your Java SE 7 or 8 installations
        /// </summary>
        public static bool SystemIsAbleToDealWithEncryptedFiles()
        {
            Java.Update();
            string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[0]);

            return(output.Contains("Strong AES encryption allowed"));
        }
コード例 #3
0
        /// <summary>
        /// Packs the .ab file from the given .tar file
        /// </summary>
        /// <param name="sourceTarFile">The tar file to pack</param>
        /// <param name="targetAbFile">The target ab file</param>
        /// <param name="version">The version of the .ab file. Use <see cref="BackupFileVersion.Version2"/> for Android 4.4.3 or higher</param>
        /// <param name="password">The password used</param>
        /// <returns>True if the process was successful</returns>
        public static bool PackFromTarFile(string sourceTarFile, string targetAbFile, BackupFileVersion version = BackupFileVersion.Version1, string password = "")
        {
            try
            {
                Java.Update();
                string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[] { "-debug", version == BackupFileVersion.Version1 ? "pack" : "pack-kk", "\"" + sourceTarFile + "\"", "\"" + targetAbFile + "\"", password });

                return(output.Contains("bytes written to") && System.IO.File.Exists(targetAbFile) && new FileInfo(targetAbFile).Length > 0);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// Extracts the file to the specified tar file
        /// </summary>
        /// <param name="targetPath">The path of the tar file</param>
        /// <returns>If the process was successful</returns>
        public bool ExtractToTarFile(string targetPath)
        {
            try
            {
                Java.Update();
                string output = Java.RunJarWithOutput(ResourceManager.abePath, new string[] { "-debug", "unpack", "\"" + mFilePath + "\"", "\"" + targetPath + "\"", mPassword });

                return(output.Contains("bytes written to") && System.IO.File.Exists(targetPath) && new FileInfo(targetPath).Length > 0);
            }
            catch (Exception)
            {
                return(false);
            }
        }