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


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基础教程之面向对象的一些概念
Aug 29 Python
在Django中创建动态视图的教程
Jul 15 Python
详解python发送各类邮件的主要方法
Dec 22 Python
Python实现将一个正整数分解质因数的方法分析
Dec 14 Python
mac系统安装Python3初体验
Jan 02 Python
python删除某个字符
Mar 19 Python
Python实现数据结构线性链表(单链表)算法示例
May 04 Python
python算法与数据结构之冒泡排序实例详解
Jun 22 Python
python 图片去噪的方法示例
Jul 09 Python
Python实现异步IO的示例
Nov 05 Python
Python调用系统命令os.system()和os.popen()的实现
Dec 31 Python
python中的unittest框架实例详解
Feb 05 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
桌面中心(四)数据显示
2006/10/09 PHP
php Http_Template_IT类库进行模板替换
2009/03/19 PHP
php之Memcache学习笔记
2013/06/17 PHP
php jq jquery getJSON跨域提交数据完整版
2013/09/13 PHP
Thinkphp中的volist标签用法简介
2014/06/18 PHP
PHP面向对象精要总结
2014/11/07 PHP
php函数连续调用实例分析
2015/07/30 PHP
php上传大文件失败的原因及应对策略
2015/10/20 PHP
使用jQuery+HttpHandler+xml模拟一个三级联动的例子
2011/08/09 Javascript
JS实现简单的键盘打字的效果
2015/04/24 Javascript
jQuery实现的跨容器无缝拖动效果代码
2016/06/21 Javascript
ES6中参数的默认值语法介绍
2017/05/03 Javascript
浅谈Postman解决token传参的问题
2018/03/31 Javascript
微信小程序项目实践之验证码倒计时功能
2018/07/18 Javascript
JS实现的A*寻路算法详解
2018/12/14 Javascript
在JavaScript中使用严格模式(Strict Mode)
2019/06/13 Javascript
jQuery实现回到顶部效果
2020/10/19 jQuery
vue的hash值原理也是table切换实例代码
2020/12/14 Vue.js
[03:02]辉夜杯主赛事第二日 每日之星
2015/12/27 DOTA
pydev使用wxpython找不到路径的解决方法
2013/02/10 Python
Python实现注册登录系统
2017/08/08 Python
Python之多线程爬虫抓取网页图片的示例代码
2018/01/10 Python
pandas 两列时间相减换算为秒的方法
2018/04/20 Python
将tensorflow的ckpt模型存储为npy的实例
2018/07/09 Python
Python写一个基于MD5的文件监听程序
2019/03/11 Python
python反编译学习之字节码详解
2019/05/19 Python
Ticketmaster德国票务网站:购买音乐会和体育等门票
2016/11/14 全球购物
Merchant 1948澳大利亚:新西兰领先的鞋类和靴子供应商
2018/03/24 全球购物
韩国美国时尚服装和美容在线全球市场:KOODING
2018/11/07 全球购物
德国、奥地利和瑞士最大的旅行和度假门户网站:HolidayCheck
2019/11/14 全球购物
30岁生日感言
2014/01/25 职场文书
生产助理岗位职责
2014/06/18 职场文书
2014年节能降耗工作总结
2014/12/11 职场文书
出纳试用期自我评价
2015/03/10 职场文书
专职安全员岗位职责
2015/04/11 职场文书
详解pytorch创建tensor函数
2022/03/22 Python