In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "Python how to crack encryption compression package". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
I. Preparations
Let's open up an encrypted archive and try to decompress it the original way.
and pop it up for me to type in the code.
It doesn't open normally. If you click Skip All Encryption, it won't open either. It closes your current window directly.
What can we do under normal circumstances? Nothing. The next one will be better.
Let's open pycharm and create a py file, which I'll call zip_pwd for now.
Question 3: Is there no pycharm? Not Python either? Still can't install? private self
Before that, we need to collect some information, such as the current password number and type.
Type contains includes whether it has special characters, whether it has strings, and whether it is pure numbers.
Suppose we now know that there are two, and we know that the current password type is an integer, six-digit password.
We first create a pure digital 6-digit password library, you can also go to GitHub to download a password dictionary library containing all characters, this is now open source, cracking time depends on the length of the password set, complex or not.
II. Start operation
back to the topic
Given that our current password is a six-digit pure number, how do you create your own password dictionary?
First we need to complete a file write function
First declare a variable f
f = open()# Python built-in functions
open is an IO stream that can complete file reading and writing functions.
For example, if I want to write something in a file first, I can do it through open.
Then we create a file called possword.txt by opening, and add a write method to write in w mode.
f = open('password.txt','w')
Then create a password by looping, password set to 1000000
for id in range(1000000)
At this point, you need to create a password variable to generate a password, and import a method package before creating it.
import zipfile
Then you can start generating passwords through password. This zfill is equal to 6 digits, plus newlines, because generating a password requires changing one line, and the generated password should be a string type.
password = str(id).zfill(6) + '\n'
Then write password to the file using f.write method
f.write(password)
After writing it in, you have to close the current file stream
f.close()
Then we'll try to generate it and see if it works.
import zipfilef = open('password.txt','w')for id in range(1000000) password = str(id).zfill(6) + '\n' f.write(password)f.close()
You can see here that we have generated a possword.txt password dictionary, which is a password library.
From 000000 to 999999, it's all generated.
This is a simple password dictionary generation method, if you want to generate a more complex password will not be so simple, to show you a complex, here I will not demonstrate, look at it, nearly wrote more than 10,000 lines.
So if you want to generate it yourself, you have to learn it carefully.
Once we have the six-digit password dictionary, we need to complete the function that solves the password for compressed files.
First we declare a function called file and add two line arguments.
The first is my zip file, and the second is the password that needs to be passed in.
def pwd_file(zipfile,password):
Write an exception handler after passing the line parameter, call zipfile, it will have a method extractall pass two values, the first is pwd pass bytes, pass line parameter in bytes, encoding set is utf8
tey: zipfile.extractall(pwd=bytes(password, 'utf8'))
Then print the compressed package password, print password
print ('zip password', password)
Because there are many passwords in the password library, only one is correct, and the others are wrong, so it will definitely report errors, so we have to write an exception handler, write a pass on it, and give it a pass if it is wrong.
except: pass
This is a simple function, we use an extractall method in zipfile to intelligently obtain the correct password, which can automatically match passwords.
And then we're going to write executive functions
First, write a main function.
def main():
In the main function, insert the encrypted compressed file into the code through the zipfile method.
zipFlie = zipfile.ZipFile('./ Get file password. zip')
Generate a list variable through pwd and open the generated password file.
pwd_list = open('./ password.txt')
Then we need to try the password one by one, this is line by line to read.
for line in pwd_list.readlines():
Read one, write it in, get a password, delete a newline.
pwd = line.strip('\n')
Call the previously written function via pwd_file, passing zipFlie and pwd
pwd_file(zipFlie, pwd)
Finally, write the function entry, write a main, why write this function entry? It works without writing.
Because it's for testing.
If __name__is a test entry, what does it mean?
For example, if I import another file library under the current file, but I don't want to use it, I can make it not run through if, so I can write it or not, as an extension.
if __name__ == '__main__': main()
all code
import zipfilef = open('password.txt', 'w')for id in range(1000000): password = str(id).zfill(6) + '\n' f.write(password)f.close()def pwd_file(zipFlie, password): try: zipFlie.extractall(pwd=bytes(password, 'utf8')) print ('zip password', password) except: passdef main(): zipFlie = zipfile.ZipFile('./ Get file password. zip') pwd_list = open('./ password.txt') for line in pwd_list.readlines(): pwd = line.strip('\n') pwd_file(zipFlie, pwd)if __name__ == '__main__': main()
Let's look at the effect. You can see that the password of the compressed package has been printed out.
The more complex the password you're trying to get, the better your computer will be and the faster it'll compute.
"Python how to crack encryption compressed package" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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.