Compression packet password Cracking example sharing (similar code cracked) _python

Source: Internet
Author: User
Tags python script

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])

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.