/// <summary> /// Enumerates the entries of the signons.sqlite file. /// </summary> /// <param name="profilePath">Path of the profile folder</param> /// <returns></returns> private static IEnumerable <EntryInfo> ReadSignonsFile(string profilePath) { var entries = new List <EntryInfo>(); var dbPath = Path.Combine(profilePath, "signons.sqlite"); if (File.Exists(dbPath)) { try { using (var db = new DBHandler(dbPath)) { DataTable dt; db.Query(out dt, "SELECT hostname, encryptedUsername, encryptedPassword, timeCreated, timePasswordChanged FROM moz_logins"); foreach (var row in dt.AsEnumerable()) { try { entries.Add(new EntryInfo { Hostname = (row["hostname"] as string).Trim(), Username = PK11_Decrypt(row["encryptedUsername"] as string).Trim(), Password = PK11_Decrypt(row["encryptedPassword"] as string), Created = DateUtils.FromUnixTimeMilliseconds((long)row["timeCreated"]), Modified = DateUtils.FromUnixTimeMilliseconds((long)row["timePasswordChanged"]) }); } catch { // Skip faulty entries } } } } catch (DbException ex) { throw new Exception(string.Format("Error while using the browsers login database. It may help to close all running instances of the browser.\n\n{0}", StrUtil.FormatException(ex)), ex); } } return(entries); }
/// <summary> /// Enumerates the entries of the signons.sqlite file. /// </summary> /// <param name="profilePath">Path of the profile folder</param> /// <returns></returns> private IEnumerable <EntryInfo> ReadSignonsFile(string profilePath) { using (var db = new DBHandler(Path.Combine(profilePath, "signons.sqlite"))) { DataTable dt = null; try { db.Query(out dt, "SELECT hostname, encryptedUsername, encryptedPassword, timeCreated, timePasswordChanged FROM moz_logins"); } catch { yield break; } foreach (var row in dt.AsEnumerable()) { EntryInfo entry; try { entry = new EntryInfo { Hostname = (row["hostname"] as string).Trim(), Username = PK11_Decrypt(row["encryptedUsername"] as string).Trim(), Password = PK11_Decrypt(row["encryptedPassword"] as string), Created = DateUtils.FromUnixTimeMilliseconds((long)row["timeCreated"]), Modified = DateUtils.FromUnixTimeMilliseconds((long)row["timePasswordChanged"]) }; } catch { continue; } yield return(entry); } } }