Passwords!

 BBS: Inland Empire Archive
Date: 12-23-92 (17:51)             Number: 334
From: MATT HART                    Refer#: NONE
  To: JIMMY BENEDETTO               Recvd: NO  
Subj: Passwords!                     Conf: (2) Quik_Bas
 JB> impossible!! The password is under 7 bytes, and uses only the 255
 JB> ASCII codes.  I was thinking of writing a Basic file which would

Here's what I came up with.  Compile with:
     C:\>bc tester;
     C:\>link tester,,,brun45;
       or whatever brun60, brt71enr run-time library you have

It works by trying to un-zip it, then counting the number of files that are
in the directory compared with how many started out - so
unzipped files will increase the number of files in the
directory.  I tried it on a 2 character password protected
file - and it worked perfectly.  Start it with parameters
indicating the search character range:

C:\>tester 65/122
           ^   ^
           ^   Ending ASCII number
           Starting ASCII number

Use it on a RAM drive or with a BIG cache to avoid a real slow run.

' TESTER.BAS  Matt Hart
'$STATIC
DEFINT A-Z

    TYPE RegTypeX
        ax    AS INTEGER
        bx    AS INTEGER
        cx    AS INTEGER
        dx    AS INTEGER
        bp    AS INTEGER
        si    AS INTEGER
        di    AS INTEGER
        flags AS INTEGER
        ds    AS INTEGER
        es    AS INTEGER
    END TYPE
    TYPE DTAType
        A AS STRING * 42
    END TYPE

C$ = COMMAND$
SEl = VAL(C$)
EEl = VAL(MID$(C$,INSTR(C$,"/")+1))

CALL CountFiles("*.*",OrigCount)

FOR i = SEl TO EEl
     Strg$ = CHR$(i)
     GOSUB Sheller
     FOR j = SEl TO EEl
          Strg$ = CHR$(i)+CHR$(j)
          GOSUB Sheller
          FOR k = SEl TO EEl
               Strg$ = CHR$(i)+CHR$(j)+CHR$(k)
               GOSUB Sheller
               FOR l = SEl TO EEl
                    Strg$ = CHR$(i)+CHR$(j)+CHR$(k)+CHR$(l)
                    GOSUB Sheller
                    '... Continue to FOR o = SEl TO EEl...
               NEXT
          NEXT
     NEXT
NEXT
PRINT "Unsuccessful!!"
END
Sheller:
     ShellStrg$ = "PKUNZIP -S"+Strg$+" PASSFILE"
     PRINT "Trying -->";Strg$;"<--"
     SHELL ShellStrg$
     CALL CountFiles("*.*",ThisTry)
     IF ThisTry > OrigCount THEN
          PRINT "Success!  Password is"
          PRINT "-->";Strg$;"<--"
          FOR z = 1 TO LEN(Strg$)
               PRINT ASC(MID$(Strg$,z,1))
          NEXT
          END
     ENDIF
    IF INKEY$ = CHR$(27) THEN PRINT "Halted" : END
RETURN
SUB CountFiles (Srch$,NumFiles)
    DIM DTA as DTAType
    NumFiles=0
    CALL SrchFile (Srch$,File$,DTA,Ecode)
    DO UNTIL Ecode
        NumFiles=NumFiles+1
        CALL SrchNext(File$,DTA,Ecode)
    LOOP
    NumFiles=NumFiles-1
END SUB
SUB SrchFile (Srch$,File$,DTA as DTAType,Ecode)
    DIM InRegs as RegTypeX
    DIM OutRegs as RegTypeX
    DIM F as string * 64
    InRegs.AX = &H1A00
    InRegs.DS = VARSEG(DTA)
    InRegs.DX = VARPTR(DTA)
    CALL InterruptX (&H21, InRegs, OutRegs)
    F = Srch$+CHR$(0)
    InRegs.AX = &H4E00
    InRegs.CX = 0
    InRegs.DS = VARSEG(F)
    InRegs.DX = VARPTR(F)
    CALL InterruptX (&H21, InRegs, OutRegs)
    File$ = MID$( DTA.A,31 )
    File$ = LEFT$(File$, INSTR(File$+CHR$(0),CHR$(0))-1)
    Ecode = OutRegs.AX
END SUB
SUB SrchNext (File$,DTA as DTAType,Ecode)
    DIM InRegs as RegTypeX
    DIM OutRegs as RegTypeX
    DIM F as string * 64
    F = Srch$+CHR$(0)
    InRegs.AX = &H4F00
    CALL InterruptX (&H21, InRegs, OutRegs)
    File$ = MID$( DTA.A, 31 )
    File$ = LEFT$(File$, INSTR(File$+CHR$(0),CHR$(0))-1)
    Ecode = OutRegs.AX
END SUB
---
 * Origin: Midnight Micro!  V.32/REL  (918)451-3306 (1:170/600)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET