Wat was nou toch dat wachtwoord weermee je dat zipje had beveiligd. Je kan er niet meer op komen. Dan zal je iets anders moeten verzinnen. Hieronder wat truken waarmee je het wachtwoord allicht toch weer boven water kan halen.

wordlist

Eerst maar eens proberen met een woordenlijst, die je als 2e argument mee kan geven aan dit pythonscriptje.

from tqdm import tqdm

import zipfile
import sys

zip_file = sys.argv[1]
wordlist = sys.argv[2]

zip_file = zipfile.ZipFile(zip_file)

n_words = len(list(open(wordlist, "rb")))
print("Total passwords to test:", n_words)

with open(wordlist, "rb") as wordlist:
    for word in tqdm(wordlist, total=n_words, unit="word"):
        try:
            zip_file.extractall(pwd=word.strip())
        except:
            continue
        else:
            print("[+] Password found:", word.decode().strip())
            exit(0)
print("[!] Password not found, try other wordlist.")

brute force

Als het geen wachtwoord blijkt te zijn uit de woordenlijst, dan wordt het tijd voor zwaarder geschut. We gaan alle denkbare wachtwoorden proberen. We bouwen het wachtwoord op met de letters uit de variabele “Alphabet”. We beginnen met de wachtwoorden van 1 letter, dan 2 tekens, dan 3,4,5 enz. De ronde met wachtwoorden van 1 teken is zo gepiept, en 2 en 3 lukt ook nog wel, maar daarna gaat duurt het al snel langer. Op een gemiddelde pc ben je zo een paar dagen bezig. om alleen de wachtwoorden van 6 tekens te checken.

import itertools
import time

Alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_.")
Password = input("What is your password?\n")
start = time.time()
counter = 0

def buildpwd(Alphabet, pwd, number,Password):
    if (number > 0):
       for c in Alphabet:
          buildpwd(Alphabet, c+pwd, number-1,Password)
    else:
       if (pwd == Password):
           print ("Found your password: it is: ",pwd)
           exit()

for t in range(1,10):
    print (t," karakters proberen")
    buildpwd(Alphabet,"",t,Password)
    timetaken = time.time() - start
    print(timetaken, " time sofar\n")

Alles snelheidswinst is welkom, en dankzij itertools kan het een stuk sneller.

Hij loopt een stuk sneller, alleen zijn er 6 speciale tekent die je niet in je karakterset kan stoppen. Met itertools, wordt razendsnel een tuple van passwords gebouwd. Hij lijkt ongeveer 5 keer sneller dan het bovenstaande scriptje.

import itertools
import time

Alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_.")
Password = input("What is your password?\n")
start = time.time()
counter = 0

for CharLength in range(1,12):
    passwords = (itertools.product(Alphabet, repeat = CharLength))
    print("\n\ncurrently working on passwords with ", CharLength, " chars")
    print("We are currently at ", (counter / (time.time() - start)), "attempts per seconds")
    print("It has been ", time.time() - start, " seconds!")
    print("We have tried ", counter, " possible passwords!")

    for i in passwords:
        counter += 1
        i = str(i)
        for c in "[]' ,()":
           i = i.replace(c, "")

        if i == Password:
            end = time.time()
            timetaken = end - start
            print("Found in ", timetaken, " seconds and ", counter, "attempts")
            print("That is ", counter / timetaken, " attempts per second!")
            print(i)
            input("Press enter when you have finished")
            exit()

Maargoed, wat een gedoe allemaal. Het was een leuke oefening, maar Je kan ook nog met John de ripper aan de slag of met fcrack

fcrackzip -b -c a1:$% -l 1-6 -u myencrypted.zip

Options

  • -b – brute force
  • -c a1:$% – specifies the character sets to use
  • -l 1-6 – specifies the length of passwords to try
  • -u – unzip to weed out wrong passwords

Usage

$ fcrackzip --help

fcrackzip version 1.0, a fast/free zip password cracker
written by Marc Lehmann <pcg@goof.com> You can find more info on
http://www.goof.com/pcg/marc/

USAGE: fcrackzip
          [-b|--brute-force]            use brute force algorithm
          [-D|--dictionary]             use a dictionary
          [-B|--benchmark]              execute a small benchmark
          [-c|--charset characterset]   use characters from charset
          [-h|--help]                   show this message
          [--version]                   show the version of this program
          [-V|--validate]               sanity-check the algortihm
          [-v|--verbose]                be more verbose
          [-p|--init-password string]   use string as initial password/file
          [-l|--length min-max]         check password with length min to max
          [-u|--use-unzip]              use unzip to weed out wrong passwords
          [-m|--method num]             use method number "num" (see below)
          [-2|--modulo r/m]             only calculcate 1/m of the password
          file...                    the zipfiles to crack

methods compiled in (* = default):

 0: cpmask
 1: zip1
*2: zip2, USE_MULT_TAB