⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pftw_dec.dpr

📁 解微软的.CAB压缩文件密码的程序
💻 DPR
字号:
{$Apptype console}
{$I-,R-,S-,D-,O-,N-,L-,Y-}

{ -- Hack of SysUtils -- }

uses Windows;

const
  fmOpenRead       = $0000;

function FileOpen(const FileName: string; Mode: Integer): Integer;
const
  AccessMode: array[0..2] of Integer = (
    GENERIC_READ,
    GENERIC_WRITE,
    GENERIC_READ or GENERIC_WRITE);
  ShareMode: array[0..4] of Integer = (
    0,
    0,
    FILE_SHARE_READ,
    FILE_SHARE_WRITE,
    FILE_SHARE_READ or FILE_SHARE_WRITE);
begin
  Result := CreateFile(PChar(FileName), AccessMode[Mode and 3],
    ShareMode[(Mode and $F0) shr 4], nil, OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL, 0);
end;

function FileCreate(const FileName: string): Integer;
begin
  Result := CreateFile(PChar(FileName), GENERIC_READ or GENERIC_WRITE,
    0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
end;

function FileRead(Handle: Integer; var Buffer; Count: Integer): Integer;
begin
  if not ReadFile(Handle, Buffer, Count, Result, nil) then Result := -1;
end;

function FileWrite(Handle: Integer; const Buffer; Count: Integer): Integer;
begin
  if not WriteFile(Handle, Buffer, Count, Result, nil) then Result := -1;
end;

function FileSeek(Handle, Offset, Origin: Integer): Integer;
begin
  Result := SetFilePointer(Handle, Offset, nil, Origin);
end;

procedure FileClose(Handle: Integer);
begin
  CloseHandle(Handle);
end;

{ -- Hack of SysUtils -- }

function IntToHex(const i: integer): string;
const
  HEXdigits: array[0..15]of char = '0123456789ABCDEF';
begin
  SetLength(Result,2);
  Result[2]:= HEXdigits[( i       and $0F)];
  Result[1]:= HEXdigits[((i shr 4)and $0F)];
end;

Type
  TData = array[1..16]of char;
  TCuff = record
            Magic: LongInt;
            Zero1: LongInt;
            FLen : LongInt;
            Zero2: LongInt;
          end;

const
  XMagic : array[0..3]of byte = ($13,$35,$86,$07);
  XChip  : TData = 'MSCF'#0#0#0#0#0#0#0#0#0#0#0#0;

var
  NInp,NOut,
  Buffer   : string;
  FInp,FOut,
  LenX,LenP,
  i,j      : integer;
  bbb      : byte;
  XPassw   : TData;
begin
  Writeln(
    'PFTW password protected .CAB files decryptor v1.50'#13#10+
    '(c) 1999  Alexander Volok  AKA  Warlock'#13#10
  );
  if ParamCount<>2 then begin
    Writeln('Syntax: PFTW_dec.exe Crypted.CAB DeCrypted.CAB');
    Exit;
  end;
  NInp:= ParamStr(1);
  NOut:= ParamStr(2);
  FInp:= FileOpen(NInp,fmOpenRead);
  if FInp<=0 then begin
    Writeln('Error open input');
    Halt(1);
  end;

  LenX:= FileSeek(FInp,0,2);
  FileSeek(FInp,0,0);
  SetLength(Buffer,LenX);
  if FileRead(FInp,Buffer[1],LenX)=LenX then begin
    TCuff(XChip).FLen:= LenX; { fill len field in .CAB header }

    Write(
            'Input  file: ',NInp,
      #13#10'Output file: ',NOut,
      #13#10#13#10'Step One: Trying to determine CRYPT Mask'#13#10+
      #13#10'Length: '
    );
    for i:= 1 to 16 do Write(i:3);
    Write(#13#10'Mask  : ');
    for i:= 1 to 16 do begin
      bbb:= byte(Buffer[i]);
      XPassw[i]:= char((NOT byte(XChip[i]))xor((bbb shr 4)or(bbb shl 4) ));
      write(' ',InttoHex(byte(XPassw[i])));
    end;
    Write(#13#10'String: ');
    for i:= 1 to 16 do Write(char(byte(XPassw[i])xor XMagic[Pred(i)mod 4]):3);
    Writeln;
    Writeln;
    for i:= 2 to 8 do begin
      j:= Pos(Copy(String(XPassw),1,i),Copy(String(XPassw),Succ(i),16));
      if j>0 then begin
        inc(j,i);
        break;
      end;
    end;
    dec(j);
    repeat
      Write('Enter CRYPT Mask length (the period) [estimated: ',j,' ] : ');
      Readln(LenP);
    until(ioresult=0)and(LenP>=1)and(LenP<=16);
    Write(
      #13#10'Step Two: Decrypting file.'#13#10+
      #13#10'Working... '
    );
    j:=1;
    for i:= 1 to LenX do begin
      bbb:= byte(Buffer[i]);
      Buffer[i]:= char(NOT(((bbb shl 4)or(bbb shr 4))xor byte(XPassw[j])));
      inc(j);
      if j>LenP then j:= 1;
    end;
    Write(
      'Done!'#13#10#13#10+
      'By the way: try to use as Installation password : "'
    );
    for i:=1 to LenP do Write(char(byte(XPassw[i])xor XMagic[Pred(i)mod 4]));
    Writeln('"');

    FOut:= FileCreate(NOut);
    FileWrite(FOut,Buffer[1],LenX);
  end;
  FileClose(FInp);
  FileClose(FOut);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -