Microsoft Access '97 password (Views: 28)
Problem/Question/Abstract: Get the MicroSoft Access '97 password. Answer: function GetMDB97PassWord(Filename: string): string; const XorArr: array[0..12] of Byte = ($86, $FB, $EC, $37, $5D, $44, $9C, $FA, $C6, $5E, $28, $E6, $13); var I: Integer; Arr: array[0..12] of Byte; S1: string; FI: file of Byte; By: Byte; Access97: Boolean; FileError: Boolean; begin // Init FileError := False; Access97 := True; // Open file AssignFile(FI, Filename); Reset(FI); // Read file I := 0; repeat if not Eof(FI) then begin Read(FI, By); Inc(I); end; until (I = $42) or Eof(FI); if Eof(FI) then FileError := True; // Read password string for I := 0 to 12 do if not Eof(FI) then Read(FI, Arr[I]); if Eof(FI) then FileError := True; //Close file CloseFile(FI); // Read string in S1 S1 := ''; for I := 0 to 12 do S1 := S1 + Chr(Arr[I]); // Is nul string? if S1 = #0 + #0 + #0 + #0 + #0 + #0 + #0 + #0 + #0 + #0 + #0 + #0 + #0 then Access97 := False; // Decode string S1 := ''; for I := 0 to 12 do S1 := S1 + Chr(Arr[I] xor XORArr[I]); // Find end of string I := 0; repeat Inc(I); until (S1[I] = #0) or (I = 14); if I <= 14 then S1 := Copy(S1, 1, I - 1); // Gather the results if Access97 then begin if Length(S1) > 0 then Result := 'The password is: ' + S1 + '.' else Result := 'The file is NOT password protected.'; end else Result := 'The file is not an Access 97 file / wrong format.'; if FileError then Result := 'File error'; end; |