3

Even though the syntax all seems correct I'm still thrown an output error, any reason why it throws this on the output? (please ignore my bad indentation).

import zipfile
myZip = zipfile.ZipFile("/mydile.zip")
count = 0
for x in range(0,1005310):
   password = count
   count += 1
   try:
      myZip.extractall(pwd = password)
      print(password)
except Exception as e:
      print(e)
print "Sorry, password not found."
Robertgold
  • 215
  • 6
  • 19

1 Answers1

5
count = 0

count is an integer.

password = count

password is an integer.

myZip.extractall(pwd = password)

This cannot be right. pwd must have the value of a string. You can convert it to a string using str()

As suggested by Ryan this is exactly what you have to do.

myZip.extractall(pwd = str(password))

You cannot place str() anywhere else because up to this point you are performing arithmetic and you cannot do arithmetic on string without converting.


Bear in mind that this brute-force method will only work if the password is an integer. This is highly improbable so you may also want to include characters. This post might be of some use if you decide to do this.

Wakun
  • 86
  • 1
  • 3
  • 15
Xantium
  • 11,201
  • 10
  • 62
  • 89