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


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实现进程间通信简单实例
Jul 23 Python
Python使用django获取用户IP地址的方法
May 11 Python
pandas 读取各种格式文件的方法
Jun 22 Python
python使用循环打印所有三位数水仙花数的实例
Nov 13 Python
pygame游戏之旅 添加键盘按键的方法
Nov 20 Python
pygame游戏之旅 添加游戏界面按键图形
Nov 20 Python
Python Cookie 读取和保存方法
Dec 28 Python
pip安装python库的方法总结
Aug 02 Python
python 中xpath爬虫实例详解
Aug 26 Python
python实现智能语音天气预报
Dec 02 Python
基于Python检测动态物体颜色过程解析
Dec 04 Python
python如何实现不可变字典inmutabledict
Jan 08 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
PHP 图片水印类代码
2012/08/27 PHP
PHP Callable强制指定回调类型的方法
2016/08/30 PHP
Thinkphp结合ajaxFileUpload实现异步图片传输示例
2017/03/13 PHP
PHP聚合式迭代器接口IteratorAggregate用法分析
2017/12/28 PHP
PHP实现的装箱算法示例
2018/06/23 PHP
Laravel统计一段时间间隔的数据方法
2019/10/09 PHP
php中数组最简单的使用方法
2020/12/27 PHP
javascript判断用户浏览器插件安装情况的代码
2011/01/01 Javascript
append和appendTo的区别以及appendChild用法
2013/12/24 Javascript
DEDECMS如何为文章添加HOT NEW标志图片
2015/08/14 Javascript
基于Angularjs+mybatis实现二级评论系统(仿简书)
2017/02/13 Javascript
详解http访问解析流程原理
2017/10/18 Javascript
Bootstrap模态对话框用法简单示例
2018/08/31 Javascript
PHP实现基于Redis的MessageQueue队列封装操作示例
2019/02/02 Javascript
Python实现计算文件夹下.h和.cpp文件的总行数
2015/04/23 Python
在Python下尝试多线程编程
2015/04/28 Python
Python自动生产表情包
2017/03/17 Python
Python实现图片添加文字
2019/11/26 Python
Python 简单计算要求形状面积的实例
2020/01/18 Python
使用Python获取当前工作目录和执行命令的位置
2020/03/09 Python
jupyter notebook中美观显示矩阵实例
2020/04/17 Python
python中判断文件结束符的具体方法
2020/08/04 Python
Python如何创建装饰器时保留函数元信息
2020/08/07 Python
CSS3 圆角效果
2009/07/15 HTML / CSS
美国维生素、补充剂、保健食品购物网站:Vitacost
2016/08/05 全球购物
联想马亚西亚官方网站:Lenovo Malaysia
2018/09/19 全球购物
科颜氏香港官方网店:Kiehl’s香港
2021/03/07 全球购物
企业文明单位申报材料
2014/05/16 职场文书
竞聘演讲稿开场白
2014/08/25 职场文书
庆祝国庆节演讲稿2014
2014/09/19 职场文书
工作表扬信
2015/01/17 职场文书
同学毕业留言寄语
2015/02/27 职场文书
毕业论文指导老师意见
2015/06/04 职场文书
汶川大地震感悟
2015/08/10 职场文书
pycharm代码删除恢复的方法
2021/06/26 Python
Redis中缓存穿透/击穿/雪崩问题和解决方法
2021/12/04 Redis