C# 使用C检索Access.mdb数据库密码#
构建读取access数据库文件的c#应用程序。 每个数据库上都有不同的密码。目前我正在使用Access Passview(免费软件)读取密码,但我希望能够自动读取密码,以便将其分配给OLEDB连接字符串的字符串。 (执行时exe的屏幕截图) exe可以从命令行运行,这是我在应用程序中尝试实现的C# 使用C检索Access.mdb数据库密码#,c#,ms-access,C#,Ms Access,构建读取access数据库文件的c#应用程序。 每个数据库上都有不同的密码。目前我正在使用Access Passview(免费软件)读取密码,但我希望能够自动读取密码,以便将其分配给OLEDB连接字符串的字符串。 (执行时exe的屏幕截图) exe可以从命令行运行,这是我在应用程序中尝试实现的 var proc = new Process { StartInfo = new ProcessStartInfo { FileN
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "accesspv.exe",
Arguments = _filePath,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true,
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
string line = proc.StandardOutput.ReadToEnd();
Console.WriteLine(line);
_password2016 = line;
}
这对我不起作用,因为access passview exe正常运行,并且密码不显示在控制台中
我的主要问题是
1.是否可以读取密码并将其分配给连接字符串的变量?
2.让accesspv.exe在后台运行,以便最终用户看不到它
谢谢。网站上提供了该util的源代码。您可以用C#编写相同的代码
如果它是开源的,你可以制作一个控制台版本。。。。否则你需要从屏幕上删除密码,因为不,它不会拾取单词,因为它没有写入标准输出..对不起,我的错误,它只是免费软件,不是开源的未来读者注意:正如原始VB6源代码中所述,“它只适用于Access 95或97[数据库文件]。”谢谢Matt,这是一个巨大的帮助!
public class Program
{
private static readonly byte[] XorBytes = {
0x86, 0xFB, 0xEC, 0x37, 0x5D, 0x44, 0x9C, 0xFA, 0xC6,
0x5E, 0x28, 0xE6, 0x13, 0xB6, 0x8A, 0x60, 0x54, 0x94
};
public static void Main(string[] args)
{
var filePath = args[0];
var fileBytes = new byte[256];
using (var fileReader = File.OpenRead(filePath))
{
fileReader.Read(fileBytes, 0, fileBytes.Length);
}
var passwordBytes = XorBytes
.Select((x, i) => (byte) (fileBytes[i + 0x42] ^ x))
.TakeWhile(x => x != 0);
var password = Encoding.ASCII.GetString(passwordBytes.ToArray());
Console.WriteLine($"Password is \"{password}\"");
Console.ReadKey();
}
}