//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
//这里定义的是13个字节作为Access2000异或的源码。与之相对应的加密标志是0x13,特此注明
//当然你可以用这一组: BE EC 65 9C FE 28 2B 8A 6C 7B CD DF 4F 与这一组相对应的加密标志是0x0c
//呵呵.程序有些乱,希望能看的懂。
//---------------------------------------------------------------------------
//Access2000异或的源码
char PassSource2k[13]={0xa1,0xec,0x7a,0x9c,0xe1,0x28,0x34,0x8a,0x73,0x7b,0xd2,0xdf,0x50};
//Access97的异或源码
char PassSource97[13]={0x86,0xfb,0xec,0x37,0x5d,0x44,0x9c,0xfa,0xc6,0x5e,0x28,0xe6,0x13};
void __fastcall TMainForm::GetMdbPass(String MdbFileName)
{
char PassStrTemp[26],Ver,EncrypFlag,t1;
int FileHandle;
String MdbPassword,MdbVersion;
FileHandle=FileOpen(MdbFileName,fmOpenRead);
if(FileHandle<0)
{
Application->MessageBox("\n文件打开错误!\n", "警告", MB_OK );
return;
}
//取得数据库版本
FileSeek(FileHandle,0x14,0);
FileRead(FileHandle,&Ver,1);
//取得加密标志
FileSeek(FileHandle,0x62,0);
FileRead(FileHandle,&EncrypFlag,1);
//读取加密后的密码到缓冲区
FileSeek(FileHandle,0x42,0);
FileRead(FileHandle,&PassStrTemp,26);
FileClose(FileHandle);
if(Ver<1)
{
MdbVersion="Access 97";
if(int(PassStrTemp[0]^PassSource97[0])==0)
MdbPassword="密码为空!";
else
{
MdbPassword="";
for(int j=0;j<13;j++)
MdbPassword=MdbPassword+char(PassStrTemp[j]^PassSource97[j]);
}
}
else
{
MdbVersion="Access 2000 or 2002";
MdbPassword="";
for(int j=0;j<13;j++)
{
if(j%2==0)
t1=char(0x13^EncrypFlag^PassStrTemp[j*2]^PassSource2k[j]);
//每隔一个字节就与加密标志相异或。这里的加密标志为0x13
else
t1=char(PassStrTemp[j*2]^PassSource2k[j]);
MdbPassword=MdbPassword+t1;
}
}
if(MdbPassword[1]<0x20||MdbPassword[1]>0x7e)
MdbPassword="密码为空!";
EditMdbFileName->Text=MdbFileName;
EditMdbPassword->Text=MdbPassword;
EditMdbVersion->Text=MdbVersion;
}
void __fastcall TMainForm::Button1Click(TObject *Sender)
{
GetMdbPass(EditMdbFileName->Text) ;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::muExitClick(TObject *Sender)
{
Close() ;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::BitBtn1Click(TObject *Sender)
{
OpenDialog1->Execute();
EditMdbFileName->Text = OpenDialog1->FileName ;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Button2Click(TObject *Sender)
{
//qqRecForm->ShowModal() ;
}
//---------------------------------------------------------------------------
评论0
最新资源