Null values when reading from Chrome SQLite cookie database

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 16:44:06

问题


C# Chrome SQLite value not read ? Mozilla cookie value read but chrome cookie value null. What is the correct way to read this cookie value?

//String connString = "Data Source=C:\\Users\\XXXX\\AppData\\Roaming\\Opera Software\\Opera Stable\\Cookies;Version=3;New=False;Compress=True;";
String connString = "Data Source=C:\\Users\\XXXX\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cookies;Version=3;New=False;Compress=True;";
//String connString = "Data Source=C:\\Users\\XXXX\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\eac8q0hd.default\\cookies.sqlite";
using (SQLiteConnection conn = new SQLiteConnection(connString))
{
   StringBuilder query = new StringBuilder();
   //chrome
   query.Append("SELECT value FROM cookies WHERE host_key LIKE '%.search.cpan.org%' AND name LIKE '%__utmc%';");
   //mozilla
   //query.Append("SELECT value FROM moz_cookies WHERE host LIKE '%.oasgames.com%' AND name LIKE '%__utmz%';");
   //query.Append("ORDER BY name");
   using (SQLiteCommand cmd = new SQLiteCommand(query.ToString(), conn))
   {
      conn.Open();
      using (SQLiteDataReader dr = cmd.ExecuteReader())
      {
         while (dr.Read())
         {
            textBox1.Text = dr.GetValue(0).ToString();
            // textBox1.Text = dr.GetValue(0) + " " + dr.GetValue(1) + " " + dr.GetValue(2) + " " + dr.GetValue(3) + " " + dr.GetValue(4) + " " + dr.GetValue(5);
         }
      }
   }
}

回答1:


The values are encrypted and stored as "encrypted_value". You will not be able to read the value, but can read the blob stored in "encrypted_value".

If you want to read the value, you could write a PowerShell script to decrypt it: https://stackoverflow.com/a/38701402

I'm reading just the encrypted value to make sure that there is a value there

SELECT encrypted_value FROM cookies WHERE host_key LIKE '%XXX%' AND name LIKE '%XXXX%';


来源:https://stackoverflow.com/questions/24047326/null-values-when-reading-from-chrome-sqlite-cookie-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!