Example of compressed package password cracking (similar to code cracking)

Source: Internet
Author: User
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])

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.