压缩包密码破解示例分享(类似典破解)


Posted in Python onJanuary 17, 2014

昨天翻硬盘,找到一个好东西,可惜自己加了密码自己不记得了。试了几个常用的没试出来,于是写了这么个小脚本来替我尝试。。呵呵,还真给解出来了。
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])
Python 相关文章推荐
最基础的Python的socket编程入门教程
Apr 23 Python
django批量导入xml数据
Oct 16 Python
python matlibplot绘制3D图形
Jul 02 Python
为什么str(float)在Python 3中比Python 2返回更多的数字
Oct 16 Python
使用Python进行目录的对比方法
Nov 01 Python
python 中Arduino串口传输数据到电脑并保存至excel表格
Oct 14 Python
django admin后管定制-显示字段的实例
Mar 11 Python
python numpy实现多次循环读取文件 等间隔过滤数据示例
Mar 14 Python
利用Python制作动态排名图的实现代码
Apr 09 Python
python 提高开发效率的5个小技巧
Oct 19 Python
python爬取微博评论的实例讲解
Jan 15 Python
python中re模块知识点总结
Jan 17 Python
vc6编写python扩展的方法分享
Jan 17 #Python
python的urllib模块显示下载进度示例
Jan 17 #Python
Python中for循环详解
Jan 17 #Python
python在命令行下使用google翻译(带语音)
Jan 16 #Python
python支持断点续传的多线程下载示例
Jan 16 #Python
python获得图片base64编码示例
Jan 16 #Python
python练习程序批量修改文件名
Jan 16 #Python
You might like
PHP4和PHP5性能测试和对比 测试代码与环境
2007/08/17 PHP
修改yii2.0用户登录使用的user表为其它的表实现方法(推荐)
2017/08/01 PHP
yii2.0整合阿里云oss删除单个文件的方法
2017/09/19 PHP
js面向对象编程之如何实现方法重载
2014/07/02 Javascript
jQuery实现的多屏图像图层切换效果实例
2015/05/07 Javascript
js实现跨域的方法实例详解
2015/06/24 Javascript
基于javascript实现tab切换特效
2016/03/29 Javascript
node.js cookie-parser之parser.js
2016/06/06 Javascript
jQuery增加、删除及修改select option的方法
2016/08/19 Javascript
JS实现获取当前URL和来源URL的方法
2016/08/24 Javascript
JavaScript实现瀑布流以及加载效果
2017/02/11 Javascript
NodeJS实现图片上传代码(Express)
2017/06/30 NodeJs
JS Testing Properties 判断属性是否在对象里的方法
2017/10/01 Javascript
layer弹出层自适应高度,垂直水平居中的实现
2019/09/16 Javascript
js正则匹配多个全部数据问题
2019/12/20 Javascript
[01:06:25]Secret vs Liquid 2018国际邀请赛淘汰赛BO3 第一场 8.25
2018/08/29 DOTA
[32:07]完美世界DOTA2联赛PWL S3 LBZS vs Rebirth 第一场 12.16
2020/12/17 DOTA
Python内建模块struct实例详解
2018/02/02 Python
python3操作微信itchat实现发送图片
2018/02/24 Python
对python多线程中互斥锁Threading.Lock的简单应用详解
2019/01/11 Python
python 批量添加的button 使用同一点击事件的方法
2019/07/17 Python
python 将字符串中的数字相加求和的实现
2019/07/18 Python
python代码xml转txt实例
2020/03/10 Python
django使用F方法更新一个对象多个对象字段的实现
2020/03/28 Python
Python基于httpx模块实现发送请求
2020/07/07 Python
css3的@media属性实现页面响应式布局示例代码
2014/02/10 HTML / CSS
哄娃神器4moms商店:美国婴童用品品牌
2019/03/07 全球购物
您的时尚,您的生活方式:DTLR Villa
2019/12/25 全球购物
网络编程中设计并发服务器,使用多进程与多线程,请问有什么区别?
2016/03/27 面试题
体育教育毕业生自荐信
2014/06/29 职场文书
党的群众路线教育实践活动心得体会(企业)
2014/11/03 职场文书
投资合作意向书范本
2015/05/08 职场文书
高考要来啦!用Python爬取历年高考数据并分析
2021/06/03 Python
java固定大小队列的几种实现方式详解
2021/07/15 Java/Android
SQL实现LeetCode(180.连续的数字)
2021/08/04 MySQL
微软Win11什么功能最惊艳? Windows11新功能特性汇总
2021/11/21 数码科技