I forgot the password of a compressed package and wrote a small script to implement the decryption function. after entering the words in my frequently used password, the script combined these passwords to try to decompress the compressed package and flip the hard drive yesterday, find a good thing, but I don't remember it when I add a password. I tried a few common ones and did not try them out, so I wrote such a small script to try it for me .. Oh, I can solve it.
The python script is as follows. running your own encrypted compressed package is not bad.
The code is as follows:
#-*-Coding: UTF-8 -*-
Import sys, OS
Def IsElementUniq (list ):
"""
Checks whether the elements in the list are unique.
"""
For word in list:
If list. count (word)> 1:
Return False
Return True
Def GenPswList ():
"""
The user is required to enter the word and combine the password based on the word. only four words are allowed to be combined and the password length is limited to 20. Poor write performance
"""
Psw = raw_input ('input a word> ')
Wordlist = []
While psw:
Wordlist. append (psw)
Psw = raw_input ('input a word> ')
Print wordlist
Global g_pswlist
G_pswlist = []
For word in wordlist:
G_pswlist.append (word)
For word1 in wordlist:
For word2 in wordlist:
Locallist = [word1, word2]
If IsElementUniq (locallist ):
Tmp = word1 + word2
If len (tmp) <20:
G_pswlist.append (tmp)
For word1 in wordlist:
For word2 in wordlist:
For word3 in wordlist:
Locallist = [word1, word2, word3]
If IsElementUniq (locallist ):
Tmp = word1 + word2 + word3
If len (tmp) <20:
G_pswlist.append (tmp)
For word1 in wordlist:
For word2 in wordlist:
For word3 in wordlist:
For word4 in wordlist:
Locallist = [word1, word2, word3, word4]
If IsElementUniq (locallist ):
Tmp = word1 + word2 + word3 + word4
If len (tmp) <20:
G_pswlist.append (tmp)
Print 'Gen psw is: ', g_pswlist
Def TestUnZipPack (filename ):
"""
Try to decompress the compressed package with the password
"""
Command = ""
For psw in g_pswlist:
Command = "7z e-p % s-y % s" % (psw, filename)
Print command
Ret = OS. system (command)
If ret = 0:
Print 'right psw is ', psw
Break
Def main (filename ):
GenPswList ()
TestUnZipPack (filename)
If _ name _ = '_ main __':
If len (sys. argv )! = 2:
Print 'argv error'
Print 'example: test_7z_ps1_py 1.7z'
Sys. exit (1)
Main (sys. argv [1])