private void OnFormLoad(object sender, EventArgs e) { if (m_pgEntrySource == null) { Debug.Assert(false); return; } if (m_ilIcons == null) { Debug.Assert(false); return; } GlobalWindowManager.AddWindow(this); List <KeyValuePair <string, string> > vColumns = new List <KeyValuePair <string, string> >(); vColumns.Add(new KeyValuePair <string, string>(PwDefs.TitleField, KPRes.Title)); vColumns.Add(new KeyValuePair <string, string>(PwDefs.UserNameField, KPRes.UserName)); vColumns.Add(new KeyValuePair <string, string>(PwDefs.UrlField, KPRes.Url)); vColumns.Add(new KeyValuePair <string, string>(PwDefs.NotesField, KPRes.Notes)); PwObjectList <PwEntry> vEntries = m_pgEntrySource.GetEntries(true); UIUtil.CreateEntryList(m_lvEntries, vEntries, vColumns, m_ilIcons); m_radioIdUuid.Checked = true; m_radioRefPassword.Checked = true; }
private void GroupPickIcon_Click(object sender, EventArgs e) { Util.Log("Group Context Menu -> PickExeIcon clicked"); if (CheckMono()) { return; } PwGroup group = pluginHost.MainWindow.GetSelectedGroup(); if (group == null) { Util.Log("No group selected"); return; } // Get all entries from the group bool subEntries = KeePass.Program.Config.MainWindow.ShowEntriesOfSubGroups; PwObjectList <PwEntry> entriesInGroup = group.GetEntries(subEntries); if (entriesInGroup == null) { Util.Log("No entries in group are null"); return; } // Copy PwObjectList<PwEntry> to PwEntry[] PwEntry[] entries = entriesInGroup.CloneShallowToList().ToArray(); Execute(entries, group); }
public async override Task <List <BreachedEntry> > CheckGroup(PwGroup group, bool expireEntries, bool oldEntriesOnly, bool ignoreDeleted, bool ignoreExpired, IProgress <ProgressItem> progressIndicator) { progressIndicator.Report(new ProgressItem(0, "Getting HaveIBeenPwned breach list...")); var entries = group.GetEntries(true).Where(e => (!ignoreDeleted || !e.IsDeleted(pluginHost)) && (!ignoreExpired || !e.Expires)); var usernames = entries.Select(e => e.Strings.ReadSafe(PwDefs.UserNameField)).Distinct(); var breaches = await GetBreaches(progressIndicator, usernames); var breachedEntries = new List <BreachedEntry>(); await Task.Run(() => { foreach (var breach in breaches) { var pwEntry = entries.FirstOrDefault(e => e.GetUrlDomain() == breach.Domain); if (pwEntry != null) { var lastModified = pwEntry.GetPasswordLastModified(); if (oldEntriesOnly && lastModified >= breach.BreachDate) { continue; } if (expireEntries) { ExpireEntry(pwEntry); } } breachedEntries.Add(new BreachedEntry(pwEntry, breach)); } }); return(breachedEntries); }
private void DownloadFaviconsGroup_Click(object sender, EventArgs e) { Util.Log("Group Context Menu -> Download Favicons clicked"); PwGroup group = pluginHost.MainWindow.GetSelectedGroup(); if (group == null) { Util.Log("No group selected"); return; } // Get all entries from the group PwObjectList <PwEntry> entriesInGroup = group.GetEntries(true); if (entriesInGroup == null || entriesInGroup.UCount == 0) { Util.Log("No entries in group"); return; } // Copy PwObjectList<PwEntry> to PwEntry[] PwEntry[] entries = entriesInGroup.CloneShallowToList().ToArray(); DownloadFavicons(entries); }
/// <summary> /// The function creates a new PwEntry that represents an import source. /// </summary> /// <param name="fileName">The path to the file in your filesystem that should be used /// as import source.</param> /// <returns><c>ChangeFlags.CommonChange</c> if the function has made any changes to the /// actual database structure (means if we added he impSrc). 0 if the impSrc allready exists /// and we don't have to make any changes anymore.</returns> public Changes AddImportPath(string fileName) { //is it a valid path to a file? if (!File.Exists(fileName)) { return(Changes.None); } //check if allready exists PwGroup importGroup = m_database.GetImportGroup(); foreach (PwEntry src in importGroup.GetEntries(true)) { if (src.Strings.ReadSafe(KeeShare.SourcePathField) == fileName) { return(Changes.None); } } PwGroup newImportGroup = new PwGroup(true, true, fileName, PwIcon.NetworkServer); newImportGroup.SetParent(importGroup); PwEntry newImportSource = new PwEntry(true, true); newImportSource.Strings.Set(KeeShare.TitleField, new ProtectedString(false, fileName)); newImportSource.Strings.Set(KeeShare.SourcePathField, new ProtectedString(false, fileName)); newImportSource.SetParent(newImportGroup); return(Changes.GroupCreated); }
/// <summary> /// Searches in a given group (non-recursively) for an existing entry for a given wifi information. /// </summary> /// <param name="inGroup">In which group do we search?</param> /// <param name="wlan">The wifi information, we are looking for</param> /// <returns>An entry with the same name or null if there is none.</returns> public PwEntry ExistingEntryInGroup(PwGroup inGroup, WlanProfile wlan) { String enName; // Check if the entry already exists foreach (PwEntry en in inGroup.GetEntries(true)) { // If it has no title field, then the entry will definetivly not be replaced and // we can ignore it if (!en.Strings.Exists(PwDefs.TitleField)) { continue; } // Note that title will be unprotected enName = en.Strings.Get(PwDefs.TitleField).ReadString(); // First, we compare with the name field of the wifi information if (wlan.name.Value != null && enName == wlan.name.ReadString()) { return(en); } // Then, we compare with the SSID field of the wifi information (if it is valid) // Note that SSID will be unprotected if (wlan.ssidConfig.Value != null && wlan.ssidConfig.Value.ssid.Value != null && wlan.ssidConfig.Value.ssid.Value.name != null && enName == wlan.ssidConfig.Value.ssid.Value.name.ReadString()) { return(en); } } return(null); }
public async override Task <List <BreachedEntry> > CheckGroup(PwGroup group, bool expireEntries, bool oldEntriesOnly, bool ignoreDeleted, bool ignoreExpired, IProgress <ProgressItem> progressIndicator, Func <bool> canContinue) { progressIndicator.Report(new ProgressItem(0, "Getting HaveIBeenPwned breach list...")); var entries = group.GetEntries(true).Where(e => (!ignoreDeleted || !e.IsDeleted(pluginHost)) && (!ignoreExpired || !e.Expires)); var breaches = await GetBreaches(progressIndicator, entries, canContinue); var breachedEntries = new List <BreachedEntry>(); await Task.Run(() => { foreach (var breach in breaches) { var pwEntry = breach.Entry; if (pwEntry != null) { if (expireEntries) { ExpireEntry(pwEntry); } } breachedEntries.Add(new BreachedEntry(pwEntry, breach)); } }); return(breachedEntries); }
public static string CreateSummaryList(PwGroup pgItems, bool bStartWithNewPar) { List<PwEntry> l = pgItems.GetEntries(true).CloneShallowToList(); string str = CreateSummaryList(pgItems, l.ToArray()); if((str.Length == 0) || !bStartWithNewPar) return str; return (MessageService.NewParagraph + str); }
public static string CreateSummaryList(PwGroup pgItems, bool bStartWithNewPar) { List <PwEntry> l = pgItems.GetEntries(true).CloneShallowToList(); string str = CreateSummaryList(pgItems, l.ToArray()); if ((str.Length == 0) || !bStartWithNewPar) { return(str); } return(MessageService.NewParagraph + str); }
public static List <PwEntry> ReadEntries(Stream msData, PwDatabase pdContext, bool bCopyIcons) { if (msData == null) { Debug.Assert(false); return(new List <PwEntry>()); } PwGroup pg = ReadGroup(msData, pdContext, bCopyIcons, true, true); return(pg.GetEntries(true).CloneShallowToList()); }
/// <summary> /// Checks if a folder is allready shared to user. /// </summary> /// <param name="group">The group we want to be checked</param> /// <param name="root">The rootNode of the user of whom we want to test shared-status</param> /// <returns></returns> private bool GroupIsSharedToUser(PwGroup group, PwEntry root) { PwObjectList <PwEntry> entryList = group.GetEntries(false); foreach (PwEntry pe in entryList) { if (pe.Strings.ReadSafe(KeeShare.UuidLinkField) == root.Uuid.ToHexString()) { return(true); } } return(false); }
private static PwEntry GetEntryFromGroup(string title, PwGroup group, bool includeSubGroups = true) { PwObjectList <PwEntry> entries = group.GetEntries(includeSubGroups); foreach (PwEntry entry in entries) { if (entry.Strings.Get(PwDefs.TitleField).ReadString() == title) { return(entry); } } return(null); }
private void OnFormLoad(object sender, EventArgs e) { if (m_pgEntrySource == null) { Debug.Assert(false); return; } if (m_ilIcons == null) { Debug.Assert(false); return; } GlobalWindowManager.AddWindow(this); this.Icon = AppIcons.Default; UIUtil.SetExplorerTheme(m_lvEntries, true); m_vColumns.Add(new KeyValuePair <string, string>(PwDefs.TitleField, KPRes.Title)); m_vColumns.Add(new KeyValuePair <string, string>(PwDefs.UserNameField, KPRes.UserName)); m_vColumns.Add(new KeyValuePair <string, string>(PwDefs.UrlField, KPRes.Url)); m_vColumns.Add(new KeyValuePair <string, string>(PwDefs.NotesField, KPRes.Notes)); PwObjectList <PwEntry> vEntries = m_pgEntrySource.GetEntries(true); UIUtil.CreateEntryList(m_lvEntries, vEntries, m_vColumns, m_ilIcons); m_radioIdUuid.Checked = true; if (m_strDefaultRef == PwDefs.TitleField) { m_radioRefTitle.Checked = true; } else if (m_strDefaultRef == PwDefs.UserNameField) { m_radioRefUserName.Checked = true; } // else if(m_strDefaultRef == PwDefs.PasswordField) // m_radioRefPassword.Checked = true; else if (m_strDefaultRef == PwDefs.UrlField) { m_radioRefUrl.Checked = true; } else if (m_strDefaultRef == PwDefs.NotesField) { m_radioRefNotes.Checked = true; } else { m_radioRefPassword.Checked = true; } }
private static void AddAutoExecEntries(List <PwEntry> l, PwGroup pg) { if (pg.Name.Equals("AutoOpen", StrUtil.CaseIgnoreCmp)) { l.AddRange(pg.GetEntries(true)); } else { foreach (PwGroup pgSub in pg.Groups) { AddAutoExecEntries(l, pgSub); } } }
private List <Template> LoadTemplates() { List <Template> templates = new List <Template>(); foreach (var pwEntry in _editPwGroup.GetEntries(false)) { string encoded = pwEntry.Strings.Get(PwDefs.NotesField).ReadString(); string serialized = EncodingEx.Base64.Decoder.DecodeString(Encoding.UTF8, encoded); Template template = (Template)SerializationDotNet2.Xml.Deserializer.DeserializeObjectFromString(serialized, typeof(Template)); templates.Add(template); } return(templates); }
private void OnTimerTick(object sender, EventArgs e) { if (m_bUpdateInProgress) { return; } m_bUpdateInProgress = true; //Trigger refresh of entry list if at least one relevant entry is shown //Relevant = Entry has OTP settings defined try { if (KeePass.Program.MainForm.UIIsInteractionBlocked()) { return; } if (!KeePass.Program.MainForm.Visible) { return; } if (!KeePass.Program.MainForm.ActiveDatabase.IsOpen) { return; } if (KeePass.Program.Config.MainWindow.EntryListColumns.Find(x => x.CustomName == KPOTPColumnName) == null) { return; } PwGroup pg = KeePass.Program.MainForm.GetSelectedGroup(); if (pg == null) { return; } bool bRefresh = pg.GetEntries(KeePass.Program.Config.MainWindow.ShowEntriesOfSubGroups).FirstOrDefault(x => OTPDAO.OTPDefined(x) == OTPDAO.OTPDefinition.Complete) != null; if (!bRefresh && !ForceUpdate) { return; //Update entry list if OTP DB was closed / deleted } if (ForceUpdate) { ForceUpdate = false; } bool LVPossible = LV_DirectUpdate(); if (!LVPossible) { KeePass.Program.MainForm.RefreshEntriesList(); } } finally { m_bUpdateInProgress = false; } }
private void ExportUserHome(PwDatabase database, PwGroup selectedGroup) { //if the seleced group was a user-home, we only export the pwds for that user if (selectedGroup.IsHome()) { foreach (PwEntry entry in selectedGroup.GetEntries(false)) { if (entry.IsUserRootNode() && selectedGroup.Notes.Contains(entry.Uuid.ToHexString())) { Export(database, entry); break; } } } }
private void SetGrouping(AceListGrouping lgPrimary) { Debug.Assert(((int)lgPrimary & ~(int)AceListGrouping.Primary) == 0); if ((int)lgPrimary == (Program.Config.MainWindow.ListGrouping & (int)AceListGrouping.Primary)) { return; } Program.Config.MainWindow.ListGrouping &= ~(int)AceListGrouping.Primary; Program.Config.MainWindow.ListGrouping |= (int)lgPrimary; Debug.Assert((Program.Config.MainWindow.ListGrouping & (int)AceListGrouping.Primary) == (int)lgPrimary); UpdateUI(); if (m_mf == null) { Debug.Assert(false); return; } PwDatabase pd = m_mf.ActiveDatabase; PwGroup pg = m_mf.GetCurrentEntries(); if ((pd == null) || !pd.IsOpen || (pg == null)) { return; // No assert } PwObjectList <PwEntry> pwl = pg.GetEntries(true); if ((pwl.UCount > 0) && EntryUtil.EntriesHaveSameParent(pwl)) { m_mf.UpdateUI(false, null, true, pwl.GetAt(0).ParentGroup, true, null, false); } else { EntryUtil.ReorderEntriesAsInDatabase(pwl, pd); // Requires open DB pg = new PwGroup(true, true); pg.IsVirtual = true; foreach (PwEntry pe in pwl) { pg.AddEntry(pe, false); } m_mf.UpdateUI(false, null, false, null, true, pg, false); } }
/// <summary> /// Timer Event that occurs to refresh the entry list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTimerTick(object sender, EventArgs e) { if ((m_host.MainWindow.ActiveDatabase.IsOpen) && (m_host.MainWindow.Visible)) { if (KeePass.Program.Config.MainWindow.EntryListColumns.Count != liColumnsCount) { liColumnTOTPVisible = false; liColumnsCount = KeePass.Program.Config.MainWindow.EntryListColumns.Count; foreach (var Column in KeePass.Program.Config.MainWindow.EntryListColumns) { if (Column.Type == AceColumnType.PluginExt) { if (Column.CustomName == TrayTOTP_Plugin_Localization.strTOTP) { liColumnTOTPVisible = true; } } } } if (liColumnTOTPVisible) { PwGroup SelectedGroup = m_host.MainWindow.GetSelectedGroup(); if (SelectedGroup != liGroupsPreviousSelected) { liColumnTOTPContains = false; liGroupsPreviousSelected = SelectedGroup; foreach (var Entry in SelectedGroup.GetEntries(true)) { if (SettingsCheck(Entry) && SeedCheck(Entry)) { liColumnTOTPContains = true; } } } } if ((liColumnTOTPVisible) && (liColumnTOTPContains)) //Tests if displayed entries have totps that require refreshing. { var CurrentSeconds = DateTime.Now.Second; if (liRefreshTimerPreviousCounter != CurrentSeconds) { m_host.MainWindow.RefreshEntriesList(); liRefreshTimerPreviousCounter = CurrentSeconds; } } } }
private void OnAnalClick(object sender, EventArgs e) { PwGroup grp = m_host.Database.RootGroup; var entries = grp.GetEntries(true); List <Dictionary <string, string> > lst = new List <Dictionary <string, string> >(); SHA1 sha = new SHA1CryptoServiceProvider(); foreach (var entry in entries) { var ex_tag = ExtractLmbTag(entry.Tags); if (string.IsNullOrEmpty(ex_tag)) { ex_tag = "LMB_N" + CreateString(6); entry.AddTag(ex_tag); } Dictionary <string, string> entry_dict = new Dictionary <string, string>(); entry_dict.Add("username", entry.Strings.ReadSafe(PwDefs.UserNameField)); var passwordHash = string.Join("", sha.ComputeHash(entry.Strings.Get(PwDefs.PasswordField).ReadUtf8()).Select(x => x.ToString("x2"))).ToUpperInvariant(); entry_dict.Add("pass_sha1", passwordHash); entry_dict.Add("url", entry.Strings.ReadSafe(PwDefs.UrlField)); entry_dict.Add("tag", ex_tag); lst.Add(entry_dict); } var fin = new Dictionary <string, object> { { "edges", JsonConvert.SerializeObject(graph_config) }, { "nodes", JsonConvert.SerializeObject(lst) } }; var outs = JsonConvert.SerializeObject(fin); //MessageService.ShowInfo(outs); Process.Start("C:\\Users\\cineq\\repos\\fb-limbo\\limbo-win32-x64\\limbo.exe"); System.Threading.Thread.Sleep(500); SockSend(outs); }
private void AddGroupEntries(PwGroup group) { // Build the entries ViewModels if (group.GetEntriesCount(false) > 0) { foreach (var item in group.GetEntries(false)) { _entries.Add(new PwEntryViewModel(item)); } if (SettingsViewModel.Instance.SortingEnabled) { _entries = _entries.OrderBy(e => e.Title).ToList(); } } }
internal static void Expire(this PwGroup pg, bool bExpireAll) { PwObjectList <PwEntry> entries = pg.GetEntries(false); foreach (PwEntry pe in entries) { pe.Expire(bExpireAll); } PwObjectList <PwGroup> groups = pg.GetGroups(false); foreach (PwGroup g in groups) { g.Expire(bExpireAll); } }
public async override Task <List <BreachedEntry> > CheckGroup(PwGroup group, bool expireEntries, bool oldEntriesOnly, bool ignoreDeleted, bool ignoreExpired, IProgress <ProgressItem> progressIndicator, Func <bool> canContinue) { progressIndicator.Report(new ProgressItem(0, "Getting HaveIBeenPwned breach list...")); var entries = group.GetEntries(true).Where(e => (!ignoreDeleted || !e.IsDeleted(pluginHost)) && (!ignoreExpired || !e.Expires)).ToArray(); var usernames = entries.Select(e => e.Strings.ReadSafe(PwDefs.UserNameField).Trim().ToLower()).Distinct(); var breaches = await GetBreaches(progressIndicator, usernames, canContinue); var breachedEntries = new List <BreachedEntry>(); await Task.Run(() => { foreach (var breachGrp in breaches.GroupBy(x => x.Username)) { var username = breachGrp.Key; var oldestUpdate = entries.Min(e => e.GetPasswordLastModified()); foreach (var breach in breachGrp) { if (oldEntriesOnly && oldestUpdate >= breach.BreachDate) { continue; } var pwEntry = string.IsNullOrWhiteSpace(breach.Domain) ? null : entries.FirstOrDefault(e => e.GetUrlDomain() == breach.Domain && breach.Username == e.Strings.ReadSafe(PwDefs.UserNameField).Trim().ToLower()); if (pwEntry != null) { var lastModified = pwEntry.GetPasswordLastModified(); if (oldEntriesOnly && lastModified >= breach.BreachDate) { continue; } if (expireEntries) { ExpireEntry(pwEntry); } } breachedEntries.Add(new BreachedEntry(pwEntry, breach)); } } }); return(breachedEntries); }
/// <summary> /// Timer Event that occurs to refresh the entry list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTimerTick(object sender, EventArgs e) { if (PluginHost.MainWindow.ActiveDatabase.IsOpen && PluginHost.MainWindow.Visible) { if (KeePass.Program.Config.MainWindow.EntryListColumns.Count != _liColumnsCount) { _liColumnTotpVisible = false; _liColumnsCount = KeePass.Program.Config.MainWindow.EntryListColumns.Count; foreach (var column in KeePass.Program.Config.MainWindow.EntryListColumns) { if (column.Type == AceColumnType.PluginExt && column.CustomName == Localization.Strings.TOTP) { _liColumnTotpVisible = true; } } } if (_liColumnTotpVisible) { PwGroup selectedGroup = PluginHost.MainWindow.GetSelectedGroup(); if (selectedGroup != _liGroupsPreviousSelected) { _liColumnTotpContains = false; _liGroupsPreviousSelected = selectedGroup; foreach (var entry in selectedGroup.GetEntries(KeePass.Program.Config.MainWindow.ShowEntriesOfSubGroups)) { if (TOTPEntryValidator.HasSeed(entry)) { _liColumnTotpContains = true; break; //No need to check remaining entries } } } } if (_liColumnTotpVisible && _liColumnTotpContains) //Tests if displayed entries have totps that require refreshing. { var currentSeconds = DateTime.Now.Second; if (_liRefreshTimerPreviousCounter != currentSeconds) { PluginHost.MainWindow.RefreshEntriesList(); _liRefreshTimerPreviousCounter = currentSeconds; } } } }
private void ExportUsingGroupsOfUser(PwDatabase database, PwGroup selectedGroup) { //if the menu was called from a GroupsGroup we try to find all users in that group and then export //the pwds for all of them. PwGroup groupsGroup = database.GetGroupsGroup(); if (selectedGroup == groupsGroup || selectedGroup.IsInsideParent(groupsGroup)) { foreach (PwEntry entry in selectedGroup.GetEntries(true)) { if (database.IsUserProxy(entry)) { Export(database, database.GetProxyTargetFor(entry)); } } } }
/// <summary> /// The function collects all export pathes for the given user. All these /// pathes are used to get a copy of the delta container /// </summary> /// <param name="rootNode">Specifies the user we want to know the expPathes of.</param> /// <returns>A <c>List<string></c> containing all the expPathes.</returns> private List <string> GetAllExportPaths(PwDatabase database, PwEntry rootNode) { List <string> expList = new List <string>(); PwGroup exportGroup = database.GetExportGroup(); foreach (PwEntry proxy in exportGroup.GetEntries(true)) { if (proxy.Strings.ReadSafe(KeeShare.UuidLinkField) == rootNode.Uuid.ToHexString()) { if (proxy.ParentGroup.IsValidExportInfo()) { expList.Add(proxy.ParentGroup.Name); } } } return(expList); }
public async override Task <List <BreachedEntry> > CheckGroup(PwGroup group, bool expireEntries, bool oldEntriesOnly, bool ignoreDeleted, bool ignoreExpired, IProgress <ProgressItem> progressIndicator, Func <bool> canContinue) { progressIndicator.Report(new ProgressItem(0, "Getting Cloudbleed breach list...")); var breaches = await GetBreaches(progressIndicator); var entries = group.GetEntries(true).Where(e => (!ignoreDeleted || !e.IsDeleted(pluginHost)) && (!ignoreExpired || !e.Expires)).ToArray(); var breachedEntries = new List <BreachedEntry>(); uint counter = 0; var entryCount = entries.Length; await Task.Run(() => { foreach (var entry in entries) { if (!canContinue()) { break; } var url = entry.GetUrlDomain(); if (!string.IsNullOrEmpty(url)) { var lastModified = entry.GetPasswordLastModified(); var domainBreaches = breaches.Where(b => url == b && (!oldEntriesOnly || lastModified < new DateTime(2017, 02, 17))); if (domainBreaches.Any()) { breachedEntries.Add(new BreachedEntry(entry, new CloudbleedSiteEntry(string.Empty, entry.GetUrlDomain()))); if (expireEntries) { ExpireEntry(entry); } } } progressIndicator.Report(new ProgressItem((uint)((double)counter / entryCount * 100), string.Format("Checking {0} for breaches", url))); counter++; } }); breaches = null; return(breachedEntries); }
public async override Task <List <BreachedEntry> > CheckGroup(PwGroup group, bool expireEntries, bool oldEntriesOnly, bool ignoreDeleted, bool ignoreExpired, IProgress <ProgressItem> progressIndicator, Func <bool> canContinue) { progressIndicator.Report(new ProgressItem(0, "Getting HaveIBeenPwned breach list...")); var breaches = await GetBreaches(progressIndicator); var entries = group.GetEntries(true).Where(e => (!ignoreDeleted || !e.IsDeleted(pluginHost)) && (!ignoreExpired || !e.Expires)).ToArray(); var breachedEntries = new List <BreachedEntry>(); uint counter = 0; var entryCount = entries.Length; await Task.Run(() => { foreach (var entry in entries) { if (!canContinue()) { break; } var url = entry.GetUrlDomain(); var userName = entry.Strings.ReadSafe(PwDefs.UserNameField); var lastModified = entry.GetPasswordLastModified(); if (!string.IsNullOrEmpty(url)) { var domainBreaches = breaches.Where(b => !string.IsNullOrWhiteSpace(b.Domain) && url == b.Domain && (!oldEntriesOnly || lastModified < b.BreachDate)).OrderBy(b => b.BreachDate); if (domainBreaches.Any()) { breachedEntries.Add(new BreachedEntry(entry, domainBreaches.Last())); if (expireEntries) { ExpireEntry(entry); } } } // this checker is so quick it probably doesn't need to report progress //progressIndicator.Report(new ProgressItem((uint)((double)counter / entryCount * 100), string.Format("Checking {0} for breaches", url))); } counter++; }); return(breachedEntries); }
public static PwObjectList <PwEntry> GetPossibleTemplates(IPluginHost m_host) { PwObjectList <PwEntry> entries = new PwObjectList <PwEntry>(); PwGroup group = template_group(m_host); if (group == null) { return(entries); } PwObjectList <PwEntry> all_entries = group.GetEntries(true); foreach (PwEntry entry in all_entries) { if (entry.Strings.Exists("_etm_template")) { entries.Add(entry); } } return(entries); }
private static PwObjectList <PwEntry> GetMatching(PwDatabase sourceDb, Settings settings) { PwObjectList <PwEntry> entries = new PwObjectList <PwEntry>(); if (!string.IsNullOrEmpty(settings.Tag) && string.IsNullOrEmpty(settings.Group)) { // Tag only export sourceDb.RootGroup.FindEntriesByTag(settings.Tag, entries, true); } else if (string.IsNullOrEmpty(settings.Tag) && !string.IsNullOrEmpty(settings.Group)) { // Tag and group export PwGroup groupToExport = sourceDb.RootGroup.GetFlatGroupList().FirstOrDefault(g => g.Name == settings.Group); if (groupToExport == null) { throw new ArgumentException("No group with the name of the Group-Setting found."); } entries = groupToExport.GetEntries(true); } else if (!string.IsNullOrEmpty(settings.Tag) && !string.IsNullOrEmpty(settings.Group)) { // Tag and group export PwGroup groupToExport = sourceDb.RootGroup.GetFlatGroupList().FirstOrDefault(g => g.Name == settings.Group); if (groupToExport == null) { throw new ArgumentException("No group with the name of the Group-Setting found."); } groupToExport.FindEntriesByTag(settings.Tag, entries, true); } else { throw new ArgumentException("At least one of Tag or ExportFolderName must be set."); } return(entries); }
internal static void RecalcExpiry(this PwGroup pg) { PwObjectList <PwEntry> entries = pg.GetEntries(false); foreach (PwEntry pe in entries) { if (pe.GetPEDValue(false).Inherit) { pe.RecalcExpiry(true); } } PwObjectList <PwGroup> groups = pg.GetGroups(false); foreach (PwGroup g in groups) { if (g.GetPEDValue(false).Inherit) { RecalcExpiry(g); } } }
// Get all user defined strings internal static List<string> GetListEntriesUserStrings(PwGroup pwg) { List<string> strl = new List<string>(); // Add all known pwentry strings foreach (PwEntry pe in pwg.GetEntries(true)) { foreach (KeyValuePair<string, ProtectedString> pstr in pe.Strings) { if (!strl.Contains(pstr.Key)) { if (!PwDefs.IsStandardField(pstr.Key)) { strl.Add(pstr.Key); } } } } strl.Sort(); return strl; }
private void AddItemsToMenu(ToolStripMenuItem Parent, PwGroup RootGroup) { //s² - 2009/06/21 - Sorting of PW-Entries in FloatingPanel List<PwEntry> myList = RootGroup.GetEntries(is_searching).CloneShallowToList(); DateTime now = DateTime.Now; if (FOptions.sortAlphabetical) { myList.Sort((X, Y) => X.Strings.ReadSafe(PwDefs.TitleField).CompareTo(Y.Strings.ReadSafe(PwDefs.TitleField))); } //End s² - 2009/06/21 - Sorting of PW-Entries in FloatingPanel foreach (PwEntry Entry in myList) { ToolStripMenuItem Item = new ToolStripMenuItem(); Item.Tag = Entry; Item.Text = Entry.Strings.ReadSafe(PwDefs.TitleField); Item.BackColor = Entry.BackgroundColor; Item.DropDownOpening += miItem_DropDownOpening; Item.DoubleClick += miItem_OpenURL; Item.DoubleClickEnabled = true; PwIcon IconIndex = Entry.IconId; PwUuid CustomIconID = Entry.CustomIconUuid; if (CustomIconID != PwUuid.Zero) Item.Image = Host.Database.GetCustomIcon(CustomIconID); else Item.Image = Host.MainWindow.ClientIcons.Images[(int)IconIndex]; if (Item.Image == null) Item.Image = ilIcons.Images[5]; if (Entry.Expires){ if (Entry.ExpiryTime <= now) { Item.Image = ilIcons.Images[7]; Item.Font = new Font(Item.Font, Item.Font.Style | FontStyle.Strikeout); } Item.ToolTipText = KPRes.ExpiryTime + ": " + Entry.ExpiryTime; } if (Parent == null) pmPasswords.Items.Add(Item); else Parent.DropDownItems.Add(Item); ToolStripMenuItem Dummy = new ToolStripMenuItem(); Dummy.Tag = null; Dummy.Text = "dummy"; Dummy.Enabled = false; Item.DropDownItems.Add(Dummy); } }
private void loadSubMenuItems(PwGroup group, MenuItem currMenu) { const string UserName = "******"; const string Title = "Title"; const string URL = "URL"; const string Password = "******"; const string CopyPwdCaption = "Copy Password"; const string CopyUrlPwdCaption = "Launch URL && Copy Password"; const string EditItemCaption = "Edit this item"; uint grpCount = 0, entryCount = 0; group.GetCounts(false, out grpCount, out entryCount); if (entryCount > 0) { foreach (var j in group.GetEntries(false)) { var titleMenu = new MenuItem(j.Strings.ReadSafe(Title)); currMenu.MenuItems.Add(titleMenu); titleMenu.MenuItems.Add(new MenuItem(j.Strings.ReadSafe(UserName))); var name = j.ParentGroup.Name + MenuSeparator + j.Strings.ReadSafe(Title) + MenuSeparator + j.Strings.ReadSafe(UserName); var pwMnu = new MenuItem(CopyPwdCaption, onPwdMenuClick); pwMnu.Name = name; titleMenu.MenuItems.Add(pwMnu); var pwlMnu = new MenuItem(CopyUrlPwdCaption, onUrlPwdMenuClick); pwlMnu.Name = name; titleMenu.MenuItems.Add(pwlMnu); currMenu.MenuItems.Add(new MenuItem(MenuSeparator)); var editMnu = new MenuItem(EditItemCaption, OnEditItemClick); editMnu.Name = name; titleMenu.MenuItems.Add(editMnu); try { localPwdHash.Add(name, j.Strings.ReadSafe(Password)); localURLHash.Add(name, j.Strings.ReadSafe(URL)); } catch (Exception e) { MessageBox.Show("Dupe found: " + name + MenuSeparator + j.Strings.ReadSafe(URL)); } } } // are there any group children if (grpCount > 0) { foreach (var j in group.Groups) { var newGroupMenu = new MenuItem(j.Name); currMenu.MenuItems.Add(newGroupMenu); loadSubMenuItems(j, newGroupMenu); } } }
/// <summary> /// Returns a list of every entry contained within a group (not recursive) /// </summary> /// <param name="uuid">the unique ID of the group we're interested in.</param> /// <param name="current__"></param> /// <returns>the list of every entry directly inside the group.</returns> private LightEntry[] GetChildEntries(PwDatabase pwd, PwGroup group, bool fullDetails) { List<Entry> allEntries = new List<Entry>(); List<LightEntry> allLightEntries = new List<LightEntry>(); if (group != null) { KeePassLib.Collections.PwObjectList<PwEntry> output; output = group.GetEntries(false); foreach (PwEntry pwe in output) { if (EntryIsInRecycleBin(pwe, pwd)) continue; // ignore if it's in the recycle bin if (string.IsNullOrEmpty(pwe.Strings.ReadSafe("URL"))) continue; if (fullDetails) { Entry kpe = (Entry)GetEntryFromPwEntry(pwe, MatchAccuracy.None, true, pwd, true); if (kpe != null) // is null if entry is marked as hidden from KPRPC allEntries.Add(kpe); } else { LightEntry kpe = GetEntryFromPwEntry(pwe, MatchAccuracy.None, false, pwd, true); if (kpe != null) // is null if entry is marked as hidden from KPRPC allLightEntries.Add(kpe); } } if (fullDetails) { allEntries.Sort(delegate(Entry e1, Entry e2) { return e1.Title.CompareTo(e2.Title); }); return allEntries.ToArray(); } else { allLightEntries.Sort(delegate(LightEntry e1, LightEntry e2) { return e1.Title.CompareTo(e2.Title); }); return allLightEntries.ToArray(); } } return null; }
/// <summary> /// Returns a list of every entry contained within a group (not recursive) /// </summary> /// <param name="uuid">the unique ID of the group we're interested in.</param> /// <param name="current__"></param> /// <returns>the list of every entry directly inside the group.</returns> private LightEntry[] GetChildEntries(PwDatabase pwd, PwGroup group, bool fullDetails) { List<Entry> allEntries = new List<Entry>(); List<LightEntry> allLightEntries = new List<LightEntry>(); if (group != null) { KeePassLib.Collections.PwObjectList<PwEntry> output; output = group.GetEntries(false); foreach (PwEntry pwe in output) { if (pwd.RecycleBinUuid.EqualsValue(pwe.ParentGroup.Uuid)) continue; // ignore if it's in the recycle bin if (pwe.Strings.Exists("Hide from KeeFox") || pwe.Strings.Exists("Hide from KPRPC") || string.IsNullOrEmpty(pwe.Strings.ReadSafe("URL"))) continue; if (fullDetails) { Entry kpe = (Entry)GetEntryFromPwEntry(pwe, false, true, pwd); allEntries.Add(kpe); } else { LightEntry kpe = GetEntryFromPwEntry(pwe, false, false, pwd); allLightEntries.Add(kpe); } } if (fullDetails) { allEntries.Sort(delegate(Entry e1, Entry e2) { return e1.Title.CompareTo(e2.Title); }); return allEntries.ToArray(); } else { allLightEntries.Sort(delegate(LightEntry e1, LightEntry e2) { return e1.Title.CompareTo(e2.Title); }); return allLightEntries.ToArray(); } } return null; }