private List <LoginFieldS> ParsJson(string filename)
        {
            string tempLine;

            List <LoginFieldS> lp = new List <LoginFieldS>();
            var json_serializer   = new JavaScriptSerializer();

            using (StreamReader file = new System.IO.StreamReader(filename))
            {
                while ((tempLine = file.ReadLine()) != null)
                {
                    try
                    {
                        if (tempLine == "")
                        {
                            continue;
                        }
                        var    dataValue = (IDictionary <string, object>)json_serializer.DeserializeObject(tempLine);
                        string url       = HIOStaticValues.getTitleNameURI(dataValue["url"].ToString()).GetUTF8String(256);
                        string username  = dataValue["username"].ToString().GetUTF8String(64);
                        string password  = dataValue["password"].ToString().GetUTF8String(64);
                        string title     = HIOStaticValues.getTitleNameURI(dataValue["title"].ToString()).GetUTF8String(64);
                        string appid     = dataValue["appid"].ToString().GetUTF8String(64);
                        string last_used = dataValue["last_used"].ToString().GetUTF8String(64);
                        int    counter   = int.Parse(dataValue["counter"].ToString());

                        lp.Add(new LoginFieldS {
                            url = url, userName = username, password = password, title = title, appID = title, last_used = last_used, popularity = counter
                        });
                    }
                    catch {
                        continue;
                    }
                }
            }
            return(lp);
        }
Exemple #2
0
        /// <summary>
        /// Fetching user passwords from browser
        /// </summary>
        /// <param name="bas">using for get handle hid device</param>
        /// <returns>List of users</returns>
        public List <LoginFieldS> getDataFromChrome()
        {
            List <LoginFieldS> userlist = new List <LoginFieldS>();

            try
            {
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                var    profiles = FindProfileName(path);
                foreach (var profile in profiles)
                {
                    string db_way  = path + "\\Google\\Chrome\\User Data\\" + profile + "\\Login Data";
                    string db_way2 = path + "\\Google\\Chrome\\User Data\\" + profile + "\\Login Data.hio";
                    File.Copy(db_way, db_way2, true);
                    string db_field = "logins";
                    string sql;
                    byte[] entropy = null;
                    string description;


                    DataBase  dbLocal          = new DataBase();
                    string    ConnectionString = "data source=" + db_way2 + ";New=True;UseUTF16Encoding=True";
                    DataTable DB = new DataTable();
                    sql = string.Format("SELECT  DISTINCT  * FROM {0}", db_field);
                    using (SQLiteConnection connect = new SQLiteConnection(ConnectionString))
                    {
                        SQLiteCommand     command = new SQLiteCommand(sql, connect);
                        SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
                        adapter.Fill(DB);
                        int rows = DB.Rows.Count;

                        for (int i = 0; i < rows; i++)
                        {
                            Trace.WriteLine("DB.Rows.Count: " + rows);



                            byte[] byteArray = (byte[])DB.Rows[i][5];
                            byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description);
                            if (((string)DB.Rows[i][7]).Split(':')[0] == "android")
                            {
                                continue;
                            }

                            string username = DB.Rows[i][3].ToString().GetUTF8String(64);
                            string password = (new UTF8Encoding(true).GetString(decrypted)).ToString().GetUTF8String(64);
                            string title    = HIOStaticValues.getTitleNameURI(DB.Rows[i][7].ToString()).GetUTF8String(64);
                            string url      = HIOStaticValues.getDomainNameURI(DB.Rows[i][7].ToString()).GetUTF8String(256);

                            if (password != "" && (string)DB.Rows[i][3] != "")
                            {
                                if (dbLocal.getInfoFromDB(url, username, "").Count == 0)
                                {
                                    userlist.Add(new LoginFieldS {
                                        password = new UTF8Encoding(true).GetString(decrypted), userName = (string)DB.Rows[i][3], title = title, url = url
                                    });
                                }
                            }
                        }


                        adapter.Dispose();
                        connect.Close();
                    }
                }
                return(userlist);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }