并非所有队列项都在打印Python
您好,我有一个问题,队列没有按其应该的顺序打印项目,因此它没有检查所有密码。代码如下并非所有队列项都在打印Python,python,python-3.x,Python,Python 3.x,您好,我有一个问题,队列没有按其应该的顺序打印项目,因此它没有检查所有密码。代码如下 Class ZipFile: def __init__(self): self.zip_file = self.return_zip_file() # just grabbing the zip file here self.password_word_list = self.password_file() # grabbing the password fi
Class ZipFile:
def __init__(self):
self.zip_file = self.return_zip_file() # just grabbing the zip file here
self.password_word_list = self.password_file() # grabbing the password file
self.q = queue.Queue(maxsize=50) # making the queue here
def word_list(self):
with open(self.password_word_list, "r") as f:
data = f.readlines()
for password in data:
password = password.strip()
yield password
def extract_zip_file(self, zip_file, password):
try:
zip_file.extractall(pwd=password.encode()) # extracting zip
print(f"[+] Password -> {password}")
except Exception as e:
print(e) # for debugging
pass
def brute_force_zip(self)
get_word_list = self.word_list()
count = 0
get_zip_file = zipfile.ZipFile(self.zip_file)
for password in get_word_list:
self.q.put(password)
if self.qsize() == 50:
while not self.q.empty():
thread = Process(target=self.extract_zip_file, args=(get_zip_file, self.q.get()), daemon=True)
thread.start()
count += 1
print(f"\rAttempts: {str(count)}")
因此,基本上self.q.get()会按顺序打印所有内容,有时甚至无法获取所有单词,我如何修复它?谢谢 事实上我已经弄明白了,我忘记了多重处理是在处理不同的线程,这就是原因所在