📄 getapass.~pas
字号:
unit GetAPass;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Variants, ComOBJ, StdCtrls, ExtCtrls, ComCtrls, FileCtrl, ActnList, ImgList,
ToolWin;
type
MDBRecord = record
PassCode: string;
FileType: string;
FileTime: string;
end;
TPassForm = class(TForm)
ListView1: TListView;
ImageList1: TImageList;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure GetMDBDir(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure GetAllPass(Sender: TObject);
private
{ Private declarations }
function ExecFile(FName: WideString): MDBRecord;
procedure ExecDirectory(S: string);
public
{ Public declarations }
FileBox1: TFileListBox;
end;
var
PassForm: TPassForm;
implementation
{$R *.DFM}
procedure TPassForm.FormCreate(Sender: TObject);
begin
FileBox1 := TFileListBox.Create(nil);
FileBox1.Visible := false;
FileBox1.Parent := Self;
FileBox1.Mask := '*.MDB';
end;
procedure TPassForm.FormDestroy(Sender: TObject);
begin
FileBox1.Free;
end;
procedure TPassForm.ExecDirectory(S: string);
var
i: integer;
P: MDBRecord;
begin
FileBox1.Directory := S;
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
for i := FileBox1.Count - 1 downto 0 do begin
S := FileBox1.Items[i];
P := ExecFile(S);
if P.PassCode = '' then Continue;
with ListView1.Items.Add do begin
Caption := S;
ImageIndex := 0;
SubItems.Add(P.FileType);
SubItems.Add(P.PassCode);
SubItems.Add(P.FileTime);
end;
ListView1.Items.EndUpdate;
end;
end;
procedure TPassForm.GetMDBDir(Sender: TObject);
var
S: string;
begin
if not SelectDirectory('选择数据库目录', '', S) then Exit;
Edit1.Text := S;
ExecDirectory(S);
end;
procedure TPassForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key <> #13 then Exit;
if Trim(Edit1.Text) = '' then Exit;
ExecDirectory(Edit1.Text);
end;
function TPassForm.ExecFile(FName: WideString): MDBRecord;
const
model = 'yyyy-mm-dd hh:nn:ss';
const
//2079-06-05前 [EC37 9CFA 28E6 8A60 7B36 DFB1 1343 B133 795B 7C2A ]
//2079-06-05后 [ED37 9DFA 29E6 8B60 7A36 DEB1 1243 B033 785B 7D2A ]
{ 固定密钥 }
InhereCode: array[0..9] of Word =($37EC, $FA9C, $E628, $608A, $367B, $B1DF, $4313, $33B1, $5B79, $2A7C);
{ 活动密钥 }
//89年9月17日前
UserCode8: array[0..9] of Word =($8B86, $345D, $2EC6, $C613, $E454, $02F5, $8477, $DFCF, $1134, $C592);
//89年9月17日后
UserCode: array[0..9] of Word =($7B86, $C45D, $DEC6, $3613, $1454, $F2F5, $7477, $2FCF, $E134, $3592);
//Access 97 固定密钥
InCode97: array[0..19] of byte =($86, $FB, $EC, $37, $5D, $44, $9C, $FA, $C6, $5E,$28, $E6, $13, $00, $00, $00, $00, $00, $00, $00);
var
DateStr: DWord;
PassCode: WideString;
EncodeArray: array[0..19] of Word;
ReaderArray: array[0..19] of Word;
var
Stream: TFileStream;
i, n: integer;
WTime: TDateTime;
WSec: DWord;
M, S: WideString;
Buf: array[0..200] of byte;
Date0: TDateTime;
Date1: TDateTime;
Date2: TDateTime;
const
XorStr = $823E6C94;
begin
Stream := TFileStream.Create(FName, fmOpenReadWrite);
Stream.Seek($00, 00); Stream.Read(Buf[0], 200);
if Buf[$14] = 0 then
begin //Access97
PassCode := '';
Stream.Seek($42, 00); Stream.Read(Buf[0], 20);
for i := 0 to 19 do PassCode := PassCode + chr(Buf[i] xor InCode97[i]);
Result.PassCode := PassCode;
Result.FileType := 'Access97';
Result.FileTime :=FormatDateTime(model,Now);
Exit;
end
else
begin //Access2000
Date0 := EncodeDate(1978, 7, 01);
Date1 := EncodeDate(1989, 9, 17);
Date2 := EncodeDate(2079, 6, 05);
Stream.Seek($42, 00); Stream.Read(ReaderArray[0], 40);
Stream.Seek($75, 00); Stream.Read(DateStr, 4);
Stream.Free;
for i := $42 to $42 + 55 do
begin
if i = $72 then M := '-' else M := '';
S := S + #32 + M + IntToHex(Buf[i], 2);
end;
Delete(S, 1, 1);
if (DateStr >= $90000000) and (DateStr < $B0000000) then
begin
WSec := DateStr xor $903E6C94;
WTime := Date2 + WSec / 8192 * 2;
end
else
begin
WSec := DateStr xor $803E6C94;
WTime := Date1 + WSec / 8192;
if WSec and $30000000 <> 0 then
begin
WSec := $40000000 - WSec;
WTime := Date1 - WSec / 8192 / 2;
end;
end;
if WTime < Date1 then
begin
for i := 0 to 9 do
begin
EncodeArray[i * 2] := (Trunc(WTime) - Trunc(Date0)) xor UserCode[i] xor $F000;
// Xor $F000 就是“高位取反”
EncodeArray[i * 2 + 1] := InhereCode[i];
end;
end;
if (WTime >= Date1) and (WTime < Date2) then
begin
for i := 0 to 9 do
begin
EncodeArray[i * 2] := (Trunc(WTime) - Trunc(Date1)) xor UserCode[i];
EncodeArray[i * 2 + 1] := InhereCode[i];
end;
end;
if WTime >= Date2 then
begin
for i := 0 to 9 do
begin
EncodeArray[i * 2] := (Trunc(WTime) - Trunc(Date1)) xor UserCode[i];
EncodeArray[i * 2 + 1] := InhereCode[i] xor 1;
// Xor 1 就是“末位取反”
end;
end;
PassCode := '';
for i := 0 to 19 do
begin
N := EncodeArray[i] xor ReaderArray[i];
if N <> 0 then PassCode := PassCode + WideChar(N);
end;
Result.FileType := 'Access2000';
Result.PassCode := PassCode;
Result.FileTime :=FormatDateTime(model,WTime);
end;
end;
procedure TPassForm.GetAllPass(Sender: TObject);
begin
if Trim(Edit1.Text) = '' then Exit;
ExecDirectory(Edit1.Text);
end;
procedure ReadMDBInfo(mMDB:WideString;mStringList:TStringList);stdcall;
const
modal = 'yyyy-mm-dd hh:nn:ss';
const
//2079-06-05前 [EC37 9CFA 28E6 8A60 7B36 DFB1 1343 B133 795B 7C2A ]
//2079-06-05后 [ED37 9DFA 29E6 8B60 7A36 DEB1 1243 B033 785B 7D2A ]
{ 固定密钥 }
InhereCode: array[0..9] of Word =($37EC, $FA9C, $E628, $608A, $367B, $B1DF, $4313, $33B1, $5B79, $2A7C);
{ 活动密钥 }
//89年9月17日前
UserCode8: array[0..9] of Word =($8B86, $345D, $2EC6, $C613, $E454, $02F5, $8477, $DFCF, $1134, $C592);
//89年9月17日后
UserCode: array[0..9] of Word =($7B86, $C45D, $DEC6, $3613, $1454, $F2F5, $7477, $2FCF, $E134, $3592);
//Access 97 固定密钥
InCode97: array[0..19] of byte =($86, $FB, $EC, $37, $5D, $44, $9C, $FA, $C6, $5E,$28, $E6, $13, $00, $00, $00, $00, $00, $00, $00);
var
DateStr: DWord;
PassCode: WideString;
EncodeArray: array[0..19] of Word;
ReaderArray: array[0..19] of Word;
const
XorStr = $823E6C94;
var
FStringList:TStringList;
Stream: TFileStream;
i, n: integer;
WTime: TDateTime;
WSec: DWord;
M, S: WideString;
Buf: array[0..200] of byte;
Date0: TDateTime;
Date1: TDateTime;
Date2: TDateTime;
begin
Stream := TFileStream.Create(mMDB,fmOpenRead);
Stream.Seek($00, 00); Stream.Read(Buf[0], 200);
if Buf[$14] = 0 then
begin //Access97
FStringList:=TStringList.Create;
FStringList.Add('Access97');//版本
PassCode := '';
Stream.Seek($42, 00); Stream.Read(Buf[0], 20);
for i := 0 to 19 do PassCode := PassCode + chr(Buf[i] xor InCode97[i]);
FStringList.Add(PassCode);//密码
FStringList.Add(FormatDateTime(modal,Now));//创建日期
mStringList.Text:=FStringList.Text;
FStringList.Free;
end
else
begin //Access2000
FStringList:=TStringList.Create;
FStringList.Add('Access2000');//版本
Date0 := EncodeDate(1978, 7, 01);
Date1 := EncodeDate(1989, 9, 17);
Date2 := EncodeDate(2079, 6, 05);
Stream.Seek($42, 00); Stream.Read(ReaderArray[0], 40);
Stream.Seek($75, 00); Stream.Read(DateStr, 4);
Stream.Free;
for i := $42 to $42 + 55 do
begin
if i = $72 then M := '-' else M := '';
S := S + #32 + M + IntToHex(Buf[i], 2);
end;
Delete(S, 1, 1);
if (DateStr >= $90000000) and (DateStr < $B0000000) then
begin
WSec := DateStr xor $903E6C94;
WTime := Date2 + WSec / 8192 * 2;
end
else
begin
WSec := DateStr xor $803E6C94;
WTime := Date1 + WSec / 8192;
if WSec and $30000000 <> 0 then
begin
WSec := $40000000 - WSec;
WTime := Date1 - WSec / 8192 / 2;
end;
end;
if WTime < Date1 then
begin
for i := 0 to 9 do
begin
EncodeArray[i * 2] := (Trunc(WTime) - Trunc(Date0)) xor UserCode[i] xor $F000;
// Xor $F000 就是“高位取反”
EncodeArray[i * 2 + 1] := InhereCode[i];
end;
end;
if (WTime >= Date1) and (WTime < Date2) then
begin
for i := 0 to 9 do
begin
EncodeArray[i * 2] := (Trunc(WTime) - Trunc(Date1)) xor UserCode[i];
EncodeArray[i * 2 + 1] := InhereCode[i];
end;
end;
if WTime >= Date2 then
begin
for i := 0 to 9 do
begin
EncodeArray[i * 2] := (Trunc(WTime) - Trunc(Date1)) xor UserCode[i];
EncodeArray[i * 2 + 1] := InhereCode[i] xor 1;
// Xor 1 就是“末位取反”
end;
end;
PassCode := '';
for i := 0 to 19 do
begin
N := EncodeArray[i] xor ReaderArray[i];
if N <> 0 then PassCode := PassCode + WideChar(N);
end;
FStringList.Add(PassCode);//密码
FStringList.Add(FormatDateTime(modal,WTime));//创建日期
mStringList.Text:=FStringList.Text;
FStringList.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -