Ejemplo n.º 1
0
        /// <inheritdoc />
        public override void Import(PwDatabase db, System.IO.Stream input, IStatusLogger logger)
        {
            try
            {
                ImportDialog form;

                while (true)
                {
                    form = new ImportDialog(db);

                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    if (string.IsNullOrEmpty(form.ProfilePath))
                    {
                        MessageBox.Show(
                            "No Profile Selected. Use Load More Profiles",
                            "Profile Required",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error
                            );
                    }
                    else
                    {
                        break;
                    }
                }

                try
                {
                    logger.StartLogging("Importing Firefox Passwords", false);
                    logger.SetText("Logging in", LogStatusType.Info);

                    using (var profile = new Profile(form.ProfilePath, form.Password))
                    {
                        logger.SetText("Reading the signon file", LogStatusType.Info);
                        IEnumerable <Signon> signons = profile.GetSignons();
                        ProcessSignonsAsync(signons, form, db, logger).GetAwaiter().GetResult();
                    }
                }
                finally
                {
                    logger.EndLogging();
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Failed to Validate Password"))
                {
                    MessageBox.Show(ex.Message, "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    ErrorDialog.Show("Import Failed", ex);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save the contents of the current <c>PwDatabase</c> to a KDB file.
        /// </summary>
        /// <param name="strSaveToFile">Location to save the KDB file to.</param>
        public void Save(string strSaveToFile, PwGroup pgDataSource)
        {
            Debug.Assert(strSaveToFile != null);
            if (strSaveToFile == null)
            {
                throw new ArgumentNullException("strSaveToFile");
            }

            using (KdbManager mgr = new KdbManager())
            {
                KdbErrorCode e = KdbFile.SetDatabaseKey(mgr, m_pwDatabase.MasterKey);
                if (e != KdbErrorCode.Success)
                {
                    Debug.Assert(false);
                    throw new Exception(KLRes.InvalidCompositeKey);
                }

                if (m_slLogger != null)
                {
                    if (m_pwDatabase.MasterKey.ContainsType(typeof(KcpUserAccount)))
                    {
                        m_slLogger.SetText(KPRes.KdbWUA, LogStatusType.Warning);
                    }

                    if (m_pwDatabase.Name.Length != 0)
                    {
                        m_slLogger.SetText(KdbPrefix + KPRes.FormatNoDatabaseName, LogStatusType.Warning);
                    }
                    if (m_pwDatabase.Description.Length != 0)
                    {
                        m_slLogger.SetText(KdbPrefix + KPRes.FormatNoDatabaseDesc, LogStatusType.Warning);
                    }
                }

                // Set properties
                if (m_pwDatabase.KeyEncryptionRounds >= (ulong)UInt32.MaxValue)
                {
                    mgr.KeyTransformationRounds = 0xFFFFFFFEU;
                }
                else
                {
                    mgr.KeyTransformationRounds = (uint)m_pwDatabase.KeyEncryptionRounds;
                }

                PwGroup pgRoot = (pgDataSource ?? m_pwDatabase.RootGroup);

                // Write groups and entries
                Dictionary <PwGroup, UInt32> dictGroups = WriteGroups(mgr, pgRoot);
                WriteEntries(mgr, dictGroups, pgRoot);

                e = mgr.SaveDatabase(strSaveToFile);
                if (e != KdbErrorCode.Success)
                {
                    throw new Exception(KLRes.FileSaveFailed);
                }
            }
        }
Ejemplo n.º 3
0
        public override void Import(PwDatabase pwDatabase, Stream input, IStatusLogger statusLogger)
        {
            ConfigurationForm configurationForm = new ConfigurationForm();

            statusLogger.StartLogging("OPVault file import", true);

            if (configurationForm.ShowDialog() == DialogResult.OK)
            {
                statusLogger.SetText("Parsing OPVault file...", LogStatusType.Info);

                string          defaultDir = Path.Combine(configurationForm.ImportDirPath, "default");
                Records.Profile profile    = oneVaultParser.ParseProfile(Path.Combine(defaultDir, "profile.js"), configurationForm.MasterPassword);

                if (profile == null)
                {
                    MessageBox.Show("Could not read profile file.", "Invalid OPVault", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (profile.masterKey == null || profile.overviewKey == null)
                {
                    MessageBox.Show("Please check the master password is correct.", "Error processing OPVault", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    List <Records.BaseRecord> records = oneVaultParser.ParseFolders(Path.Combine(defaultDir, "folders.js"), profile);
                    Dictionary <string, Records.AttachmentMetadata> attachments = new Dictionary <string, Records.AttachmentMetadata>();

                    for (int i = 0; i < 16; i++)
                    {
                        records.AddRange(oneVaultParser.ParseItems(Path.Combine(defaultDir, string.Format("band_{0:X}.js", i)), profile));
                    }

                    foreach (string attachmentFilePath in Directory.GetFiles(defaultDir, "*.attachment"))
                    {
                        Records.AttachmentMetadata attachmentMetadata = oneVaultParser.ParseAttachments(attachmentFilePath, profile);
                        Records.BaseRecord         item = records.Find(r => r.uuid.Equals(attachmentMetadata.itemUUID));
                        if (item is Records.ItemRecord)
                        {
                            (item as Records.ItemRecord).AddAttachment(attachmentFilePath, attachmentMetadata);
                        }
                    }

                    statusLogger.SetText(string.Format("Importing {0} parsed records...", records.Count), LogStatusType.Info);
                    oneVaultImporter.Import(records, pwDatabase, statusLogger, configurationForm.GetUserPrefs());
                    statusLogger.SetText("Finished import.", LogStatusType.Info);
                }
            }
            else
            {
                statusLogger.SetText("Import cancelled.", LogStatusType.Info);
            }

            statusLogger.EndLogging();
        }
Ejemplo n.º 4
0
        /// <summary>Read from a xml file</summary>
        /// <param name="pwStorage">The database in which the new entry is inserted</param>
        /// <param name="sInput">A stream on the xml file/entry</param>
        /// <param name="slLogger">Logger to be used</param>
        public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger)
        {
            slLogger.SetText("Lese XML", new LogStatusType());

            XmlSerializer xml  = new XmlSerializer(typeof(WlanProfile));
            WlanProfile   wlan = (WlanProfile)xml.Deserialize(sInput);

            slLogger.SetText("Suche vorhandenen Gruppeneintrag", LogStatusType.Info);
            PwGroup group = GetStandardGroup(pwStorage, true);

            slLogger.SetText("Füge Eintrag hinzu", LogStatusType.Info);
            ImportTo(wlan, pwStorage, group, BehaviourForExEntry.ASK_USER, slLogger, 80, 20);
        }
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger)
        {
            slLogger.SetText("Collecting entries...", LogStatusType.Info);

            var entries = ConvertGroup(pwExportInfo.DataGroup, slLogger);

            slLogger.SetText("Encrypting backup...", LogStatusType.Info);

            var filewriter = new StreamWriter(sOutput);

            filewriter.Write(entries);
            filewriter.Flush();

            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Update a single plugin
        /// </summary>
        /// <param name="upd">Update information for plugin</param>
        /// <param name="sPluginFolder">Target folder for plugin file</param>
        /// <param name="sTranslationFolder">Target folder for plugin translations</param>
        /// <param name="bTranslationsOnly">Only download newest translations</param>
        /// <returns></returns>
        internal bool UpdatePlugin(PluginUpdate upd, string sPluginFolder, bool bTranslationsOnly)
        {
            bool bOK = true;

            if (m_slUpdatePlugins != null)
            {
                m_slUpdatePlugins.SetText(string.Format(PluginTranslate.PluginUpdating, upd.Title), LogStatusType.Info);
            }
            if (!bTranslationsOnly)
            {
                bOK = upd.Download(sPluginFolder);
            }
            if (upd is OwnPluginUpdate)
            {
                bool bTranslationsOK = (upd as OwnPluginUpdate).DownloadTranslations(sPluginFolder, PluginConfig.DownloadActiveLanguage, bTranslationsOnly);
                if (bTranslationsOnly)
                {
                    bOK = bTranslationsOK;
                }
            }
            if (bOK)
            {
                bOK = upd.ProcessDownload(sPluginFolder);
            }
            upd.Cleanup();
            return(bOK);
        }
Ejemplo n.º 7
0
        public override void Import(PwDatabase pwStorage, System.IO.Stream sInput, IStatusLogger slLogger)
        {
            var document = new XmlDocument();

            document.Load(sInput);



            var root     = document.DocumentElement.SelectSingleNode("YourKey");
            var products = root.SelectNodes("Product_Key");

            if (products == null || products.Count == 0)
            {
                return;
            }

            var msdnGroup = pwStorage.RootGroup.FindCreateGroup("Microsoft Product Keys", true);

            for (int i = 0; i < products.Count; i++)
            {
                var product = new Product(products[i]);
                slLogger.SetText(string.Format("{0} ({1} of {2})", product.Name, i + 1, products.Count), LogStatusType.Info);
                AddProduct(pwStorage, msdnGroup, product);
            }
        }
        public override void Import(PwDatabase storage, Stream input, IStatusLogger status)
        {
            status.SetText("Parsing .pif ...", LogStatusType.Info);
            List <BaseRecord> baseRecords = _pifParser.Parse(input);

            _pifImporter.Import(baseRecords, storage, status);
        }
Ejemplo n.º 9
0
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
                                    IStatusLogger slLogger)
        {
            PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase());

            string strTempFile = Program.TempFilesPool.GetTempFileName(false);

            try
            {
                KdbFile kdb = new KdbFile(pd, slLogger);
                kdb.Save(strTempFile, pwExportInfo.DataGroup);

                byte[] pbKdb = File.ReadAllBytes(strTempFile);
                sOutput.Write(pbKdb, 0, pbKdb.Length);
                MemUtil.ZeroByteArray(pbKdb);
            }
            catch (Exception exKdb)
            {
                if (slLogger != null)
                {
                    slLogger.SetText(exKdb.Message, LogStatusType.Error);
                }

                return(false);
            }
            finally
            {
                Program.TempFilesPool.Delete(strTempFile);
            }

            return(true);
        }
Ejemplo n.º 10
0
        public void Import(List <BaseRecord> baseRecords, PwDatabase storage, IStatusLogger status)
        {
            var records        = new List <BaseRecord>();
            var trashedRecords = new List <BaseRecord>();

            baseRecords.ForEach(record =>
            {
                if (record.trashed)
                {
                    trashedRecords.Add(record);
                }
                else
                {
                    records.Add(record);
                }
            });


            var tree = BuildTree(records);

            status.SetText("Importing records..", LogStatusType.Info);

            PwGroup root = new PwGroup(true, true);

            root.Name = "1Password Import on " + DateTime.Now.ToString();


            foreach (var node in tree)
            {
                ImportRecord(node, root, storage);
            }

            if (trashedRecords.Count > 0)
            {
                PwGroup trash = new PwGroup(true, true)
                {
                    Name = "Trash", IconId = PwIcon.TrashBin
                };

                foreach (var trecord in trashedRecords)
                {
                    var wfrecord = trecord as WebFormRecord;
                    if (wfrecord != null)
                    {
                        PwEntry entry = wfrecord.CreatePwEntry(storage);

                        if (entry != null)
                        {
                            trash.AddEntry(entry, true);
                        }
                    }
                }
                root.AddGroup(trash, true);
            }

            storage.RootGroup.AddGroup(root, true);
        }
Ejemplo n.º 11
0
        /// <summary>Writes to a xml file</summary>
        /// <param name="pwExportInfo">The information to be exported</param>
        /// <param name="sOutput">A stream to the xml file/entry</param>
        /// <param name="slLogger">Logger to be used</param>
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger)
        {
            XmlSerializer xml        = new XmlSerializer(typeof(WlanProfile));
            WlanProfile   curProfile = new WlanProfile();

            if (slLogger != null)
            {
                slLogger.SetText("Schreibe XML", LogStatusType.Info);
                slLogger.SetProgress(0);
            }

            double progress = 0;
            String name;

            foreach (PwEntry entry in pwExportInfo.DataGroup.GetEntries(true))
            {
                if (slLogger != null)
                {
                    name = entry.Strings.Get(PwDefs.TitleField).ReadString();
                    if ((name == null) || (name.Length == 0))
                    {
                        name = entry.Strings.Get(FieldNames.SSID).ReadString();
                        if ((name == null) || (name.Length == 0))
                        {
                            continue;
                        }
                    }

                    slLogger.SetText(String.Format("Schreibe Wifi-Information {0}", name), LogStatusType.Info);
                    progress += 50 / pwExportInfo.DataGroup.GetEntriesCount(true);
                    slLogger.SetProgress((uint)progress);
                }

                curProfile.LoadFrom(pwExportInfo.ContextDatabase, entry);
                xml.Serialize(sOutput, curProfile);
                if (slLogger != null)
                {
                    progress += 50 / pwExportInfo.DataGroup.GetEntriesCount(true);
                    slLogger.SetProgress((uint)progress);
                }
            }

            return(true);
        }
Ejemplo n.º 12
0
        // report error details
        private void reportError(String msg, String heading, IStatusLogger slLogger, LogStatusType lst)
        {
            MessageBox.Show(msg,
                            heading,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation,
                            MessageBoxDefaultButton.Button1);

            slLogger.SetText(msg, lst);
        }
Ejemplo n.º 13
0
        public override void Import(KeePassLib.PwDatabase pwStorage, System.IO.Stream sInput, IStatusLogger slLogger)
        {
            if (pwStorage == null)
            {
                throw new ArgumentNullException("CardFileFormatProvider.Import(): null PwDatabase argument received");
            }
            if (!pwStorage.IsOpen)
            {
                MessageBox.Show("You first need to open a database!", "CardFileFormatProvider");
                return;
            }
            if (sInput == null)
            {
                throw new ArgumentNullException("CardFileFormatProvider.Import(): null Stream argument received");
            }
            if (slLogger == null)
            {
                throw new ArgumentNullException("CardFileFormatProvider.Import(): null IStatusLogger argument received");
            }
            if (!(sInput.CanRead))
            {
                throw new ArgumentException("Input stream not readable");
            }
            try {
                KPWriter kpWriter = new KPWriter(pwStorage);                     // The plugin's Keepass Writer
                CardFile crdfile  = new CardFile(false, String.Empty, kpWriter); // The plugin's Importer, false = no logging

                slLogger.SetText("Importing Cardfile ...", LogStatusType.Info);
                crdfile.process(sInput);                   // read the cardfile & write to keepass

                m_Host.MainWindow.UpdateUI(false, null, true, m_Host.Database.RootGroup, true, null, true);
                slLogger.SetText("Importing Cardfile completed", LogStatusType.Info);
            } catch (ExnCardFileRdr ex) {
                reportError(ex.Message, "Warning", slLogger, LogStatusType.Warning);
            } catch (FileNotFoundException ex) {
                reportError(ex.Message, "Warning", slLogger, LogStatusType.Warning);
            } catch (DirectoryNotFoundException ex) {
                reportError(ex.Message, "Warning", slLogger, LogStatusType.Warning);
            } catch (Exception ex) {
                reportError(ex.ToString(), "Error", slLogger, LogStatusType.Error);
            }            //try
        }
Ejemplo n.º 14
0
        /// <summary>Read from a xml file</summary>
        /// <param name="pwStorage">The database in which the new entry is inserted</param>
        /// <param name="sInput">A stream on the xml file/entry</param>
        /// <param name="slLogger">Logger to be used</param>
        public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger)
        {
            slLogger.SetText("Lese Systeminformationen", LogStatusType.Info);
            slLogger.SetProgress(0);
            Dictionary <String, WlanProfile> res = GetSystemProfiles(slLogger, 0.0, 15.0);

            slLogger.SetText("Suche vorhandene Gruppen", LogStatusType.Info);
            MSWifiXML xmlImporter = new MSWifiXML();
            PwGroup   group       = xmlImporter.GetStandardGroup(pwStorage, true);

            double progress = 20.0;

            slLogger.SetProgress((uint)progress);

            foreach (KeyValuePair <String, WlanProfile> pair in res)
            {
                slLogger.SetText(String.Format("Füge Eintrag '{0}' hinzu", pair.Key), LogStatusType.Info);

                if (null != xmlImporter.ImportTo(pair.Value, pwStorage, group,
                                                 MSWifiXML.BehaviourForExEntry.ASK_USER,
                                                 slLogger, 75.0 / res.Count, progress))
                {
                    slLogger.SetText(String.Format("Füge Eintrag '{0}' hinzu. Erfolgreich!", pair.Key),
                                     LogStatusType.Info);
                }
                else
                {
                    slLogger.SetText(String.Format("Füge Eintrag '{0}' hinzu. Fehlgeschlagen!", pair.Key),
                                     LogStatusType.Error);
                }
            }

            slLogger.SetText("Schließe ab", new LogStatusType());
            slLogger.SetProgress(100);
        }
Ejemplo n.º 15
0
        public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger)
        {
            var form = new OptionForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            slLogger.SetText("Decrypting backup...", LogStatusType.Info);

            var pfp     = new PfpConvert();
            var protect = Util.GetMemoryProtection(pwStorage.MemoryProtection);

            protect.Add("PIN");
            protect.Add("PUK");
            protect.Add("CVV");

            var entries = pfp.Load(sInput, form.MasterPassword);
            var pw      = pfp.GetPasswordGetter(form.MasterPassword);

            var i = 0;

            foreach (var baseentry in entries)
            {
                if (!(baseentry is PassEntry entry))
                {
                    continue;
                }

                slLogger.SetText($"Importing {entry.name}@{entry.site}...", LogStatusType.Info);

                var pwEntry = Util.GetKeepassEntry(entry, pw, protect);

                pwStorage.RootGroup.AddEntry(pwEntry, true);
                i++;
            }

            slLogger.SetText($"Imported {i} entries.", LogStatusType.Info);
        }
Ejemplo n.º 16
0
        public override void Import(PwDatabase pwDatabase, Stream input, IStatusLogger statusLogger)
        {
            ConfigurationForm configurationForm = new ConfigurationForm();

            statusLogger.StartLogging("1PIF file import", true);

            if (configurationForm.ShowDialog() == DialogResult.OK)
            {
                statusLogger.SetText("Parsing 1PIF file...", LogStatusType.Info);
                List <Records.BaseRecord> records;
                using (Stream importFileStream = File.OpenRead(configurationForm.ImportFilePath))
                    records = onePIFParser.Parse(importFileStream);
                statusLogger.SetText(string.Format("Importing {0} parsed records...", records.Count), LogStatusType.Info);
                onePIFImporter.Import(records, pwDatabase, statusLogger, configurationForm.GetUserPrefs());
                statusLogger.SetText("Finished import.", LogStatusType.Info);
            }
            else
            {
                statusLogger.SetText("Import cancelled.", LogStatusType.Info);
            }

            statusLogger.EndLogging();
        }
        public override void Import(PwDatabase storage, Stream input, IStatusLogger status)
        {
            status.SetText("Parsing .pif ...", LogStatusType.Info);
            var  res             = MessageBox.Show("Create seperate subfolders for each 1PW category (like Logins, Accounts ...)?", "Create Subfolders?", MessageBoxButtons.YesNo);
            bool createSubfolder = false;

            if (res == DialogResult.Yes)
            {
                createSubfolder = true;
            }
            List <BaseRecord> baseRecords = _pifParser.Parse(input);

            _pifImporter.Import(baseRecords, storage, status, createSubfolder);
        }
Ejemplo n.º 18
0
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger)
        {
            var form = new OptionForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            slLogger.SetText("Collecting entries...", LogStatusType.Info);

            var entries = ConvertGroup(pwExportInfo.DataGroup, slLogger);

            slLogger.SetText("Encrypting backup...", LogStatusType.Info);

            var pfp = new PfpConvert();

            pfp.Save(sOutput, form.MasterPassword, entries);

            slLogger.SetText($"Exported {entries.Count} entries.", LogStatusType.Info);

            return(true);
        }
Ejemplo n.º 19
0
        protected void IncreaseLogger()
        {
            if (m_EntryCount == 0)
            {
                return;
            }
            if (m_sl == null)
            {
                return;
            }
            m_EntryIndex++;
            uint percentage = (uint)(100 * m_EntryIndex / m_EntryCount);

            m_sl.SetProgress(percentage);
            m_sl.SetText(percentage.ToString() + "% - " + m_EntryIndex.ToString() + " / " + m_EntryCount.ToString(), LogStatusType.Info);
        }
Ejemplo n.º 20
0
        internal static void ShowLoadError(string strPath, Exception ex,
                                           IStatusLogger slStatus)
        {
            if (string.IsNullOrEmpty(strPath))
            {
                Debug.Assert(false); return;
            }

            if (slStatus != null)
            {
                slStatus.SetText(KPRes.PluginLoadFailed, LogStatusType.Info);
            }

            string strMsg = KPRes.PluginIncompatible + MessageService.NewLine +
                            strPath + MessageService.NewParagraph + KPRes.PluginUpdateHint;

            if (NativeLib.IsUnix())
            {
                strMsg += MessageService.NewParagraph + KPRes.PluginMonoComplete;
            }

            bool bShowExcp = (Program.CommandLineArgs[
                                  AppDefs.CommandLineOptions.Debug] != null);
            string strExcp = ((ex != null) ? StrUtil.FormatException(ex).Trim() : null);

            VistaTaskDialog vtd = new VistaTaskDialog();

            vtd.Content             = strMsg;
            vtd.ExpandedByDefault   = ((strExcp != null) && bShowExcp);
            vtd.ExpandedInformation = strExcp;
            vtd.WindowTitle         = PwDefs.ShortProductName;
            vtd.SetIcon(VtdIcon.Warning);

            if (!vtd.ShowDialog())
            {
                if (!bShowExcp)
                {
                    MessageService.ShowWarning(strMsg);
                }
                else
                {
                    MessageService.ShowWarningExcp(strPath, ex);
                }
            }
        }
Ejemplo n.º 21
0
		public void Import(List<BaseRecord> baseRecords, PwDatabase storage, IStatusLogger status)
		{
			var records = new List<BaseRecord>();
			var trashedRecords = new List<BaseRecord>();

			baseRecords.ForEach(record =>
			{
				if (record.trashed)
					trashedRecords.Add(record);
				else
					records.Add(record);
			});


			var tree = BuildTree(records);

			status.SetText("Importing records..", LogStatusType.Info);
			
			PwGroup root = new PwGroup(true, true);
			root.Name = "1Password Import on " + DateTime.Now.ToString();


			foreach (var node in tree)
			{
				ImportRecord(node, root, storage);
			}

			if (trashedRecords.Count > 0)
			{
				PwGroup trash = new PwGroup(true, true) { Name = "Trash", IconId = PwIcon.TrashBin };

				foreach (var trecord in trashedRecords)
				{
					var wfrecord = trecord as WebFormRecord;
					if (wfrecord != null)
						CreateWebForm(trash, storage, wfrecord);
				}
				root.AddGroup(trash, true);
			}

			storage.RootGroup.AddGroup(root, true);
		}
        public override void Import(PwDatabase pwStorage, System.IO.Stream sInput, IStatusLogger slLogger)
        {
            var document = new XmlDocument();
            document.Load(sInput);

            var root = document.DocumentElement;
            var products = root.SelectNodes("Product_Key");

            if (products == null || products.Count == 0)
                return;

            var msdnGroup = pwStorage.RootGroup.FindCreateGroup("Microsoft Product Keys", true);

            for (int i = 0; i < products.Count; i++ )
            {
                var product = new Product(products[i]);
                slLogger.SetText(string.Format("{0} ({1} of {2})", product.Name, i + 1, products.Count), LogStatusType.Info);
                AddProduct(pwStorage, msdnGroup, product);
            }
        }
Ejemplo n.º 23
0
        public static async Task ProcessSignonsAsync(
            IEnumerable <Signon> signons,
            ImportDialog form,
            PwDatabase db,
            IStatusLogger logger)
        {
            logger.SetText("Processing signons", LogStatusType.Info);

            List <Task> tasks    = signons.Select(signon => AddEntryAsync(signon, form, db, logger)).ToList();
            int         total    = tasks.Count;
            var         progress = 0;

            while (tasks.Count > 0)
            {
                Task completedTask = Task.Factory.ContinueWhenAny(tasks.ToArray(), task => tasks.Remove(task));
                await completedTask.ConfigureAwait(false);

                ++progress;
                logger.SetProgress((uint)(100 * (double)progress / total));
            }
        }
Ejemplo n.º 24
0
        public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger)
        {
            var entries   = new List <Entry>();
            var name      = GetName(sInput);
            var rootGroup = CreateGroup(pwStorage, name);

            using (var reader = new StreamReader(sInput, System.Text.Encoding.UTF8))
            {
                while (!reader.EndOfStream)
                {
                    var entry = Entry.Read(reader);
                    entries.Add(entry);
                }
            }

            for (int i = 0; i < entries.Count; i++)
            {
                var entry = entries[i];
                slLogger.SetText(string.Format("{0} ({1} of {2})", entry.Name, i + 1, entries.Count), LogStatusType.Info);
                AddEntry(pwStorage, rootGroup, entry);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// A PwDatabase extension method that creates a website entry.
        /// </summary>
        /// <param name="pd">The database to act on</param>
        /// <param name="group">The group to insert new entries into</param>
        /// <param name="host">The host</param>
        /// <param name="username">The username</param>
        /// <param name="password">The password</param>
        /// <param name="extractTitle">true to extract the title of the host</param>
        /// <param name="extractIcon">true to extract icon of the host</param>
        /// <param name="logger">The logger</param>
        public static void CreateWebsiteEntry(this PwDatabase pd, PwGroup group, string host, string username, string password, bool extractTitle, bool extractIcon, IStatusLogger logger)
        {
            Contract.Requires(group != null);
            Contract.Requires(host != null);
            Contract.Requires(username != null);
            Contract.Requires(password != null);
            Contract.Requires(logger != null);

            logger.SetText(string.Format("{0} - {1}", username, host), LogStatusType.Info);

            var pe = new PwEntry(true, true);

            group.AddEntry(pe, true);

            pe.Strings.Set(PwDefs.TitleField, new ProtectedString(pd.MemoryProtection.ProtectTitle, host));
            pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(pd.MemoryProtection.ProtectUserName, username));
            pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(pd.MemoryProtection.ProtectPassword, password));
            pe.Strings.Set(PwDefs.UrlField, new ProtectedString(pd.MemoryProtection.ProtectUrl, host));

            if (!string.IsNullOrEmpty(host) && (extractTitle || extractIcon))
            {
                try
                {
                    string content;
                    using (var client = new WebClientEx())
                    {
                        content = client.DownloadString(host);

                        var document = new HtmlDocument();
                        document.LoadHtml(content);

                        if (extractTitle)
                        {
                            var title = document.DocumentNode.SelectSingleNode("/html/head/title");
                            if (title != null)
                            {
                                pe.Strings.Set(PwDefs.TitleField, new ProtectedString(pd.MemoryProtection.ProtectTitle, HttpUtility.HtmlDecode(title.InnerText.Trim())));
                            }
                        }

                        if (extractIcon)
                        {
                            string iconUrl = null;
                            foreach (var prio in new string[] { "shortcut icon", "apple-touch-icon", "icon" })
                            {
                                //iconUrl = document.DocumentNode.SelectNodes("/html/head/link").Where(l => prio == l.Attributes["rel"]?.Value).LastOrDefault()?.Attributes["href"]?.Value;
                                var node = document.DocumentNode.SelectNodes("/html/head/link").Where(l => l.GetAttributeValue("rel", string.Empty) == prio).LastOrDefault();
                                if (node != null)
                                {
                                    iconUrl = node.GetAttributeValue("href", string.Empty);
                                }

                                if (!string.IsNullOrEmpty(iconUrl))
                                {
                                    break;
                                }
                            }

                            if (!string.IsNullOrEmpty(iconUrl))
                            {
                                if (!iconUrl.StartsWith("http://") && !iconUrl.StartsWith("https://"))
                                {
                                    iconUrl = host.TrimEnd('/') + '/' + iconUrl.TrimStart('/');
                                }

                                using (var s = client.OpenRead(iconUrl))
                                {
                                    var icon = Image.FromStream(s);
                                    if (icon.Width > 16 || icon.Height > 16)
                                    {
                                        icon = icon.GetThumbnailImage(16, 16, null, IntPtr.Zero);
                                    }

                                    using (var ms = new MemoryStream())
                                    {
                                        icon.Save(ms, ImageFormat.Png);

                                        var data = ms.ToArray();

                                        foreach (var item in pd.CustomIcons)
                                        {
                                            if (KeePassLib.Utility.MemUtil.ArraysEqual(data, item.ImageDataPng))
                                            {
                                                pe.CustomIconUuid = item.Uuid;

                                                return;
                                            }
                                        }

                                        var pwci = new PwCustomIcon(new PwUuid(true), data);
                                        pd.CustomIcons.Add(pwci);
                                        pe.CustomIconUuid = pwci.Uuid;
                                    }
                                }

                                pd.UINeedsIconUpdate = true;
                            }
                        }
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 26
0
        private static string ReadFile(BinaryReader br, PlgxPluginInfo plgx,
                                       IStatusLogger slStatus)
        {
            uint uSig1    = br.ReadUInt32();
            uint uSig2    = br.ReadUInt32();
            uint uVersion = br.ReadUInt32();

            if ((uSig1 != PlgxSignature1) || (uSig2 != PlgxSignature2))
            {
                return(null);                // Ignore file, don't throw
            }
            if ((uVersion & PlgxVersionMask) > (PlgxVersion & PlgxVersionMask))
            {
                throw new PlgxException(KLRes.FileVersionUnsupported);
            }

            string strPluginPath = null;
            string strTmpRoot = null;
            bool?  obContent = null;
            string strBuildPre = null, strBuildPost = null;

            while (true)
            {
                KeyValuePair <ushort, byte[]> kvp = ReadObject(br);

                if (kvp.Key == PlgxEOF)
                {
                    break;
                }
                else if (kvp.Key == PlgxFileUuid)
                {
                    plgx.FileUuid = new PwUuid(kvp.Value);
                }
                else if (kvp.Key == PlgxBaseFileName)
                {
                    plgx.BaseFileName = StrUtil.Utf8.GetString(kvp.Value);
                }
                else if (kvp.Key == PlgxCreationTime)
                {
                }                                                        // Ignore
                else if (kvp.Key == PlgxGeneratorName)
                {
                }
                else if (kvp.Key == PlgxGeneratorVersion)
                {
                }
                else if (kvp.Key == PlgxPrereqKP)
                {
                    ulong uReq = MemUtil.BytesToUInt64(kvp.Value);
                    if (uReq > PwDefs.FileVersion64)
                    {
                        throw new PlgxException(KLRes.FileNewVerReq);
                    }
                }
                else if (kvp.Key == PlgxPrereqNet)
                {
                    ulong uReq  = MemUtil.BytesToUInt64(kvp.Value);
                    ulong uInst = WinUtil.GetMaxNetFrameworkVersion();
                    if ((uInst != 0) && (uReq > uInst))
                    {
                        throw new PlgxException(KPRes.NewerNetRequired);
                    }
                }
                else if (kvp.Key == PlgxPrereqOS)
                {
                    string strOS  = "," + WinUtil.GetOSStr() + ",";
                    string strReq = "," + StrUtil.Utf8.GetString(kvp.Value) + ",";
                    if (strReq.IndexOf(strOS, StrUtil.CaseIgnoreCmp) < 0)
                    {
                        throw new PlgxException(KPRes.PluginOperatingSystemUnsupported);
                    }
                }
                else if (kvp.Key == PlgxPrereqPtr)
                {
                    uint uReq = MemUtil.BytesToUInt32(kvp.Value);
                    if (uReq > (uint)IntPtr.Size)
                    {
                        throw new PlgxException(KPRes.PluginOperatingSystemUnsupported);
                    }
                }
                else if (kvp.Key == PlgxBuildPre)
                {
                    strBuildPre = StrUtil.Utf8.GetString(kvp.Value);
                }
                else if (kvp.Key == PlgxBuildPost)
                {
                    strBuildPost = StrUtil.Utf8.GetString(kvp.Value);
                }
                else if (kvp.Key == PlgxBeginContent)
                {
                    if (obContent.HasValue)
                    {
                        throw new PlgxException(KLRes.FileCorrupted);
                    }

                    string strCached = PlgxCache.GetCacheFile(plgx, true, false);
                    if (!string.IsNullOrEmpty(strCached) && plgx.AllowCached)
                    {
                        strPluginPath = strCached;
                        break;
                    }

                    if (slStatus != null)
                    {
                        slStatus.SetText(KPRes.PluginsCompilingAndLoading,
                                         LogStatusType.Info);
                    }

                    obContent = true;
                    if (plgx.LogStream != null)
                    {
                        plgx.LogStream.WriteLine("Content:");
                    }
                }
                else if (kvp.Key == PlgxFile)
                {
                    if (!obContent.HasValue || !obContent.Value)
                    {
                        throw new PlgxException(KLRes.FileCorrupted);
                    }

                    if (strTmpRoot == null)
                    {
                        strTmpRoot = CreateTempDirectory();
                    }
                    ExtractFile(kvp.Value, strTmpRoot, plgx);
                }
                else if (kvp.Key == PlgxEndContent)
                {
                    if (!obContent.HasValue || !obContent.Value)
                    {
                        throw new PlgxException(KLRes.FileCorrupted);
                    }

                    obContent = false;
                }
                else
                {
                    Debug.Assert(false);
                }
            }

            if ((strPluginPath == null) && plgx.AllowCompile)
            {
                strPluginPath = Compile(strTmpRoot, plgx, strBuildPre, strBuildPost);
            }

            return(strPluginPath);
        }
		public override void Import(PwDatabase storage, Stream input, IStatusLogger status)
		{
			status.SetText("Parsing .pif ...", LogStatusType.Info);
			List<BaseRecord> baseRecords = _pifParser.Parse(input);
			_pifImporter.Import(baseRecords, storage, status);
		}
Ejemplo n.º 28
0
        /// <summary>
        /// Load a KDB file from a stream.
        /// </summary>
        /// <param name="sSource">Stream to read the data from. Must contain
        /// a KDBX stream.</param>
        /// <param name="kdbFormat">Format specifier.</param>
        /// <param name="slLogger">Status logger (optional).</param>
        public void Load(Stream sSource, KdbxFormat kdbFormat, IStatusLogger slLogger)
        {
            Debug.Assert(sSource != null);
            if(sSource == null) throw new ArgumentNullException("sSource");

            m_format = kdbFormat;
            m_slLogger = slLogger;

            HashingStreamEx hashedStream = new HashingStreamEx(sSource, false, null);

            UTF8Encoding encNoBom = StrUtil.Utf8;
            try
            {
                BinaryReaderEx br = null;
                BinaryReaderEx brDecrypted = null;
                Stream readerStream = null;

                if(kdbFormat == KdbxFormat.Default || kdbFormat == KdbxFormat.ProtocolBuffers)
                {
                    br = new BinaryReaderEx(hashedStream, encNoBom, KLRes.FileCorrupted);
                    ReadHeader(br);

                    Stream sDecrypted = AttachStreamDecryptor(hashedStream);
                    if((sDecrypted == null) || (sDecrypted == hashedStream))
                        throw new SecurityException(KLRes.CryptoStreamFailed);

                    if (m_slLogger != null)
                        m_slLogger.SetText("KP2AKEY_TransformingKey", LogStatusType.AdditionalInfo);

                    brDecrypted = new BinaryReaderEx(sDecrypted, encNoBom, KLRes.FileCorrupted);
                    byte[] pbStoredStartBytes = brDecrypted.ReadBytes(32);

                    if((m_pbStreamStartBytes == null) || (m_pbStreamStartBytes.Length != 32))
                        throw new InvalidDataException();

                    if (m_slLogger != null)
                        m_slLogger.SetText("KP2AKEY_DecodingDatabase", LogStatusType.AdditionalInfo);

                    for(int iStart = 0; iStart < 32; ++iStart)
                    {
                        if(pbStoredStartBytes[iStart] != m_pbStreamStartBytes[iStart])
                            throw new InvalidCompositeKeyException();
                    }

                    Stream sHashed = new HashedBlockStream(sDecrypted, false, 0,
                        !m_bRepairMode);

                    if(m_pwDatabase.Compression == PwCompressionAlgorithm.GZip)
                        readerStream = new Ionic.Zlib.GZipStream(sHashed, Ionic.Zlib.CompressionMode.Decompress);
                    else readerStream = sHashed;
                }
                else if(kdbFormat == KdbxFormat.PlainXml)
                    readerStream = hashedStream;
                else { Debug.Assert(false); throw new FormatException("KdbFormat"); }

                if(kdbFormat != KdbxFormat.PlainXml) // Is an encrypted format
                {
                    if(m_pbProtectedStreamKey == null)
                    {
                        Debug.Assert(false);
                        throw new SecurityException("Invalid protected stream key!");
                    }

                    m_randomStream = new CryptoRandomStream(m_craInnerRandomStream,
                        m_pbProtectedStreamKey);
                }
                else m_randomStream = null; // No random stream for plain-text files
                if (m_slLogger != null)
                    m_slLogger.SetText("KP2AKEY_ParsingDatabase", LogStatusType.AdditionalInfo);
                var stopWatch = Stopwatch.StartNew();

                if (kdbFormat == KdbxFormat.ProtocolBuffers)
                {
                    KdbpFile.ReadDocument(m_pwDatabase, readerStream, m_pbProtectedStreamKey, m_pbHashOfHeader);

                    Kp2aLog.Log(String.Format("KdbpFile.ReadDocument: {0}ms", stopWatch.ElapsedMilliseconds));

                }
                else
                {
                    ReadXmlStreamed(readerStream, hashedStream);

                    Kp2aLog.Log(String.Format("ReadXmlStreamed: {0}ms", stopWatch.ElapsedMilliseconds));
                }

                readerStream.Close();
                // GC.KeepAlive(br);
                // GC.KeepAlive(brDecrypted);
            }
            catch(CryptographicException) // Thrown on invalid padding
            {
                throw new CryptographicException(KLRes.FileCorrupted);
            }
            finally { CommonCleanUpRead(sSource, hashedStream); }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Imports a wlan connection information to the database. If the entry already exists, then the
        /// parameter behaviour defines the behaviour
        /// </summary>
        /// <param name="wlan">The new wifi connection informations</param>
        /// <param name="pwStorage">The database in which the group lies</param>
        /// <param name="group">The group to which we add the entry</param>
        /// <param name="behaviour">What do we do if the entry already exists?</param>
        /// <param name="slLogger">Where we log to (can be null)</param>
        /// <param name="totalProcents">If we parsed completely, how many (additional) procents of the
        /// total progress did we finish? (Senseless if slLogger = null)</param>
        /// <param name="minProcents">How many procents of the total progress were already finished</param>
        /// <remarks>Note that minProcents + totalProcents has to be less than or equal to 100.</remarks>
        /// <returns>The entry created or null if an error occured</returns>
        public PwEntry ImportTo(WlanProfile wlan, PwDatabase pwStorage, PwGroup group,
                                BehaviourForExEntry behaviour = BehaviourForExEntry.ASK_USER,
                                IStatusLogger slLogger        = null, double totalProcents = 60,
                                double minProcents            = 20)
        {
            slLogger.SetProgress((uint)minProcents);
            PwEntry entry = null;

            String wlanName = wlan.NameOrSSID;// Note that the entries base name must be unprotected!

            if ((wlanName == null) || (wlanName == ""))
            {
                return(null);
            }

            entry = ExistingEntryInGroup(group, wlan);
            if (slLogger != null)
            {
                minProcents += totalProcents / 3.0;
                slLogger.SetProgress((uint)minProcents);
            }

            // Entry exists
            if (entry != null)
            {
                if (behaviour == BehaviourForExEntry.ASK_USER)
                {
                    VistaTaskDialog vtd = new VistaTaskDialog();
                    vtd.CommandLinks = false;
                    //            vtd.Content = strDatabase;
                    vtd.MainInstruction = String.Format("Es ist bereits ein Eintrag namens {0} vorhanden.\n" +
                                                        "Soll der alte Eintrag durch die ausgelesenen Daten ersetzt werden oder " +
                                                        "der Eintrag übersprungen werden?", wlan.name.Value.ReadString());
                    vtd.SetIcon(VtdCustomIcon.Question);
                    //            vtd.VerificationText = KPRes.DialogNoShowAgain;
                    //            vtd.WindowTitle = KeePass.UI. UIExtExt.ProductName;

                    vtd.AddButton((int)BehaviourForExEntry.REPLACE, "Ersetzen", null);
//                        vtd.AddButton((int)BehaviourForExEntry.RENAME_NEW_ONE, "Neuer Eintrag", null);
                    vtd.AddButton((int)BehaviourForExEntry.CANCEL_WITHOUT_ERROR, "Überspringen", null);
                    vtd.ShowDialog();
                    behaviour = (BehaviourForExEntry)vtd.Result;
                }

                switch (behaviour)
                {
                case BehaviourForExEntry.CANCEL_WITHOUT_ERROR:
                    if (slLogger != null)
                    {
                        minProcents += 2.0 * totalProcents / 3.0;
                        slLogger.SetProgress((uint)minProcents);
                    }
                    return(null);

                case BehaviourForExEntry.CANCEL_WITH_ERROR:
                    if (slLogger != null)
                    {
                        slLogger.SetText("Fehler beim Einfügen des Eintrags", LogStatusType.Error);
                        minProcents += 2.0 * totalProcents / 3.0;
                        slLogger.SetProgress((uint)minProcents);
                    }
                    return(null);

                case BehaviourForExEntry.REPLACE:
                    group.Entries.Remove(entry);
                    entry = null;
                    break;

                    /* As long as the title and the ssid in Windows have to identical, we cannot just rename the entry
                     * case BehaviourForExEntry.RENAME_NEW_ONE:*/
                }
            }

            entry = new PwEntry(true, true);
            if (slLogger != null)
            {
                minProcents += totalProcents / 3.0;
                slLogger.SetProgress((uint)minProcents);
            }

            if (wlan.SaveIn(pwStorage, entry))
            {
                group.AddEntry(entry, true);
            }
            else
            {
                entry = null;
            }

            if (slLogger != null)
            {
                minProcents += totalProcents / 3.0;
                slLogger.SetProgress((uint)minProcents);
            }

            // We might have change the name, so let us change it back.
            // Note again that the name must be unprotected!
            wlan.name.Value = new ProtectedString(false, wlanName);
            return(entry);
        }
Ejemplo n.º 30
0
		private static string ReadFile(BinaryReader br, PlgxPluginInfo plgx,
			IStatusLogger slStatus)
		{
			uint uSig1 = br.ReadUInt32();
			uint uSig2 = br.ReadUInt32();
			uint uVersion = br.ReadUInt32();

			if((uSig1 != PlgxSignature1) || (uSig2 != PlgxSignature2))
				return null; // Ignore file, don't throw
			if((uVersion & PlgxVersionMask) > (PlgxVersion & PlgxVersionMask))
				throw new PlgxException(KLRes.FileVersionUnsupported);

			string strPluginPath = null;
			string strTmpRoot = null;
			bool? bContent = null;
			string strBuildPre = null, strBuildPost = null;

			while(true)
			{
				KeyValuePair<ushort, byte[]> kvp = ReadObject(br);

				if(kvp.Key == PlgxEOF) break;
				else if(kvp.Key == PlgxFileUuid)
					plgx.FileUuid = new PwUuid(kvp.Value);
				else if(kvp.Key == PlgxBaseFileName)
					plgx.BaseFileName = StrUtil.Utf8.GetString(kvp.Value);
				else if(kvp.Key == PlgxCreationTime) { } // Ignore
				else if(kvp.Key == PlgxGeneratorName) { }
				else if(kvp.Key == PlgxGeneratorVersion) { }
				else if(kvp.Key == PlgxPrereqKP)
				{
					ulong uReq = MemUtil.BytesToUInt64(kvp.Value);
					if(uReq > PwDefs.FileVersion64)
						throw new PlgxException(KLRes.FileNewVerReq);
				}
				else if(kvp.Key == PlgxPrereqNet)
				{
					ulong uReq = MemUtil.BytesToUInt64(kvp.Value);
					ulong uInst = WinUtil.GetMaxNetFrameworkVersion();
					if((uInst != 0) && (uReq > uInst))
						throw new PlgxException(KPRes.NewerNetRequired);
				}
				else if(kvp.Key == PlgxPrereqOS)
				{
					string strOS = "," + WinUtil.GetOSStr() + ",";
					string strReq = "," + StrUtil.Utf8.GetString(kvp.Value) + ",";
					if(strReq.IndexOf(strOS, StrUtil.CaseIgnoreCmp) < 0)
						throw new PlgxException(KPRes.PluginOperatingSystemUnsupported);
				}
				else if(kvp.Key == PlgxPrereqPtr)
				{
					uint uReq = MemUtil.BytesToUInt32(kvp.Value);
					if(uReq > (uint)IntPtr.Size)
						throw new PlgxException(KPRes.PluginOperatingSystemUnsupported);
				}
				else if(kvp.Key == PlgxBuildPre)
					strBuildPre = StrUtil.Utf8.GetString(kvp.Value);
				else if(kvp.Key == PlgxBuildPost)
					strBuildPost = StrUtil.Utf8.GetString(kvp.Value);
				else if(kvp.Key == PlgxBeginContent)
				{
					if(bContent.HasValue)
						throw new PlgxException(KLRes.FileCorrupted);

					string strCached = PlgxCache.GetCacheFile(plgx, true, false);
					if(!string.IsNullOrEmpty(strCached) && plgx.AllowCached)
					{
						strPluginPath = strCached;
						break;
					}

					if(slStatus != null)
						slStatus.SetText(KPRes.PluginsCompilingAndLoading,
							LogStatusType.Info);

					bContent = true;
					if(plgx.LogStream != null) plgx.LogStream.WriteLine("Content:");
				}
				else if(kvp.Key == PlgxFile)
				{
					if(!bContent.HasValue || !bContent.Value)
						throw new PlgxException(KLRes.FileCorrupted);

					if(strTmpRoot == null) strTmpRoot = CreateTempDirectory();
					ExtractFile(kvp.Value, strTmpRoot, plgx);
				}
				else if(kvp.Key == PlgxEndContent)
				{
					if(!bContent.HasValue || !bContent.Value)
						throw new PlgxException(KLRes.FileCorrupted);

					bContent = false;
				}
				else { Debug.Assert(false); }
			}

			if((strPluginPath == null) && plgx.AllowCompile)
				strPluginPath = Compile(strTmpRoot, plgx, strBuildPre, strBuildPost);

			return strPluginPath;
		}
Ejemplo n.º 31
0
        private void BackupAction(PwDatabase database)
        {
            // don't perform backup if configuration isn't finished
            if (!this.m_config.BackupConfigured)
            {
                return;
            }

            IStatusLogger swLogger = this.m_host.MainWindow.CreateShowWarningsLogger();

            try
            {
                m_host.MainWindow.UIBlockInteraction(true);
                bool warnings = false;

                BackupManager.SetKPMainWindowSwLogger(swLogger);
                swLogger.SetText("KPSimpleBackup: Backup started...", LogStatusType.Info);
                m_PluginLogger.Log("KPSimpleBackup: Backup started...", LogStatusType.Info);

                BasicBackupManager basicBackupManager = new BasicBackupManager(database);
                warnings = !basicBackupManager.Run() || warnings;

                // perform long term backup if enabled in settings
                if (m_config.UseLongTermBackup)
                {
                    LongTermBackupManager ltbManager = new LongTermBackupManager(database);
                    warnings = !ltbManager.Run() || warnings;
                }

                // backup KeePass configuration if enabled in settings
                if (m_config.BackupKeePassConfig)
                {
                    KPConfigBackupManager kPConfigBackupManager = new KPConfigBackupManager(database);
                    warnings = !kPConfigBackupManager.Run() || warnings;
                }

                if (warnings)
                {
                    swLogger.SetText("KPSimpleBackup: Backup finished with warnings, consider checking the logs!", LogStatusType.Info);
                    if (m_config.ShowBackupFailedWarning)
                    {
                        MessageService.ShowWarning(
                            "KPSimpleBackup: Backup finished with warnings, check the logs for details!"
                            );
                    }
                }
                else
                {
                    swLogger.SetText("KPSimpleBackup: Backup finished!", LogStatusType.Info);
                }
            }
            catch (Exception e)
            {
                swLogger.EndLogging();
                swLogger.SetText("KPSimpleBackup: Backup failed, see logs for details!", LogStatusType.Error);

                m_PluginLogger.Log("Could not backup database! Error:", LogStatusType.Error);
                m_PluginLogger.Log(e.ToString(), LogStatusType.Error);
            }
            finally
            {
                m_host.MainWindow.UIBlockInteraction(false);
                m_PluginLogger.Log("KPSimpleBackup: Finished", LogStatusType.Info);
            }
        }
Ejemplo n.º 32
0
        public override void Import(PwDatabase pwStorage, Stream sInput,
                                    IStatusLogger slLogger)
        {
            slLogger.SetText("> Spamex.com...", LogStatusType.Info);

            SingleLineEditForm dlgUser = new SingleLineEditForm();

            dlgUser.InitEx("Spamex.com", KPRes.WebSiteLogin + " - " + KPRes.UserName,
                           KPRes.UserNamePrompt, KeePass.Properties.Resources.B48x48_WWW,
                           string.Empty, null);
            if (UIUtil.ShowDialogNotValue(dlgUser, DialogResult.OK))
            {
                return;
            }
            string strUser = dlgUser.ResultString;

            UIUtil.DestroyForm(dlgUser);

            SingleLineEditForm dlgPassword = new SingleLineEditForm();

            dlgPassword.InitEx("Spamex.com", KPRes.WebSiteLogin + " - " + KPRes.Password,
                               KPRes.PasswordPrompt, KeePass.Properties.Resources.B48x48_WWW,
                               string.Empty, null);
            if (UIUtil.ShowDialogNotValue(dlgPassword, DialogResult.OK))
            {
                return;
            }
            string strPassword = dlgPassword.ResultString;

            UIUtil.DestroyForm(dlgPassword);

            RemoteCertificateValidationCallback pPrevCertCb =
                ServicePointManager.ServerCertificateValidationCallback;

            ServicePointManager.ServerCertificateValidationCallback =
                delegate(object sender, X509Certificate certificate, X509Chain chain,
                         SslPolicyErrors sslPolicyErrors)
            {
                return(true);
            };

            try
            {
                slLogger.SetText(KPRes.ImportingStatusMsg, LogStatusType.Info);

                string strPostData = @"toollogin=&MetaDomain=&LoginEmail=" +
                                     strUser + @"&LoginPassword="******"&Remember=1";

                List <KeyValuePair <string, string> > vCookies;
                string strMain = NetUtil.WebPageLogin(new Uri(UrlLoginPage),
                                                      strPostData, out vCookies);

                if (strMain.IndexOf("Welcome <b>" + strUser + "</b>") < 0)
                {
                    MessageService.ShowWarning(KPRes.InvalidUserPassword);
                    return;
                }

                string strIndexPage = NetUtil.WebPageGetWithCookies(new Uri(UrlIndexPage),
                                                                    vCookies, UrlDomain);

                ImportIndex(pwStorage, strIndexPage, vCookies, slLogger);

                int           nOffset   = 0;
                List <string> vSubPages = new List <string>();
                while (true)
                {
                    string strLink = StrUtil.GetStringBetween(strIndexPage, nOffset,
                                                              StrTabLinksStart, StrTabLinksEnd, out nOffset);
                    ++nOffset;

                    if (strLink.Length == 0)
                    {
                        break;
                    }

                    if (!strLink.StartsWith(StrTabLinkUrl))
                    {
                        continue;
                    }
                    if (vSubPages.IndexOf(strLink) >= 0)
                    {
                        continue;
                    }

                    vSubPages.Add(strLink);

                    string strSubPage = NetUtil.WebPageGetWithCookies(new Uri(
                                                                          UrlBase + strLink), vCookies, UrlDomain);

                    ImportIndex(pwStorage, strSubPage, vCookies, slLogger);
                }
            }
            finally
            {
                ServicePointManager.ServerCertificateValidationCallback = pPrevCertCb;
            }
        }
Ejemplo n.º 33
0
        private static void ImportAccount(PwDatabase pwStorage, string strID,
                                          List <KeyValuePair <string, string> > vCookies, IStatusLogger slf)
        {
            string strPage = NetUtil.WebPageGetWithCookies(new Uri(
                                                               UrlAccountPage + strID), vCookies, UrlDomain);

            PwEntry pe = new PwEntry(true, true);

            pwStorage.RootGroup.AddEntry(pe, true);

            string str;

            string strTitle = StrUtil.GetStringBetween(strPage, 0, "Subject : <b>", "</b>");

            if (strTitle.StartsWith("<b>"))
            {
                strTitle = strTitle.Substring(3, strTitle.Length - 3);
            }
            pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
                               pwStorage.MemoryProtection.ProtectTitle, strTitle));

            string strUser = StrUtil.GetStringBetween(strPage, 0, "Site Username : <b>", "</b>");

            if (strUser.StartsWith("<b>"))
            {
                strUser = strUser.Substring(3, strUser.Length - 3);
            }
            pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(
                               pwStorage.MemoryProtection.ProtectUserName, strUser));

            str = StrUtil.GetStringBetween(strPage, 0, "Site Password : <b>", "</b>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(
                               pwStorage.MemoryProtection.ProtectPassword, str));

            str = StrUtil.GetStringBetween(strPage, 0, "Site Domain : <b>", "</b>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set(PwDefs.UrlField, new ProtectedString(
                               pwStorage.MemoryProtection.ProtectUrl, str));

            str = StrUtil.GetStringBetween(strPage, 0, "Notes : <b>", "</b>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
                               pwStorage.MemoryProtection.ProtectNotes, str));

            str = StrUtil.GetStringBetween(strPage, 0, "Address:&nbsp;</td><td><font class=\"midHD\">", "</font></td>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set("Address", new ProtectedString(false, str));

            str = StrUtil.GetStringBetween(strPage, 0, "Forwards to: <b>", "</b>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set("Forward To", new ProtectedString(false, str));

            str = StrUtil.GetStringBetween(strPage, 0, "Reply-To Messages: <b>", "</b>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set("Reply-To Messages", new ProtectedString(false, str));

            str = StrUtil.GetStringBetween(strPage, 0, "Allow Reply From: <b>", "</b>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set("Allow Reply From", new ProtectedString(false, str));

            str = StrUtil.GetStringBetween(strPage, 0, "Filter Mode: <b>", "</b>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set("Filter Mode", new ProtectedString(false, str));

            str = StrUtil.GetStringBetween(strPage, 0, "Created: <b>", "</b>");
            if (str.StartsWith("<b>"))
            {
                str = str.Substring(3, str.Length - 3);
            }
            pe.Strings.Set("Created", new ProtectedString(false, str));

            slf.SetText(strTitle + " - " + strUser + " (" + strID + ")",
                        LogStatusType.Info);

            if (!slf.ContinueWork())
            {
                throw new InvalidOperationException(string.Empty);
            }
        }
Ejemplo n.º 34
0
		private static void ImportAccount(PwDatabase pwStorage, string strID,
			List<KeyValuePair<string, string>> vCookies, IStatusLogger slf)
		{
			string strPage = NetUtil.WebPageGetWithCookies(new Uri(
				UrlAccountPage + strID), vCookies, UrlDomain);

			PwEntry pe = new PwEntry(true, true);
			pwStorage.RootGroup.AddEntry(pe, true);

			string str;

			string strTitle = StrUtil.GetStringBetween(strPage, 0, "Subject : <b>", "</b>");
			if(strTitle.StartsWith("<b>")) strTitle = strTitle.Substring(3, strTitle.Length - 3);
			pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectTitle, strTitle));

			string strUser = StrUtil.GetStringBetween(strPage, 0, "Site Username : <b>", "</b>");
			if(strUser.StartsWith("<b>")) strUser = strUser.Substring(3, strUser.Length - 3);
			pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectUserName, strUser));

			str = StrUtil.GetStringBetween(strPage, 0, "Site Password : <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectPassword, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Site URL : <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set(PwDefs.UrlField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectUrl, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Notes : <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectNotes, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Address:&nbsp;</td><td><font class=\"midHD\">", "</font></td>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Address", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Forwards to: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Forward To", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Reply-To Messages: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Reply-To Messages", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Allow Reply From: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Allow Reply From", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Filter Mode: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Filter Mode", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Created: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Created", new ProtectedString(false, str));

			slf.SetText(strTitle + " - " + strUser + " (" + strID + ")",
				LogStatusType.Info);

			if(!slf.ContinueWork())
				throw new InvalidOperationException(string.Empty);
		}
Ejemplo n.º 35
0
		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			slLogger.SetText("> Spamex.com...", LogStatusType.Info);

			SingleLineEditForm dlgUser = new SingleLineEditForm();
			dlgUser.InitEx("Spamex.com", KPRes.WebSiteLogin + " - " + KPRes.UserName,
				KPRes.UserNamePrompt, KeePass.Properties.Resources.B48x48_WWW,
				string.Empty, null);
			if(dlgUser.ShowDialog() != DialogResult.OK) return;

			SingleLineEditForm dlgPassword = new SingleLineEditForm();
			dlgPassword.InitEx("Spamex.com", KPRes.WebSiteLogin + " - " + KPRes.Password,
				KPRes.PasswordPrompt, KeePass.Properties.Resources.B48x48_WWW,
				string.Empty, null);
			if(dlgPassword.ShowDialog() != DialogResult.OK) return;

			RemoteCertificateValidationCallback pPrevCertCb =
				ServicePointManager.ServerCertificateValidationCallback;

			ServicePointManager.ServerCertificateValidationCallback =
				delegate(object sender, X509Certificate certificate, X509Chain chain,
					SslPolicyErrors sslPolicyErrors)
				{
					return true;
				};

			try
			{
				slLogger.SetText(KPRes.ImportingStatusMsg, LogStatusType.Info);

				string strUser = dlgUser.ResultString; ;
				string strPassword = dlgPassword.ResultString;

				string strPostData = @"toollogin=&MetaDomain=&LoginEmail=" +
					strUser + @"&LoginPassword="******"&Remember=1";

				List<KeyValuePair<string, string>> vCookies;
				string strMain = NetUtil.WebPageLogin(new Uri(UrlLoginPage),
					strPostData, out vCookies);

				if(strMain.IndexOf("Welcome <b>" + strUser + "</b>") < 0)
				{
					MessageService.ShowWarning(KPRes.InvalidUserPassword);
					return;
				}

				string strIndexPage = NetUtil.WebPageGetWithCookies(new Uri(UrlIndexPage),
					vCookies, UrlDomain);

				ImportIndex(pwStorage, strIndexPage, vCookies, slLogger);

				int nOffset = 0;
				List<string> vSubPages = new List<string>();
				while(true)
				{
					string strLink = StrUtil.GetStringBetween(strIndexPage, nOffset,
						StrTabLinksStart, StrTabLinksEnd, out nOffset);
					++nOffset;

					if(strLink.Length == 0) break;

					if(!strLink.StartsWith(StrTabLinkUrl)) continue;
					if(vSubPages.IndexOf(strLink) >= 0) continue;

					vSubPages.Add(strLink);

					string strSubPage = NetUtil.WebPageGetWithCookies(new Uri(
						UrlBase + strLink), vCookies, UrlDomain);

					ImportIndex(pwStorage, strSubPage, vCookies, slLogger);
				}
			}
			catch
			{
				ServicePointManager.ServerCertificateValidationCallback = pPrevCertCb;
				throw;
			}

			ServicePointManager.ServerCertificateValidationCallback = pPrevCertCb;
		}
Ejemplo n.º 36
0
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
            IStatusLogger slLogger)
        {
            PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase());

            string strTempFile = Program.TempFilesPool.GetTempFileName(false);

            try
            {
                Kdb3File kdb = new Kdb3File(pd, slLogger);
                kdb.Save(strTempFile, pwExportInfo.DataGroup);

                byte[] pbKdb = File.ReadAllBytes(strTempFile);
                sOutput.Write(pbKdb, 0, pbKdb.Length);
                Array.Clear(pbKdb, 0, pbKdb.Length);
            }
            catch(Exception exKdb)
            {
                if(slLogger != null) slLogger.SetText(exKdb.Message, LogStatusType.Error);

                return false;
            }

            Program.TempFilesPool.Delete(strTempFile);
            return true;
        }
        /// <summary>
        /// Load a KDBX file from a stream.
        /// </summary>
        /// <param name="sSource">Stream to read the data from. Must contain
        /// a KDBX stream.</param>
        /// <param name="fmt">Format.</param>
        /// <param name="slLogger">Status logger (optional).</param>
        public void Load(Stream sSource, KdbxFormat fmt, IStatusLogger slLogger)
        {
            Debug.Assert(sSource != null);
            if (sSource == null)
            {
                throw new ArgumentNullException("sSource");
            }

            if (m_bUsedOnce)
            {
                throw new InvalidOperationException("Do not reuse KdbxFile objects!");
            }
            m_bUsedOnce = true;

#if KDBX_BENCHMARK
            Stopwatch swTime = Stopwatch.StartNew();
#endif

            m_format   = fmt;
            m_slLogger = slLogger;

            m_pbsBinaries.Clear();

            UTF8Encoding encNoBom    = StrUtil.Utf8;
            byte[]       pbCipherKey = null;
            byte[]       pbHmacKey64 = null;

            List <Stream> lStreams = new List <Stream>();
            lStreams.Add(sSource);

            HashingStreamEx sHashing = new HashingStreamEx(sSource, false, null);
            lStreams.Add(sHashing);

            try
            {
                Stream sXml;
                if (fmt == KdbxFormat.Default || fmt == KdbxFormat.ProtocolBuffers)
                {
                    BinaryReaderEx br = new BinaryReaderEx(sHashing,
                                                           encNoBom, KLRes.FileCorrupted);
                    byte[] pbHeader = LoadHeader(br);
                    m_pbHashOfHeader = CryptoUtil.HashSha256(pbHeader);

                    int           cbEncKey, cbEncIV;
                    ICipherEngine iCipher = GetCipher(out cbEncKey, out cbEncIV);

                    if (m_slLogger != null)
                    {
                        m_slLogger.SetText("KP2AKEY_TransformingKey", LogStatusType.AdditionalInfo);
                    }

                    ComputeKeys(out pbCipherKey, cbEncKey, out pbHmacKey64);

                    string strIncomplete = KLRes.FileHeaderCorrupted + " " +
                                           KLRes.FileIncomplete;

                    Stream sPlain;
                    if (m_uFileVersion < FileVersion32_4)
                    {
                        Stream sDecrypted = EncryptStream(sHashing, iCipher,
                                                          pbCipherKey, cbEncIV, false);
                        if ((sDecrypted == null) || (sDecrypted == sHashing))
                        {
                            throw new SecurityException(KLRes.CryptoStreamFailed);
                        }

                        if (m_slLogger != null)
                        {
                            m_slLogger.SetText("KP2AKEY_DecodingDatabase", LogStatusType.AdditionalInfo);
                        }

                        lStreams.Add(sDecrypted);

                        BinaryReaderEx brDecrypted = new BinaryReaderEx(sDecrypted,
                                                                        encNoBom, strIncomplete);
                        byte[] pbStoredStartBytes = brDecrypted.ReadBytes(32);

                        if ((m_pbStreamStartBytes == null) || (m_pbStreamStartBytes.Length != 32))
                        {
                            throw new EndOfStreamException(strIncomplete);
                        }
                        if (!MemUtil.ArraysEqual(pbStoredStartBytes, m_pbStreamStartBytes))
                        {
                            throw new InvalidCompositeKeyException();
                        }

                        if (m_slLogger != null)
                        {
                            m_slLogger.SetText("KP2AKEY_DecodingDatabase", LogStatusType.AdditionalInfo);
                        }


                        sPlain = new HashedBlockStream(sDecrypted, false, 0, !m_bRepairMode);
                    }
                    else                     // KDBX >= 4
                    {
                        byte[] pbStoredHash = MemUtil.Read(sHashing, 32);
                        if ((pbStoredHash == null) || (pbStoredHash.Length != 32))
                        {
                            throw new EndOfStreamException(strIncomplete);
                        }
                        if (!MemUtil.ArraysEqual(m_pbHashOfHeader, pbStoredHash))
                        {
                            throw new InvalidDataException(KLRes.FileHeaderCorrupted);
                        }

                        byte[] pbHeaderHmac = ComputeHeaderHmac(pbHeader, pbHmacKey64);
                        byte[] pbStoredHmac = MemUtil.Read(sHashing, 32);
                        if ((pbStoredHmac == null) || (pbStoredHmac.Length != 32))
                        {
                            throw new EndOfStreamException(strIncomplete);
                        }
                        if (!MemUtil.ArraysEqual(pbHeaderHmac, pbStoredHmac))
                        {
                            throw new InvalidCompositeKeyException();
                        }

                        HmacBlockStream sBlocks = new HmacBlockStream(sHashing,
                                                                      false, !m_bRepairMode, pbHmacKey64);
                        lStreams.Add(sBlocks);

                        sPlain = EncryptStream(sBlocks, iCipher, pbCipherKey,
                                               cbEncIV, false);
                        if ((sPlain == null) || (sPlain == sBlocks))
                        {
                            throw new SecurityException(KLRes.CryptoStreamFailed);
                        }
                    }
                    lStreams.Add(sPlain);

                    if (m_pwDatabase.Compression == PwCompressionAlgorithm.GZip)
                    {
                        sXml = new GZipStream(sPlain, CompressionMode.Decompress);
                        lStreams.Add(sXml);
                    }
                    else
                    {
                        sXml = sPlain;
                    }

                    if (m_uFileVersion >= FileVersion32_4)
                    {
                        LoadInnerHeader(sXml);                         // Binary header before XML
                    }
                }
                else if (fmt == KdbxFormat.PlainXml)
                {
                    sXml = sHashing;
                }
                else
                {
                    Debug.Assert(false); throw new ArgumentOutOfRangeException("fmt");
                }

                if (fmt == KdbxFormat.Default)
                {
                    if (m_pbInnerRandomStreamKey == null)
                    {
                        Debug.Assert(false);
                        throw new SecurityException("Invalid inner random stream key!");
                    }

                    m_randomStream = new CryptoRandomStream(m_craInnerRandomStream,
                                                            m_pbInnerRandomStreamKey);
                }
                if (m_slLogger != null)
                {
                    m_slLogger.SetText("KP2AKEY_ParsingDatabase", LogStatusType.AdditionalInfo);
                }

#if KeePassDebug_WriteXml
                // FileStream fsOut = new FileStream("Raw.xml", FileMode.Create,
                //	FileAccess.Write, FileShare.None);
                // try
                // {
                //	while(true)
                //	{
                //		int b = sXml.ReadByte();
                //		if(b == -1) break;
                //		fsOut.WriteByte((byte)b);
                //	}
                // }
                // catch(Exception) { }
                // fsOut.Close();
#endif
                var stopWatch = Stopwatch.StartNew();

                if (fmt == KdbxFormat.ProtocolBuffers)
                {
                    KdbpFile.ReadDocument(m_pwDatabase, sXml, m_pbInnerRandomStreamKey, m_pbHashOfHeader);

                    Kp2aLog.Log(String.Format("KdbpFile.ReadDocument: {0}ms", stopWatch.ElapsedMilliseconds));
                }
                else
                {
                    ReadXmlStreamed(sXml, sHashing);

                    Kp2aLog.Log(String.Format("ReadXmlStreamed: {0}ms", stopWatch.ElapsedMilliseconds));
                }
                // ReadXmlDom(sXml);
            }
            catch (CryptographicException)            // Thrown on invalid padding
            {
                throw new CryptographicException(KLRes.FileCorrupted);
            }
            finally
            {
                if (pbCipherKey != null)
                {
                    MemUtil.ZeroByteArray(pbCipherKey);
                }
                if (pbHmacKey64 != null)
                {
                    MemUtil.ZeroByteArray(pbHmacKey64);
                }

                CommonCleanUpRead(lStreams, sHashing);
            }

#if KDBX_BENCHMARK
            swTime.Stop();
            MessageService.ShowInfo("Loading KDBX took " +
                                    swTime.ElapsedMilliseconds.ToString() + " ms.");
#endif
        }
Ejemplo n.º 38
0
 private void ReportProgress(ProgressInfo progress)
 {
     logger.SetProgress((uint)progress.Percent);
     logger.SetText(string.Format("YAFD: Success: {0} / Not Found: {1} / Error: {2} / Remaining: {3}", progress.Success, progress.NotFound, progress.Error, progress.Remaining), LogStatusType.Info);
 }