📄 freeotfefrmcdbdump.pas
字号:
unit FreeOTFEfrmCDBDump;
// Description:
// By Sarah Dean
// Email: sdean12@sdean12.org
// WWW: http://www.FreeOTFE.org/
//
// -----------------------------------------------------------------------------
//
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Spin, ComCtrls,
PasswordRichEdit, Spin64,
OTFEFreeOTFE_U, Buttons;
type
TfrmFreeOTFECDBDump = class(TForm)
pbOK: TButton;
pbCancel: TButton;
GroupBox1: TGroupBox;
Label1: TLabel;
edVolumeFilename: TEdit;
Label2: TLabel;
lblOffset: TLabel;
se64Offset: TSpinEdit64;
lblOffsetBytes: TLabel;
preUserKey: TPasswordRichEdit;
seSaltLength: TSpinEdit;
lblSaltLengthBits: TLabel;
lblSaltLength: TLabel;
OpenDialog: TOpenDialog;
GroupBox2: TGroupBox;
pbBrowseDumpfile: TButton;
edDumpFilename: TEdit;
Label3: TLabel;
SaveDialog: TSaveDialog;
bbBrowsePartition: TBitBtn;
bbBrowseFile: TBitBtn;
seKeyIterations: TSpinEdit;
lblKeyIterations: TLabel;
lblOptional: TLabel;
ckBaseIVCypherOnHashLength: TCheckBox;
procedure pbBrowseDumpfileClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ControlChanged(Sender: TObject);
procedure pbOKClick(Sender: TObject);
procedure bbBrowseFileClick(Sender: TObject);
procedure bbBrowsePartitionClick(Sender: TObject);
private
fLUKSDump: boolean;
procedure SetLUKSDump(dumpLUKS: boolean);
function GetLUKSBaseIVCypherOnHashLength(): boolean;
function GetVolumeFilename(): string;
function GetUserKey(): string;
function GetOffset(): int64;
function GetSaltLength(): integer;
function GetKeyIterations(): integer;
function GetDumpFilename(): string;
procedure EnableDisableControls();
public
OTFEFreeOTFE: TOTFEFreeOTFE;
// If set to TRUE, dump LUKS volume, otherwise dump FreeOTFE
// Defaults to FreeOTFE (FALSE)
property LUKSDump: boolean read fLUKSDump write SetLUKSDump;
property LUKSBaseIVCypherOnHashLength: boolean read GetLUKSBaseIVCypherOnHashLength;
property VolumeFilename: string read GetVolumeFilename;
property UserKey: string read GetUserKey;
property Offset: int64 read GetOffset;
property SaltLength: integer read GetSaltLength;
property KeyIterations: integer read GetKeyIterations;
property DumpFilename: string read GetDumpFilename;
end;
implementation
{$R *.DFM}
uses
SDUGeneral,
SDUDialogs;
const
CRLF = #10+#13;
procedure TfrmFreeOTFECDBDump.pbBrowseDumpfileClick(Sender: TObject);
begin
SaveDialog.Filter := FILE_FILTER_FLT_TEXTFILES;
SaveDialog.DefaultExt := FILE_FILTER_DFLT_TEXTFILES;
SDUOpenSaveDialogSetup(SaveDialog, edDumpFilename.text);
if SaveDialog.Execute() then
begin
edDumpFilename.text := SaveDialog.Filename;
end;
end;
function TfrmFreeOTFECDBDump.GetVolumeFilename(): string;
begin
Result := edVolumeFilename.text;
end;
function TfrmFreeOTFECDBDump.GetUserKey(): string;
begin
Result := preUserKey.Text;
end;
function TfrmFreeOTFECDBDump.GetOffset(): int64;
begin
Result := se64Offset.Value;
end;
function TfrmFreeOTFECDBDump.GetSaltLength(): integer;
begin
Result := seSaltLength.Value;
end;
function TfrmFreeOTFECDBDump.GetKeyIterations(): integer;
begin
Result := seKeyIterations.Value;
end;
function TfrmFreeOTFECDBDump.GetDumpFilename(): string;
begin
Result := edDumpFilename.text;
end;
procedure TfrmFreeOTFECDBDump.FormCreate(Sender: TObject);
begin
LUKSDump := FALSE;
preUserKey.Plaintext := TRUE;
// FreeOTFE volumes CAN have newlines in the user's password
preUserKey.WantReturns := TRUE;
preUserKey.WordWrap := TRUE;
preUserKey.Lines.Clear();
preUserKey.PasswordChar := '*';
seSaltLength.Increment := 8;
seSaltLength.Value := DEFAULT_SALT_LENGTH;
se64Offset.Value := 0;
seKeyIterations.MinValue := 1;
seKeyIterations.MaxValue := 999999; // Need *some* upper value, otherwise setting MinValue won't work properly
seKeyIterations.Increment := DEFAULT_KEY_ITERATIONS_INCREMENT;
seKeyIterations.Value := DEFAULT_KEY_ITERATIONS;
edVolumeFilename.text := '';
edDumpFilename.text := '';
ckBaseIVCypherOnHashLength.checked := TRUE;
end;
procedure TfrmFreeOTFECDBDump.EnableDisableControls();
begin
pbOK.Enabled := (
(edVolumeFilename.text <> '') AND
(edDumpFilename.text <> '') AND
(KeyIterations > 0)
);
end;
procedure TfrmFreeOTFECDBDump.FormShow(Sender: TObject);
begin
EnableDisableControls();
end;
procedure TfrmFreeOTFECDBDump.ControlChanged(Sender: TObject);
begin
EnableDisableControls()
end;
procedure TfrmFreeOTFECDBDump.pbOKClick(Sender: TObject);
var
{$IFDEF FREEOTFE_TIME_CDB_DUMP}
startTime: TDateTime;
stopTime: TDateTime;
diffTime: TDateTime;
Hour, Min, Sec, MSec: Word;
{$ENDIF}
dumpOK: boolean;
notepadCommandLine: string;
begin
{$IFDEF FREEOTFE_TIME_CDB_DUMP}
startTime := Now();
{$ENDIF}
if LUKSDump then
begin
dumpOK := OTFEFreeOTFE.DumpLUKSDataToFile(
VolumeFilename,
UserKey,
LUKSBaseIVCypherOnHashLength,
DumpFilename
);
end
else
begin
dumpOK := OTFEFreeOTFE.DumpCriticalDataToFile(
VolumeFilename,
Offset,
UserKey,
SaltLength, // In bits
KeyIterations,
DumpFilename
);
end;
if dumpOK then
begin
{$IFDEF FREEOTFE_TIME_CDB_DUMP}
stopTime := Now();
diffTime := (stopTime - startTime);
DecodeTime(diffTime, Hour, Min, Sec, MSec);
showmessage('Time taken to dump CDB: '+inttostr(Hour)+' hours, '+inttostr(Min)+' mins, '+inttostr(Sec)+'.'+inttostr(MSec)+' secs');
{$ENDIF}
if (SDUMessageDlg('A human readable copy of your critical data block has been '+CRLF+
'written to:'+CRLF+
CRLF+
DumpFilename+CRLF+
CRLF+
'Do you wish to open this file in Windows Notepad?',
mtInformation, [mbYes,mbNo], 0) = mrYes) then
begin
notepadCommandLine := 'notepad '+DumpFilename;
if (WinExec(PChar(notepadCommandLine), SW_RESTORE))<31 then
begin
SDUMessageDlg('Error running Notepad', mtError, [], 0);
end;
end;
ModalResult := mrOK;
end
else
begin
{$IFDEF FREEOTFE_TIME_CDB_DUMP}
stopTime := Now();
diffTime := (stopTime - startTime);
DecodeTime(diffTime, Hour, Min, Sec, MSec);
showmessage('Time taken to FAIL to dump CDB: '+inttostr(Hour)+' hours, '+inttostr(Min)+' mins, '+inttostr(Sec)+'.'+inttostr(MSec)+' secs');
{$ENDIF}
SDUMessageDlg('Unable to dump out critical data block.'+CRLF+
CRLF+
'Please ensure that your password and details are entered '+CRLF+
'correctly, and that this file is not currently in use (e.g. mounted)',
mtError, [mbOK], 0);
end;
end;
procedure TfrmFreeOTFECDBDump.bbBrowseFileClick(Sender: TObject);
begin
OpenDialog.Filter := FILE_FILTER_FLT_VOLUMESANDKEYFILES;
OpenDialog.DefaultExt := FILE_FILTER_DFLT_NONE;
SDUOpenSaveDialogSetup(OpenDialog, edVolumeFilename.text);
if OpenDialog.Execute() then
begin
edVolumeFilename.text := OpenDialog.Filename;
edDumpFilename.text := edVolumeFilename.text + '.txt';
end;
end;
procedure TfrmFreeOTFECDBDump.bbBrowsePartitionClick(Sender: TObject);
var
selectedPartition: string;
begin
selectedPartition := OTFEFreeOTFE.SelectPartition();
if (selectedPartition <> '') then
begin
edVolumeFilename.text := selectedPartition;
end;
end;
procedure TfrmFreeOTFECDBDump.SetLUKSDump(dumpLUKS: boolean);
begin
lblOptional.Visible := dumpLUKS;
ckBaseIVCypherOnHashLength.Visible := dumpLUKS;
lblOffset.Enabled := not(dumpLUKS);
se64Offset.Enabled := not(dumpLUKS);
lblOffsetBytes.Enabled := not(dumpLUKS);
lblSaltLength.Enabled := not(dumpLUKS);
seSaltLength.Enabled := not(dumpLUKS);
lblSaltLengthBits.Enabled := not(dumpLUKS);
lblKeyIterations.Enabled := not(dumpLUKS);
seKeyIterations.Enabled := not(dumpLUKS);
if (dumpLUKS) then
begin
self.caption := 'Dump LUKS Details';
se64Offset.value := 0;
seSaltLength.value := 0;
seKeyIterations.value := 0;
end
else
begin
self.caption := 'Dump Critical Data Block';
end;
fLUKSDump := dumpLUKS;
end;
function TfrmFreeOTFECDBDump.GetLUKSBaseIVCypherOnHashLength(): boolean;
begin
Result := ckBaseIVCypherOnHashLength.checked;
end;
END.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -