壓縮包密碼破解樣本分享(類似典破解)

來源:互聯網
上載者:User
昨天翻硬碟,找到一個好東西,可惜自己加了密碼自己不記得了。試了幾個常用的沒試出來,於是寫了這麼個小指令碼來替我嘗試。。呵呵,還真給解出來了。
python指令碼內容如下,跑跑自己加密的壓縮包還不錯

代碼如下:


# -*- coding: utf-8 -*-

import sys,os

def IsElementUniq(list):
"""
判斷list中的元素是否為唯一的
"""
for word in list:
if list.count(word)>1:
return False

return True

def GenPswList():
"""
要求使用者輸入詞,並根據單片語合密碼,只嘗試四個單詞來組合,並限制密碼長度為20。寫的比較挫
"""
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):
"""
嘗試用密碼來解壓壓縮包
"""

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

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.