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


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根据经纬度计算距离示例
Feb 16 Python
Python实现识别手写数字 简易图片存储管理系统
Jan 29 Python
python通过伪装头部数据抵抗反爬虫的实例
May 07 Python
tensorflow 用矩阵运算替换for循环 用tf.tile而不写for的方法
Jul 27 Python
Python使用paramiko操作linux的方法讲解
Feb 25 Python
Python企业编码生成系统总体系统设计概述
Jul 26 Python
python多线程案例之多任务copy文件完整实例
Oct 29 Python
Python流程控制常用工具详解
Feb 24 Python
python实现udp聊天窗口
Mar 31 Python
pycharm 2018 激活码及破解补丁激活方式
Sep 21 Python
Python中过滤字符串列表的方法
Dec 22 Python
golang中的空接口使用详解
Mar 30 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实现aes加密类分享
2014/02/16 PHP
PHP水印类,支持添加图片、文字、填充颜色区域的实现
2017/02/04 PHP
深入理解Yii2.0乐观锁与悲观锁的原理与使用
2017/07/26 PHP
PHP中TP5 上传文件的实例详解
2017/07/31 PHP
PHPMailer使用QQ邮箱实现邮件发送功能
2017/08/18 PHP
thinkPHP5分页功能实现方法分析
2017/10/25 PHP
PHP多维数组排序array详解
2017/11/21 PHP
js本身的局限性 别让javascript做太多事
2010/03/23 Javascript
JS常用字符串处理方法应用总结
2014/05/22 Javascript
javascript中attachEvent用法实例分析
2015/05/14 Javascript
JavaScript中三种异步上传文件方式
2016/03/06 Javascript
全屏js头像上传插件源码高清版
2016/03/29 Javascript
JavaScript中关于iframe滚动条的去除和保留
2016/11/17 Javascript
js实现横向拖拽导航条功能
2017/02/17 Javascript
微信小程序 PHP生成带参数二维码
2017/02/21 Javascript
探究react-native 源码的图片缓存问题
2017/08/24 Javascript
node.js学习之断言assert的使用示例
2017/09/28 Javascript
JavaScript使用localStorage存储数据
2019/09/25 Javascript
Postman环境变量全局变量使用方法详解
2020/08/13 Javascript
使用python检测主机存活端口及检查存活主机
2015/10/12 Python
Python中的字符串类型基本知识学习教程
2016/02/04 Python
Python中装饰器兼容加括号和不加括号的写法详解
2017/07/05 Python
如何在python中使用selenium的示例
2017/12/26 Python
基于DataFrame改变列类型的方法
2018/07/25 Python
python批量修改图片尺寸,并保存指定路径的实现方法
2019/07/04 Python
使用CSS3的appearance属性改变元素的外观的方法
2015/12/12 HTML / CSS
什么是虚拟内存?虚拟内存有什么优势?
2016/02/09 面试题
医学生自荐信
2013/12/03 职场文书
优秀高中生事迹材料
2014/02/11 职场文书
党的群众路线教育学习材料
2014/05/12 职场文书
传承焦裕禄精神思想汇报2014
2014/09/10 职场文书
2014乡镇党政班子四风问题思想汇报
2014/09/14 职场文书
音乐教育专业自荐信
2014/09/18 职场文书
敲诈同学钱财检讨书范文
2014/11/18 职场文书
水电工程师岗位职责
2015/02/13 职场文书
PHP连接MSSQL数据库案例,PHPWAMP多个PHP版本连接SQL Server数据库
2021/04/16 PHP