Yesterday turned the hard drive, found a good thing, but I added the password I do not remember. Tried a few commonly used not to try out, so wrote a little foot originally for me to try. Oh, and really to solve it out.
The Python script reads as follows, running its own encrypted compressed package is good
Copy Code code as follows:
#-*-Coding:utf-8-*-
Import Sys,os
def iselementuniq (list):
"""
To determine if an element in the list is unique
"""
For word in list:
If List.count (word) >1:
Return False
Return True
Def genpswlist ():
"""
Asks the user to enter the word, and according to the word combination password, tries only four words to combine, and limits the password length is 20. It's a bit lame.
"""
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 using a password to extract the compressed package
"""
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_psw.py 1.7z '
Sys.exit (1)
Main (sys.argv[1])