我工作的一所學校的項目一個簡單的壓縮文件密碼破解,我需要它來顯示密碼一旦破解它從字典中的單詞列表。每當我運行它時,它只會提取文件,並不會打印任何內容。我如何解決這個問題也顯示密碼?這是我的代碼。的Python 3郵編密碼破解
import optparse
import zipfile
from threading import Thread
def extract_zip(zFile, password):
try:
password = bytes(password.encode('utf-8'))
zFile.extractall(pwd=password)
print ("[+] Password Found: " + password + '\n')
except:
pass
def Main():
parser = optparse.OptionParser("useage &prog "+\
"-f <zipfile> -d <dictionary>")
parser.add_option('-f', dest='zname', type='string',\
help='specify zip file')
parser.add_option('-d', dest='dname', type='string',\
help='specify dictionary file')
(options, arg) = parser.parse_args()
if (options.zname == None) | (options.dname == None):
print (parser.usage)
exit(0)
else:
zname = options.zname
dname = options.dname
zFile = zipfile.ZipFile(zname)
passFile = open(dname)
for line in passFile.readlines():
password = line.strip('\n')
t = Thread(target=extract_zip, args=(zFile, password))
t.start()
if __name__ == '__main__':
Main()
你的問題是什麼? –
請閱讀[導覽],然後[問]然後[mcve]。你還沒有問一個問題,所以你需要編輯你的文章。 –
@DaveS我加了問題 – Vixro