I need help with PureZip
Posted: Sun Sep 06, 2009 3:16 am
				
				Hi  
I have made this:
The scope of the code is recover a password from a zipped file with a brute force attack. Why this code doesn't work?    
 
Thanks
			
I have made this:
Code: Select all
#MAXLEN = 10
Global chars.s
Global cptr.l
Global clen.i
Global counter.l
Procedure.b zipCeck(bzpath.s, bzpass.s) 
    counter + 1
    
    Debug "Counter " + Str(counter)    
 
      If (PureZIP_Archive_Read(bzpath))
        PureZIP_SetArchivePassword(bzpass) 
        If (PureZIP_ExtractFiles(bzpath, "*.*", "D:\Programmazione\PureBasic\Brutus\Temp", #False) <> #Null) 
            Debug "Ceck the file with the password " + bzpass
            PureZIP_Archive_Close() 
            ProcedureReturn 1
        EndIf
        PureZIP_Archive_Close() 
      EndIf
EndProcedure
                              
Procedure.s crack(w.i, position.i, p.s, characters.l)  
    Protected c.i
    Protected char.s 
    Protected cpass.s
    Protected cr.s
    
    For c = 0 To clen
        cr = ""
        char = PeekS(@chars+c,1)
        cpass = p + char
        If (position < w)
            cr = crack(w,position + 1, cpass,characters)
            If (cr <> "")
                Debug "password trovata!"
                ProcedureReturn cr  
            EndIf
        EndIf
       If (zipCeck("D:\Programmazione\PureBasic\Brutus\test.zip", cpass)=1)
            Debug cpass
            Debug "password found!"
            ProcedureReturn cpass
       EndIf
    Next c  
EndProcedure
Procedure main()
  Protected w.i
  Protected p.s
    
  chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 
  clen = Len(chars)-1
  While ((p = "") And (w < #MAXLEN))
        p = crack(w,0,"",@chars)
        w + 1
  Wend  
EndProcedure
main()
 
 Thanks
