In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to crack the password of encrypted zip files", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to crack the password of encrypted zip files.
Before that, I found an encrypted zip compression package in my old computer at home. Because I forgot my password for too long, I vaguely remembered that the password was 6 letters plus numbers. I downloaded a lot of software to crack the password on the Internet without effect, so I thought of writing a script to violently crack the password with Python.
Python has a built-in module zipfile that can do this, test a wave, a test file, and set the decompression password to 123.
Import zipfile # create file handle file = zipfile.ZipFile ("test .zip",'r') # extract the contents of the compressed file, note that the password must be in bytes format, and path indicates which file.extractall to extract (path='.', pwd='123'.encode ('utf-8'))
The running effect is shown in the following figure, and the extraction is successful.
All right, let's start cracking the password of the old file. In order to speed up, I added the original code of multithreading:
Import zipfile import itertools from concurrent.futures import ThreadPoolExecutor def extract (file, password): if not flag: return file.extractall (path='.', pwd=''.join (password). Encode ('utf-8')) def result (f): exception = f.exception () if not exception: # if the exception is not obtained, the print (' password is:' F.pwd) global flag flag = False if _ _ name__ = ='_ _ main__': # create a flag to determine whether the password has been successfully cracked flag = True # create a thread pool pool = ThreadPoolExecutor (100) nums = [str (I) for i in range (10)] chrs = [chr (I) for i in range (65) 91)] # generate numeric + alphanumeric 6-digit passwords password_lst = itertools.permutations (nums + chrs, 6) # create file handle zfile = zipfile.ZipFile ("encrypted file .zip",'r') for pwd in password_lst: if not flag: break f = pool.submit (extract, zfile Pwd) f.pwd = pwd f.pool = pool f.add_done_callback (result)
There is a problem with this code. The memory will burst after running for a while! Reason: ThreadPoolExecutor uses unbounded queues by default, and the speed of trying passwords can't keep up with the speed of production passwords, so production tasks will be infinitely added to the queue. Causes the memory to be full. The memory goes straight to 95:
Then the program crashes:
After looking at the source code, it is found that the internal ThreadPoolExecutor uses unbounded queues, so the memory is directly full. Rewrite the _ work_queue attribute in the ThreadPoolExecutor class to change the unbounded queues to bounded queues, so that the problem of full memory will not occur. See the code:
Import queue from concurrent.futures import ThreadPoolExecutor class BoundedThreadPoolExecutor (ThreadPoolExecutor): def _ init__ (self, max_workers=None, thread_name_prefix=''): super (). _ init__ (max_workers, thread_name_prefix) self._work_queue = queue.Queue (self._max_workers * 2) # set the queue size
Finally, it is successfully cracked, as shown in the following figure.
At this point, I believe you have a deeper understanding of "how to crack the password of encrypted zip files". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.