Пример #1
0
 public static List<Browser> getInstalledBrowsers()
 {
     RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default);
     RegistryKey browsers = baseKey.OpenSubKey("SOFTWARE\\Wow6432Node\\Clients\\StartMenuInternet");
     String appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
     String local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
     List<Browser> browserList = new List<Browser>();
     foreach (String subkey in browsers.GetSubKeyNames())
     {
         if (subkey.Contains("FIREFOX"))
         {
             String fireFox = Path.Combine(appData, "Mozilla", "Firefox", "Profiles");
             if (Directory.Exists(fireFox))
             {
                 foreach (String directory in Directory.EnumerateDirectories(fireFox))
                 {
                     String path = Path.Combine(directory, "cookies.sqlite");
                     if (File.Exists(path))
                     {
                         byte[] data = CookieFactory.getDataSafe(path);
                         List<FirefoxCookie> cookies = CookieFactory.processSQLData<FirefoxCookie>("moz_cookies", data);
                         Browser browser = new Browser(BrowserType.FIREFOX);
                         foreach (FirefoxCookie cookie in cookies)
                         {
                             browser.cookies.Add(new Cookie(cookie.name, cookie.value, cookie.path, cookie.hostName));
                         }
                         browserList.Add(browser);
                     }
                 }
             }
         }
         else if (subkey.Contains("Chrome"))
         {
             String chrome = Path.Combine(local, "Google", "Chrome", "User Data", "Default");
             if (Directory.Exists(chrome))
             {
                 String path = Path.Combine(chrome, "Cookies");
                 if (File.Exists(path))
                 {
                     byte[] data = CookieFactory.getDataSafe(path);
                     List<ChromeCookie> cookies = CookieFactory.processSQLData<ChromeCookie>("cookies", data);
                     Browser browser = new Browser(BrowserType.CHROME);
                     foreach (ChromeCookie cookie in cookies)
                     {
                         browser.cookies.Add(new Cookie(cookie.name, cookie.value, cookie.path, cookie.hostName));
                     }
                     browserList.Add(browser);
                 }
             }
         }
     }
     return browserList;
 }
Пример #2
0
 private void loadCookiesFromBrowser(Browser browser)
 {
     entries.Clear();
     foreach (Cookie cookie in browser.cookies)
     {
         String expires = (DateTime.Now + new TimeSpan(7, 0, 0, 0)).ToUniversalTime().ToString("ddd, dd-MMM-yyyy HH:mm:ss") + " GMT";
         String str = cookie.ToString() + "; expires = " + expires;
         InternetSetCookie(cookie.Domain + cookie.Path, null, str);
         DomainEntry entry = new DomainEntry(cookie.Domain);
         if (!entries.Contains(entry))
         {
             entries.Add(new DomainEntry(cookie.Domain));
         }
         else
         {
             entries[entries.IndexOf(entry)].Count++;
         }
     }
     listView.Items.SortDescriptions.Add(new SortDescription("Count", ListSortDirection.Descending));
 }