Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zipfile Method doesn't works

I create a zip file with rockyou password and I tried to extractall files. But I got some issues. Doesn't matter how password I put in extractall always I will get:

('Bad password for file', <zipfile.ZipInfo object at 0x7f7928d14dc8>)

Code:

import zipfile

zfile = zipfile.ZipFile("./rockyou.zip")

pss = b"rockyou"

try:
    zfile.extractall(pwd = pss)

except RuntimeError as e:
    print(e)
    zfile.close()

If I pass a string I got another issue:

TypeError: pwd: expected bytes, got <class 'str'>

And I tried too:

pss = str.encode("rockyou")

And:

pss = bytes(str.encode("rockyou"))

And:

pss = bytes("rockyou".encode("UTF-8"))
like image 477
Radagast Avatar asked Sep 11 '26 09:09

Radagast


1 Answers

Well, I found a way to fix that, works for me, may not so beautiful...

  zFile.extractall(pwd = 'PASSWORD'.encode('cp850','replace'))
like image 91
Amarth Gûl Avatar answered Sep 13 '26 21:09

Amarth Gûl