我正在努力用Python编写线程密码破解程序。当我尝试运行它时,它会显示一个错误。我不知道将所需的位置参数传递给我的crack()函数。
您在这里找到了我到目前为止得到的代码:
#/usr/bin/python3.7
from itertools import product
import threading
from queue import Queue
from string import ascii_letters,digits
print_lock = threading.Lock()
password = "test"
dictionary = ascii_letters + digits
def crack (dictionary,x):
for x in range (1,len(dictionary) + 1):
seq = product(dictionary,repeat=x)
for item in seq:
if (''.join(item) == password):
with print_lock:
print("Password found: ",password)
q = Queue()
def threader ():
while True:
worker = q.get()
crack(worker)
q.task_done()
for x in range (20):
t = threading.Thread(target = threader)
t.daemon = True
t.start()
for worker in range (1,len(dictionary)):
q.put(worker)
q.join()