I found a chrome cookie and I use sqliteBrowser to open it and find the cookie structure.
And I also successfully read the cookies from this file, although the cookie value is encrypted, but I still find a way to decrypt it.
I also noticed that the create_utc cookie uses a time counter from 01.16.01.
All I want to say is that I did a little work and already know the structure of the chrome file files.
But the question is, when I want to insert a new record into this file using C # System.data.sqlite, my program just could not insert this record and go into some kind of state, such as deadlock, I notice that this The situation is caused by the fact that the executeNoQuery method does not return !!!
the same sql syntax works fine in my test sqlite file, so I assume the question is caused by the chrome file file.
Can someone help me? thank!
The following is my code trying to set a cookie:
private static bool SetCookie_Chrome(string strHost, string strField, string value,DateTime expiresDate)
{
bool fRtn = false;
string strPath, strDb;
strPath = GetChromeCookiePath();
if (string.Empty == strPath)
return false;
try
{
strDb = "Data Source=" + strPath + ";pooling=false";
SQLiteConnection conn = new SQLiteConnection(strDb);
SQLiteCommand cmd = conn.CreateCommand();
Byte[] encryptedValue=getEncryptedValue(value);
cmd.CommandText = "INSERT INTO `cookies`(`creation_utc`,`host_key`,`name`,`value`,`path`,`expires_utc`,`secure`,`httponly`,`last_access_utc`,`has_expires`,`persistent`,`priority`,`encrypted_value`) "+
"VALUES ("+TimeUtil.get_creation_utc()+",'"+strHost+"','"+strField+"','','/',"+
TimeUtil.get_specific_utc(expiresDate.Year,expiresDate.Month,expiresDate.Day,expiresDate.Hour,expiresDate.Minute,expiresDate.Second)+
",0,0," + TimeUtil.get_creation_utc() + ",1,1,1,@evalue);";
cmd.Parameters.Add("@evalue", System.Data.DbType.Binary).Value = encryptedValue;
conn.Open();
int rtV=cmd.ExecuteNonQuery();
conn.Close();
fRtn = true;
}
catch (Exception e)
{
fRtn = false;
}
return fRtn;
}