Я написал сценарий C# для расшифровки и сохранения паролей браузеров из браузеров на основе хрома (хром, края и т. Д.), Но я получаю эту ошибку: < /p>
Ошибка SQLite: невозможно загрузить dll 'e_sqlite3' или одну из его зависимости: указанный модуль не может быть найден. (0x8007007e) < /p>
Я установил необходимые пакеты Nuget (System.data.sqlite), но это все еще не работает. Скрипт копирует файлы базы данных браузеров в каталог Temp и пытается прочитать их, но не удается на подключении SQLite. < /P>
My Environment: < /p>
Windows 10 < /p>
Visual Studio 2022 < /p>
ishy.net 8.0 < /p>
< /p>
.using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace PasswordDecryptor
{
public class Password
{
public string Url { get; set; }
public string Username { get; set; }
public string PasswordValue { get; set; }
}
public static class Crypto
{
[System.Runtime.InteropServices.DllImport("crypt32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
private static extern bool CryptUnprotectData(
ref DATA_BLOB pCipherText,
ref string pszDescription,
ref DATA_BLOB pEntropy,
IntPtr pReserved,
ref CRYPTPROTECT_PROMPTSTRUCT pPrompt,
int dwFlags,
ref DATA_BLOB pPlainText);
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
private struct DATA_BLOB
{
public int cbData;
public IntPtr pbData;
}
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
private struct CRYPTPROTECT_PROMPTSTRUCT
{
public int cbSize;
public int dwPromptFlags;
public IntPtr hwndApp;
public string szPrompt;
}
public static byte[] DPAPIDecrypt(byte[] cipherText, byte[] entropy = null)
{
DATA_BLOB plainText = new DATA_BLOB();
DATA_BLOB cipherBlob = new DATA_BLOB();
DATA_BLOB entropyBlob = new DATA_BLOB();
CRYPTPROTECT_PROMPTSTRUCT prompt = new CRYPTPROTECT_PROMPTSTRUCT()
{
cbSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(CRYPTPROTECT_PROMPTSTRUCT)),
dwPromptFlags = 0,
hwndApp = IntPtr.Zero,
szPrompt = null
};
string description = string.Empty;
try
{
cipherBlob.pbData = System.Runtime.InteropServices.Marshal.AllocHGlobal(cipherText.Length);
cipherBlob.cbData = cipherText.Length;
System.Runtime.InteropServices.Marshal.Copy(cipherText, 0, cipherBlob.pbData, cipherText.Length);
if (entropy != null)
{
entropyBlob.pbData = System.Runtime.InteropServices.Marshal.AllocHGlobal(entropy.Length);
entropyBlob.cbData = entropy.Length;
System.Runtime.InteropServices.Marshal.Copy(entropy, 0, entropyBlob.pbData, entropy.Length);
}
CryptUnprotectData(ref cipherBlob, ref description, ref entropyBlob, IntPtr.Zero, ref prompt, 1, ref plainText);
byte[] result = new byte[plainText.cbData];
System.Runtime.InteropServices.Marshal.Copy(plainText.pbData, result, 0, plainText.cbData);
return result;
}
catch (Exception ex)
{
Console.WriteLine($"DPAPI Decrypt error: {ex.Message}");
return null;
}
finally
{
if (cipherBlob.pbData != IntPtr.Zero)
System.Runtime.InteropServices.Marshal.FreeHGlobal(cipherBlob.pbData);
if (entropyBlob.pbData != IntPtr.Zero)
System.Runtime.InteropServices.Marshal.FreeHGlobal(entropyBlob.pbData);
if (plainText.pbData != IntPtr.Zero)
System.Runtime.InteropServices.Marshal.FreeHGlobal(plainText.pbData);
}
}
public static byte[] GetMasterKey(string browserPath)
{
string localStateFile = Path.Combine(browserPath, "Local State");
if (!File.Exists(localStateFile))
return null;
try
{
string content = File.ReadAllText(localStateFile);
int start = content.IndexOf("\"encrypted_key\":\"") + 16;
int end = content.IndexOf("\"", start);
string encryptedKey = content.Substring(start, end - start);
byte[] masterKey = Convert.FromBase64String(encryptedKey);
byte[] rawMasterKey = new byte[masterKey.Length - 5];
Array.Copy(masterKey, 5, rawMasterKey, 0, rawMasterKey.Length);
return DPAPIDecrypt(rawMasterKey);
}
catch (Exception ex)
{
Console.WriteLine($"Master key error: {ex.Message}");
return null;
}
}
public static string DecryptPassword(string loginDataPath, string encryptedPassword)
{
if (string.IsNullOrEmpty(encryptedPassword))
return "";
try
{
if (encryptedPassword.StartsWith("v10") || encryptedPassword.StartsWith("v11"))
{
string browserPath = Directory.GetParent(loginDataPath).Parent.FullName;
byte[] masterKey = GetMasterKey(browserPath);
if (masterKey == null)
return "MASTER_KEY_NOT_FOUND";
// Простая реализация без AES-GCM для упрощения
// В реальном проекте нужно добавить полноценную AES-GCM расшифровку
return "ENCRYPTED_NEW_FORMAT";
}
else
{
byte[] decrypted = DPAPIDecrypt(Encoding.Default.GetBytes(encryptedPassword));
return decrypted != null ? Encoding.UTF8.GetString(decrypted) : "DECRYPTION_FAILED";
}
}
catch (Exception ex)
{
return $"ERROR: {ex.Message}";
}
}
}
public static class SQLiteReader
{
public static List ReadPasswords(string loginDataPath)
{
List passwords = new List();
if (!File.Exists(loginDataPath))
{
Console.WriteLine($"File not found: {loginDataPath}");
return passwords;
}
string tempFile = Path.GetTempFileName();
try
{
// Копируем файл для обхода блокировки
File.Copy(loginDataPath, tempFile, true);
using (var connection = new SQLiteConnection($"Data Source={tempFile};Version=3;"))
{
connection.Open();
using (var command = new SQLiteCommand("SELECT origin_url, username_value, password_value FROM logins", connection))
{
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
string url = reader["origin_url"]?.ToString() ?? "";
string username = reader["username_value"]?.ToString() ?? "";
string encryptedPassword = reader["password_value"]?.ToString() ?? "";
string decryptedPassword = Crypto.DecryptPassword(loginDataPath, encryptedPassword);
passwords.Add(new Password
{
Url = url,
Username = username,
PasswordValue = decryptedPassword
});
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"SQLite error: {ex.Message}");
}
finally
{
if (File.Exists(tempFile))
File.Delete(tempFile);
}
return passwords;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("=== Browser Password Decryptor ===");
Console.WriteLine("Close all browsers before running!");
Console.WriteLine();
string[] browserPaths = new string[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\\Chrome\\User Data\\Default\\Login Data"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\Edge\\User Data\\Default\\Login Data"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Opera Software\\Opera Stable\\Login Data")
};
foreach (string loginDataPath in browserPaths)
{
Console.WriteLine($"\nChecking: {loginDataPath}");
if (File.Exists(loginDataPath))
{
Console.WriteLine("Found! Reading passwords...");
List passwords = SQLiteReader.ReadPasswords(loginDataPath);
Console.WriteLine($"\nFound {passwords.Count} passwords:");
Console.WriteLine("==========================================");
foreach (var pwd in passwords)
{
Console.WriteLine($"URL: {pwd.Url}");
Console.WriteLine($"Username: {pwd.Username}");
Console.WriteLine($"Password: {pwd.PasswordValue}");
Console.WriteLine("------------------------------------------");
}
// Сохраняем в файл
string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "DecryptedPasswords.txt");
SavePasswordsToFile(passwords, savePath);
Console.WriteLine($"\nSaved to: {savePath}");
}
else
{
Console.WriteLine("Not found");
}
}
Console.WriteLine("\nPress any key to exit...");
Console.ReadKey();
}
static void SavePasswordsToFile(List passwords, string filePath)
{
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.WriteLine("URL | Username | Password");
writer.WriteLine("==========================================");
foreach (var pwd in passwords)
{
writer.WriteLine($"{pwd.Url} | {pwd.Username} | {pwd.PasswordValue}");
}
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... -passwords
Ошибка SQLite: невозможно загрузить dll 'e_sqlite3' при расшифровании паролей браузера - C# ⇐ C#
Место общения программистов C#
1758380783
Anonymous
Я написал сценарий C# для расшифровки и сохранения паролей браузеров из браузеров на основе хрома (хром, края и т. Д.), Но я получаю эту ошибку: < /p>
Ошибка SQLite: невозможно загрузить dll 'e_sqlite3' или одну из его зависимости: указанный модуль не может быть найден. (0x8007007e) < /p>
Я установил необходимые пакеты Nuget (System.data.sqlite), но это все еще не работает. Скрипт копирует файлы базы данных браузеров в каталог Temp и пытается прочитать их, но не удается на подключении SQLite. < /P>
My Environment: < /p>
Windows 10 < /p>
Visual Studio 2022 < /p>
ishy.net 8.0 < /p>
< /p>
.using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace PasswordDecryptor
{
public class Password
{
public string Url { get; set; }
public string Username { get; set; }
public string PasswordValue { get; set; }
}
public static class Crypto
{
[System.Runtime.InteropServices.DllImport("crypt32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
private static extern bool CryptUnprotectData(
ref DATA_BLOB pCipherText,
ref string pszDescription,
ref DATA_BLOB pEntropy,
IntPtr pReserved,
ref CRYPTPROTECT_PROMPTSTRUCT pPrompt,
int dwFlags,
ref DATA_BLOB pPlainText);
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
private struct DATA_BLOB
{
public int cbData;
public IntPtr pbData;
}
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
private struct CRYPTPROTECT_PROMPTSTRUCT
{
public int cbSize;
public int dwPromptFlags;
public IntPtr hwndApp;
public string szPrompt;
}
public static byte[] DPAPIDecrypt(byte[] cipherText, byte[] entropy = null)
{
DATA_BLOB plainText = new DATA_BLOB();
DATA_BLOB cipherBlob = new DATA_BLOB();
DATA_BLOB entropyBlob = new DATA_BLOB();
CRYPTPROTECT_PROMPTSTRUCT prompt = new CRYPTPROTECT_PROMPTSTRUCT()
{
cbSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(CRYPTPROTECT_PROMPTSTRUCT)),
dwPromptFlags = 0,
hwndApp = IntPtr.Zero,
szPrompt = null
};
string description = string.Empty;
try
{
cipherBlob.pbData = System.Runtime.InteropServices.Marshal.AllocHGlobal(cipherText.Length);
cipherBlob.cbData = cipherText.Length;
System.Runtime.InteropServices.Marshal.Copy(cipherText, 0, cipherBlob.pbData, cipherText.Length);
if (entropy != null)
{
entropyBlob.pbData = System.Runtime.InteropServices.Marshal.AllocHGlobal(entropy.Length);
entropyBlob.cbData = entropy.Length;
System.Runtime.InteropServices.Marshal.Copy(entropy, 0, entropyBlob.pbData, entropy.Length);
}
CryptUnprotectData(ref cipherBlob, ref description, ref entropyBlob, IntPtr.Zero, ref prompt, 1, ref plainText);
byte[] result = new byte[plainText.cbData];
System.Runtime.InteropServices.Marshal.Copy(plainText.pbData, result, 0, plainText.cbData);
return result;
}
catch (Exception ex)
{
Console.WriteLine($"DPAPI Decrypt error: {ex.Message}");
return null;
}
finally
{
if (cipherBlob.pbData != IntPtr.Zero)
System.Runtime.InteropServices.Marshal.FreeHGlobal(cipherBlob.pbData);
if (entropyBlob.pbData != IntPtr.Zero)
System.Runtime.InteropServices.Marshal.FreeHGlobal(entropyBlob.pbData);
if (plainText.pbData != IntPtr.Zero)
System.Runtime.InteropServices.Marshal.FreeHGlobal(plainText.pbData);
}
}
public static byte[] GetMasterKey(string browserPath)
{
string localStateFile = Path.Combine(browserPath, "Local State");
if (!File.Exists(localStateFile))
return null;
try
{
string content = File.ReadAllText(localStateFile);
int start = content.IndexOf("\"encrypted_key\":\"") + 16;
int end = content.IndexOf("\"", start);
string encryptedKey = content.Substring(start, end - start);
byte[] masterKey = Convert.FromBase64String(encryptedKey);
byte[] rawMasterKey = new byte[masterKey.Length - 5];
Array.Copy(masterKey, 5, rawMasterKey, 0, rawMasterKey.Length);
return DPAPIDecrypt(rawMasterKey);
}
catch (Exception ex)
{
Console.WriteLine($"Master key error: {ex.Message}");
return null;
}
}
public static string DecryptPassword(string loginDataPath, string encryptedPassword)
{
if (string.IsNullOrEmpty(encryptedPassword))
return "";
try
{
if (encryptedPassword.StartsWith("v10") || encryptedPassword.StartsWith("v11"))
{
string browserPath = Directory.GetParent(loginDataPath).Parent.FullName;
byte[] masterKey = GetMasterKey(browserPath);
if (masterKey == null)
return "MASTER_KEY_NOT_FOUND";
// Простая реализация без AES-GCM для упрощения
// В реальном проекте нужно добавить полноценную AES-GCM расшифровку
return "ENCRYPTED_NEW_FORMAT";
}
else
{
byte[] decrypted = DPAPIDecrypt(Encoding.Default.GetBytes(encryptedPassword));
return decrypted != null ? Encoding.UTF8.GetString(decrypted) : "DECRYPTION_FAILED";
}
}
catch (Exception ex)
{
return $"ERROR: {ex.Message}";
}
}
}
public static class SQLiteReader
{
public static List ReadPasswords(string loginDataPath)
{
List passwords = new List();
if (!File.Exists(loginDataPath))
{
Console.WriteLine($"File not found: {loginDataPath}");
return passwords;
}
string tempFile = Path.GetTempFileName();
try
{
// Копируем файл для обхода блокировки
File.Copy(loginDataPath, tempFile, true);
using (var connection = new SQLiteConnection($"Data Source={tempFile};Version=3;"))
{
connection.Open();
using (var command = new SQLiteCommand("SELECT origin_url, username_value, password_value FROM logins", connection))
{
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
string url = reader["origin_url"]?.ToString() ?? "";
string username = reader["username_value"]?.ToString() ?? "";
string encryptedPassword = reader["password_value"]?.ToString() ?? "";
string decryptedPassword = Crypto.DecryptPassword(loginDataPath, encryptedPassword);
passwords.Add(new Password
{
Url = url,
Username = username,
PasswordValue = decryptedPassword
});
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"SQLite error: {ex.Message}");
}
finally
{
if (File.Exists(tempFile))
File.Delete(tempFile);
}
return passwords;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("=== Browser Password Decryptor ===");
Console.WriteLine("Close all browsers before running!");
Console.WriteLine();
string[] browserPaths = new string[]
{
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\\Chrome\\User Data\\Default\\Login Data"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\Edge\\User Data\\Default\\Login Data"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Opera Software\\Opera Stable\\Login Data")
};
foreach (string loginDataPath in browserPaths)
{
Console.WriteLine($"\nChecking: {loginDataPath}");
if (File.Exists(loginDataPath))
{
Console.WriteLine("Found! Reading passwords...");
List passwords = SQLiteReader.ReadPasswords(loginDataPath);
Console.WriteLine($"\nFound {passwords.Count} passwords:");
Console.WriteLine("==========================================");
foreach (var pwd in passwords)
{
Console.WriteLine($"URL: {pwd.Url}");
Console.WriteLine($"Username: {pwd.Username}");
Console.WriteLine($"Password: {pwd.PasswordValue}");
Console.WriteLine("------------------------------------------");
}
// Сохраняем в файл
string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "DecryptedPasswords.txt");
SavePasswordsToFile(passwords, savePath);
Console.WriteLine($"\nSaved to: {savePath}");
}
else
{
Console.WriteLine("Not found");
}
}
Console.WriteLine("\nPress any key to exit...");
Console.ReadKey();
}
static void SavePasswordsToFile(List passwords, string filePath)
{
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.WriteLine("URL | Username | Password");
writer.WriteLine("==========================================");
foreach (var pwd in passwords)
{
writer.WriteLine($"{pwd.Url} | {pwd.Username} | {pwd.PasswordValue}");
}
}
}
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79770376/sqlite-error-unable-to-load-dll-e-sqlite3-when-decrypting-browser-passwords[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия