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

📄 unit1.pas

📁 ziptv为delphi控件
💻 PAS
字号:
(*
  THIS IS NOT A SUPPORTED COMPONENT!

  *****************************************************************************
  *****************************************************************************
  This component requires the following environment variable

  NOTE: version 4.0 no longer requires the following "Break On Exception"
  settings.  These are still listed here for versions of ZipTV prior 4.0.

  --------
  Delphi 2: "Break On Exception"
  Delphi 3: "Break On Exception"
  Delphi 4: "Stop On Exception" (in menu tools|Debugger options)
  Delphi 5+: Tools (menu)
             Debugger Options... (menu)
             Language Exceptions (Tab)
             Add (button)
             In the "Add Language Exception" enter "E_RAISE" (no qoutes)
             *Make sure the checkbox is checked prior to saving and exiting.

  C++ Builder 3+: "Integrated Debugging" (in menu tools|environment options)
  ---------
  ...be turned OFF when running within the Delphi environment!  This is
  because there are unnormal values forced into the decompression routines
  that understandably raises errors conditions.
  *****************************************************************************
  *****************************************************************************

  TZipKey uses a brute force method to obtain a forgotten password in a zip
  archive.  With the seed key concept used in zip file encryption, the only
  way to obtain the correct password used to encrypt is through brute force.

  If your looking for a quick way to obtain that forgotten password... keep
  looking, it doesn't exist.  Below are statistics on using the TZipKey
  component to obtain that forgotten password.

                                      #  |--------- Possible combinations ------|
  CharSets property   Char set      chars  with 4 char pwrd    with 5 char pwrd
  ------------------------------------------------------------------------------
  csNumeric         | 0..9         | 10  |          10,000  |           100,000 |
  csAlphaUpperCase  | A..Z         | 26  |         456,976  |        11,881,376 |
  csAlphaLowerCase  | a..z         | 26  |         456,976  |        11,881,376 |
  csAlphaULcase     | a..Z         | 52  |       7,311,616  |       380,204,032 |
  csAlphaNumeric    | 0..10, a..Z  | 62  |      14,776,336  |       916,132,832 |
  csAlphaNumericU   | 0..10, A..Z  | 36  |       1,679,616  |        60,466,176 |
  csAlphaNumericL   | 0..10, a..z  | 36  |       1,679,616  |        60,466,176 |
  csFullSet         | 0..255       | 256 |   4,228,250,625  | 1,078,203,909,375 |
  csNonAlphaNumeric |              | 193 |   1,387,488,001  |   267,785,184,193 |
  ----------------- | --------------------------------------------------------- |
  csWordList        | this option is FAST!  It requires that you log your       |
     (v4.0+ only)   | passwords in a WordListFile.                              |
  ------------------------------------------------------------------------------

  A preventive measure built into the zip encryption is that approx 1% of all
  password combinations are returned as the possible password.  With all
  combinations that fall into this percentage range, the associated password
  has to be fed into the decompression routines to verify the resulting crc
  value.  It would be near impossible in terms of required time to retreive
  the password if we weren't able to narrow the forced attempts to 1% of all
  possible combinations.

  As you can see from the above chart, the seed key concept used to encrypt
  passwords in a zip archive is pretty secure.  When encrypting an archive,
  where the password could be forgotten (with minimum security), you would use
  Alpha characters either all upper or all lower case characters.  This would
  require considerably less time to retreive the password. Another idea for a
  quicker find of a forgotten password is to always use passwords with a
  constant length.  If the length is known, the starting password can be
  entered using that length and save possible millions of forced attempts at
  passwords that are several characters less than or greater than the actual
  password.  Any clues you might have such as character types, password length,
  uppercase, lowercase, etc. helps narrow the scope in finding the lost
  password.

  Any password can be obtained using this component, no matter its length.
  The question is... how determined are you in terms of time in obtaining
  it?

  ----------------------------------------------------------------------------
  This component is not a part of the ZipTV component package.  Its intended
  use is to assist in finding forgotten passwords with personal use.  Its use
  in commercial, shareware, for profit, or any distributed or shared software
  is absolutely forbidden.
  ----------------------------------------------------------------------------

  ----------------------------------------------------------------------------
  We reserve the right to remove TZipKey for distribution without prior notice.
  ----------------------------------------------------------------------------

  Version 4.0:
     1. Break on exception IDE setting no longer required.
     2. Property "WordListFile" added to support storage of passwords in a
        list on your local disk for easy and rapid retrieval.  Now you can
        use extra security by using LONG passwords (see above chart), save
        them in a password list file and you don't have to remember the
        password.

        NOTE: this enhances security against this brute force password
        attach, because the longer the password, the longer it takes to
        retrieve the password.  It's common practice to use short abbreviated
        passwords because we have to remember them.

        The file defined in WordListFile is a local file that is not
        distributed with your archives.  They are for personal use only.

*)
Unit Unit1;

Interface

Uses
   Windows,
   Messages,
   SysUtils,
   Classes,
   Graphics,
   Controls,
   Forms,
   Dialogs,
   StdCtrls,
   ExtCtrls,
   Buttons,
   ztvBase,
   ztvGbls,
   ztvHeaders,
   ztvZipKey,
   ztvRegister,
   ztvUnZip;

Type
   TForm1 = Class(TForm)
      ZipKey1: TZipKey;
      Label1: TLabel;
      Label2: TLabel;
      Label3: TLabel;
      Label4: TLabel;
      Label5: TLabel;
      Label6: TLabel;
      lblPassword: TLabel;
      CurFilename: TLabel;
      lbPasswordHits: TLabel;
      lbForcedHits: TLabel;
      lbPasswordLen: TLabel;
      Button1: TButton;
      Button2: TButton;
      Button3: TButton;
      FileSpec: TEdit;
      ArchiveFile: TEdit;
      StartPassword: TEdit;
      Panel1: TPanel;
      Panel2: TPanel;
      Panel3: TPanel;
      bbDir: TBitBtn;
      OpenDialog1: TOpenDialog;
      RadioGroup1: TRadioGroup;
      ListBox1: TListBox;
      Memo1: TMemo;

      Procedure FormCreate(Sender: TObject);
      Procedure bbDirClick(Sender: TObject);
      Procedure Button1Click(Sender: TObject);
      Procedure Button2Click(Sender: TObject);
      Procedure ZipKey1Change(Sender: TObject; Password: String; PasswordHits,
         ForcedHits: Integer);
      Procedure ZipKey1Found(Sender: TObject; FileName, Password: String);
      Procedure ZipKey1Begin(Sender: TObject; FN: String; RecNum: Integer;
         Var Extract: Boolean);
      Procedure ZipKey1Error(Sender: TObject; FN, MsgEx, VolumeID: String; ECode:
         Integer);
      Procedure ZipKey1ElapsedTime(Sender: TObject; ElapsedTime: Single);
      Procedure Button3Click(Sender: TObject);
   Private
      { Private declarations }
   Public
      { Public declarations }
   End;

Var
   Form1: TForm1;

Implementation

{$R *.DFM}

Var
   DisplayStats: Boolean;

   //-------------------------------------------------------------

Procedure TForm1.FormCreate(Sender: TObject);
Begin
   ArchiveFile.Text := ZipKey1.ArchiveFile;
   RadioGroup1.ItemIndex := Ord(csAlphaULcase);
   StartPassword.Text := ZipKey1.StartPassword;

   If ZipKey1.FileSpec.Count > 0 Then
      FileSpec.Text := ZipKey1.FileSpec[0];
   DisplayStats := True;                (* local global *)
End;
//-------------------------------------------------------------
(* Go button - assign ZipKey1 properties and activate the search *)

Procedure TForm1.Button1Click(Sender: TObject);
Begin
   ZipKey1.ArchiveFile := ArchiveFile.Text;
   If ZipKey1.IsArcValid(ZipKey1.ArcType) Then
   Begin
      ListBox1.Items.Clear;
      ZipKey1.FileSpec.Clear;
      If FileSpec.Text <> '' Then
         ZipKey1.FileSpec.Add(FileSpec.Text);

      If Ord(High(TCharSets)) < RadioGroup1.ItemIndex Then
      Begin
         ShowMessage('Unregistered vesion... does not support: '#13#13 + '"' +
            RadioGroup1.Items[RadioGroup1.ItemIndex] + '"');
         Exit;
      End;

      ZipKey1.CharSets := TCharSets(RadioGroup1.ItemIndex);
      ZipKey1.StartPassword := StartPassword.Text;
      //===============
      ZipKey1.Activate();
      //===============
      StartPassword.SetFocus;
   End
   Else
   Begin
      ShowMessage('Invalid or unsupported archive.');
      ArchiveFile.SetFocus;
   End;
End;
//-------------------------------------------------------------

Procedure TForm1.Button2Click(Sender: TObject);
Begin
   ZipKey1.Pause := True;
End;
//-------------------------------------------------------------
(* Set the ZipKey1.ArchiveFile property *)

Procedure TForm1.bbDirClick(Sender: TObject);
Begin
   OpenDialog1.Options := [ofFileMustExist, ofHideReadOnly];
   If OpenDialog1.Execute Then
   Begin
      ZipKey1.ArchiveFile := OpenDialog1.FileName;

      If (ZipKey1.ArcType In [atZip, atZipExe]) Then
         ArchiveFile.Text := ZipKey1.ArchiveFile
      Else
      Begin
         ShowMessage('Unsupported archive type');
         ArchiveFile.Text := '';
      End;
   End;
End;
//-------------------------------------------------------------
(* OnChange event - activates when TZipKey changes passwords *)

Procedure TForm1.ZipKey1Change(Sender: TObject; Password: String;
   PasswordHits, ForcedHits: Integer);
Begin
   If DisplayStats Then
   Begin
      StartPassword.Text := Password;
      lbPasswordHits.Caption := IntToStr(PasswordHits);
      lbForcedHits.Caption := IntToStr(ForcedHits);
      lbPasswordLen.Caption := IntToStr(Length(Password));
   End;
End;
//-------------------------------------------------------------
(* OnFound event - activated when TZipKey finds a matching password *)

Procedure TForm1.ZipKey1Found(Sender: TObject; FileName, Password: String);
Begin
   ListBox1.Items.Add(FileName + ' = ' + Password);
   StartPassword.Text := Password;
End;
//-------------------------------------------------------------

Procedure TForm1.ZipKey1Begin(Sender: TObject; FN: String; RecNum: Integer;
   Var Extract: Boolean);
Begin
   CurFilename.Caption := ExtractFilename(FN);
End;
//-------------------------------------------------------------
(* OnError event - don't use a dialog to display error messages in this event!
 The brute force method of obtaining a forgotten password causes many internal
  execeptions, routing them through here.  These exceptions are necessary to
  achieve this components objective.

  It would be best to use this event only for debugging purposes.
  *)

Procedure TForm1.ZipKey1Error(Sender: TObject; FN, MsgEx, VolumeID: String;
   ECode: Integer);
Begin
   ;
End;
//-------------------------------------------------------------
(* OnElapsedTime event *)

Procedure TForm1.ZipKey1ElapsedTime(Sender: TObject; ElapsedTime: Single);
Var
   s: ShortString;
Begin
	// show the elapsed time
   s := Format('Seconds: %g', [ElapsedTime]);
   ShowMessage(s + #13#13'OnElapsedTime event');
End;
//-------------------------------------------------------------
(* Display Off/On *)

Procedure TForm1.Button3Click(Sender: TObject);
Begin
   DisplayStats := DisplayStats Xor True;
   If DisplayStats Then
      Button3.Caption := 'Display Off'
   Else
      Button3.Caption := 'Display On';
End;
//-------------------------------------------------------------

End.

⌨️ 快捷键说明

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