支持Access97和Access2000密码的查看和破解!由于密码加密部分在文件头,所以不需要读取所有的文件即可快速计算出文件密码
关键字节:
Access2000 [0xbe, 0xec, 0x65, 0x9c, 0xfe,0x28, 0x2b, 0x8a, 0x6c, 0x7b,0xcd, 0xdf, 0x4f]
Access97 [0x86,0xfb,0xec,0x37,0x5d,0x44,0x9c,0xfa,0xc6,0x5e,0x28,0xe6,0x13]
快速读取Access MDB数据库加密的密码,不管你几个G的数据库,理论上也是秒读
/// <summary>
/// 获取Access数据库的密码
/// </summary>
/// <param name="file">文件路径</param>
/// <returns></returns>
public static string GetMdbPassword(string file)
{
// 未加密的文件0x42开始至0x61之前的每间隔一字节的数值
byte[] baseByte =
{
0xbe, 0xec, 0x65, 0x9c, 0xfe, 0x28, 0x2b, 0x8a, 0x6c, 0x7b, 0xcd, 0xdf, 0x4f, 0x13, 0xf7, 0xb1,
};
// 标志 0x62 处的数值
const byte flagByte = 0x0c;
var password = "";
try
{
using (var fs = File.OpenRead(file))
{
fs.Seek(0x14, SeekOrigin.Begin);
// 取得版本, 1为Access2000, 0为Access97
var ver = (byte)fs.ReadByte();
fs.Seek(0x42, SeekOrigin.Begin);
var bs = new byte[33];
if (fs.Read(bs, 0, 33) != 33) return "";
var flag = (byte)(bs[32] ^ flagByte);
for (int i = 0; i < 16; i++)
{
var b = (byte)(baseByte[i] ^ bs[i * 2]);
if (i % 2 == 0 && ver == 1) b ^= flag; //Access 2000
if (b <= 0) continue;
var ch = (char)b;
password += ch;
}
}
}
catch
{
}
return password;
}