Cookie Chrome

Регистрация
20.02.2019
Сообщения
295
Благодарностей
35
Баллы
28
Доброго дня, в курсе можт кто делал, на виртуалке выгрузить куки без проблем с chrome можно.
Как вставить свою куку? Файл sqlite в него чето ничем не получается вгрузить(
 

usboff

Client
Регистрация
25.08.2021
Сообщения
110
Благодарностей
80
Баллы
28
Раньше когда была подобная необходимость использовал такой код:

C#:
var droid = instance.DroidInstance;
// Установить sqlite, если еще не установлен
droid.Sqlite3.Install();
var cookiePath = droid.App.GetCookiePath("com.android.chrome");
var domain = ".ya.ru";
var top_frame_site_key = "";
var name = "ya-auth";
var value = project.Variables["ya-auth"].Value;
var encrypted_value = "";
var path = "/";
var is_secure = Convert.ToInt32(true);
var http_only = Convert.ToInt32(true);
var create_time = DateTime.Now;
var expire_time = create_time.AddDays(1); // +1 day
var has_expires = Convert.ToInt32(true);
var is_persistent = Convert.ToInt32(true);
var priority = 1;
var samesite = 1; //LAX
var source_scheme = 2;
var source_port = 443;
var is_same_party = Convert.ToInt32(false);
var create_time_converted = (((DateTimeOffset)create_time).ToUnixTimeSeconds() + 11644421940) * 1_000_000;
var expire_time_converted = (((DateTimeOffset)expire_time).ToUnixTimeSeconds() + 11644421940) * 1_000_000;
//var query = $"INSERT INTO cookies (host_key, top_frame_site_key, name, value, encrypted_value, path, expires_utc, has_expires, is_persistent, priority, samesite, source_scheme, source_port, is_secure, is_httponly, is_same_party, creation_utc, last_access_utc, last_update_utc) VALUES('{domain}', '{top_frame_site_key}', '{name}', '{value}', '{encrypted_value}', '{path}', {expire_time_converted}, {has_expires}, {is_persistent}, {priority}, {samesite}, {source_scheme}, {source_port}, {is_secure}, {http_only}, {is_same_party}, {create_time_converted}, {create_time_converted}, {create_time_converted});";
var query = $"INSERT INTO cookies (host_key, top_frame_site_key, name, value, encrypted_value, path, expires_utc, has_expires, is_persistent, priority, samesite, source_scheme, source_port, is_secure, is_httponly,  creation_utc, last_access_utc, last_update_utc) VALUES('{domain}', '{top_frame_site_key}', '{name}', '{value}', '{encrypted_value}', '{path}', {expire_time_converted}, {has_expires}, {is_persistent}, {priority}, {samesite}, {source_scheme}, {source_port}, {is_secure}, {http_only},  {create_time_converted}, {create_time_converted}, {create_time_converted});";

return droid.Sqlite3.ExecuteQuery(cookiePath, query);
Можно обернуть в цикл, если нужно ставить сразу несколько значений, прежде распрасив и приведя к нужному формату, далее устанавливая переменными то или иное значение.
Код привёл в целом как пример, который ранее точно работал, нужно лишь допилить его под себя.
 
  • Спасибо
Реакции: alexeipigilov12
Регистрация
20.02.2019
Сообщения
295
Благодарностей
35
Баллы
28
А не в курсе, что не так?
Все вставляется норм в куку, кроме value, там экранирование чтоли нужно какое то?
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)