简体   繁体   中英

Not all Queue items are printing Python

Hello I have a problem with the queue not printing items in the order its supposed to be in so it doesnt check for all the passwords. Code below

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)}")

So basically the self.q.get() prints everything out of order, and doesnt even get all the words sometimes, how can i fix it? thanks!

Actually I figured it out, I forgot that the multiprocessing was processing different threads and that was the reason why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM