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

时间:2022-10-17 17:03:37 

昨天翻硬盘,找到一个好东西,可惜自己加了密码自己不记得了。试了几个常用的没试出来,于是写了这么个小脚本来替我尝试。。呵呵,还真给解出来了。
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])


标签:压缩包密码破解
0
投稿

猜你喜欢

  • python对Excel的读取的示例代码

    2023-03-27 17:55:06
  • python导入csv文件出现SyntaxError问题分析

    2023-12-12 04:29:57
  • Python ttkbootstrap的介绍与使用教程

    2022-09-14 11:36:22
  • 使用cmd命令行窗口操作SqlServer的方法

    2012-07-21 14:24:06
  • php环境配置 php5 MySQL5 apache2 phpmyadmin安装与配置图文教程

    2023-11-14 22:08:47
  • python实现任意位置文件分割的实例

    2021-01-17 18:18:22
  • pandas将numpy数组写入到csv的实例

    2021-02-07 00:51:00
  • python 使用get_argument获取url query参数

    2023-02-12 03:52:18
  • JavaScript 拾漏补遗

    2024-04-19 09:52:05
  • 详解pandas.DataFrame.plot() 画图函数

    2021-06-02 21:41:49
  • 详解Python数据结构与算法中的顺序表

    2023-12-31 01:47:04
  • Selenium执行完毕未关闭chromedriver/geckodriver进程的解决办法(java版+python版)

    2023-03-28 12:39:51
  • mysql游标的原理与用法实例分析

    2024-01-15 16:33:36
  • 基于Python实现主机远程控制

    2023-11-24 17:27:31
  • python绘制高斯曲线

    2023-01-06 06:48:33
  • Python+Opencv实现图像匹配功能(模板匹配)

    2022-06-28 08:56:35
  • SQL Server 复制需要有实际的服务器名称才能连接到服务器

    2012-07-11 15:46:51
  • python 实现简单的计算器(gui界面)

    2022-11-14 14:35:14
  • Django基础知识 URL路由系统详解

    2021-01-23 11:29:59
  • 整理Python中常用的conda命令操作

    2022-07-17 16:53:33
  • asp之家 网络编程 m.aspxhome.com