简介:

破解rar和zip压缩包。Windows下使用PyCharm软件。

1.步骤

1.环境

  1. 指令pip install 安装。
  2. 如果是rar文件需要把rar安装包下的Rar.exe和UnRar.exe,放在对应项目\venv\Scripts的路径下。
  3. import失败时,需要在File->Settings->Project Interpreter添加对应的模块。

2.判断文件格式

        type = os.path.splitext(path)[-1][1:]if type == "zip":elif type == "rar":

3.判断是否有密码

        type = os.path.splitext(path)[-1][1:]if type == "zip":fileGet = zipfile.ZipFile(path)with fileGet as z:for l in z.infolist():is_encrypted = l.flag_bits & 0x1if is_encrypted:print("have password ")breakelse:passelif type == "rar":fileGet = rarfile.RarFile(path)with fileGet as z:if z.needs_password():print("have password ")else:print("no password")return

4.密码字典

  1. 自己写或者下载相应的软件生成。

5.解压文件

1.zip和rar

fileGet = zipfile.ZipFile(path)
fileGet = rarfile.RarFile(path)

2.解压

 fileExtr.extractall(pwd=password)

2.代码

import sys
import zipfile
import rarfile
import threading
import datetime
import os
import subprocess
import  getopti = 0
fileGet = ""class MyThread(threading.Thread):def __init__(self, func, args, name=''):threading.Thread.__init__(self)self.name = nameself.func = funcself.args = argsself.result = self.func(*self.args)def get_result(self):try:return self.resultexcept Exception:return Nonedef extractFile(fileExtr, password, fileType):try:encodestr = str.encode(password)if (fileType == "zip"):fileExtr.extractall(pwd=str.encode(password))else:fileExtr.extractall(pwd=password)global ii = i + 1print("search count : %d,real password is : %s" % (i, password))return passwordexcept:i = i + 1print("search count : %d,test password : %s, err:%s" % (i, password, sys.exc_info()[0]))passdef mainStep():path = input("please input path:")try:if os.path.exists(path) == False:print("%s : path error!"%(path))returntype = os.path.splitext(path)[-1][1:]if type == "zip":fileGet = zipfile.ZipFile(path)with fileGet as z:for l in z.infolist():is_encrypted = l.flag_bits & 0x1if is_encrypted:print("have password ")breakelse:passfileGet = zipfile.ZipFile(path)elif type == "rar":fileGet = rarfile.RarFile(path)with fileGet as z:if z.needs_password():print("have password ")else:print("no password")returnelse:print("file not right")returnpwdLists = open("D:\Python工程\mutou.txt")startTime = datetime.datetime.now()for line in pwdLists.readlines():Pwd = line.strip('\n')t = MyThread(extractFile, (fileGet, Pwd, type))t.start()if (t.get_result() is Pwd):breakendTime = datetime.datetime.now()timeSpan = endTime - startTimeprint("search time:%ss" % (timeSpan.total_seconds()))except:print("err:%s" % sys.exc_info()[0])if __name__ == '__main__':mainStep()

1.在线调试

2.脚本运行

  1. cmd 窗口打开方式:右键开始菜单,选择‘命令提示符(管理员)’即可。或者从开始菜单->运行->输入cmd,回车。
  2. 关于 cd 命令:用于改变当前目录路径。使用方式:cd[空格][路径]。例如 cd d:/Python27/Mytest 转到该路径下。
  3. 注意:如果当前盘符不是 D 盘,需要先转到 D 盘,输入 d: 回车即可。然后才可以使用 cd d:/Python27/Mytest 。
  4. 输入python test.py。test.py是对应的文件名。

Python破解压缩包密码相关推荐

  1. Python破解压缩包密码问题

    所用知识 1. Pool 进程池 2. try...except 异常处理 3.枚举的方式 4.生成器的运用 逻辑关系 通过生成假密码去碰撞!捕获异常,一直碰撞,直到生成的密码与压缩包建立的密码对应, ...

  2. python暴力破解压缩包密码(python暴力破解zip压缩包)

    python暴力破解压缩包密码 简介 简介: ZIP文件格式是一种数据压缩和文档储存的文件格式,原名Deflate,发明者为菲尔·卡茨(Phil Katz),他于1989年1月公布了该格式的资料.ZI ...

  3. 20220208--CTF MISC-- BUUCTF--二维码 1--binwalk-john-(工具的使用:分析文件/暴力破解压缩包密码)

    MISC-- BUUCTF–二维码 1 这题首先下载文件,解压: 微信扫描了一下这个二维码,得到: secret is here 打开kali ,首先用binwalk分析该文件 命令: binkwal ...

  4. Centos下rarcrack破解压缩包密码

    Centos下rarcrack破解压缩包密码 很久之前的压缩包忘了密码怎么办?我在花了大量时间收集和整理后发现,目前CentOS下有效的就是rarcrack这个软件了,目前在官网已经没有了,只能是自己 ...

  5. 【PC工具】压缩包密码破解工具,暴力破解压缩包密码,解压密码获取

    公众号关注 "DLGG创客DIY" 设为"星标",重磅干货,第一时间送达. 平时备份文件,为保证数据安全,经常会给压缩包加密,那么问题就来了,我脑子不好老忘事怎 ...

  6. 【PC工具】压缩包密码破解工具,暴力破解压缩包密码,zip密码获取

    平时备份文件,为保证安全经常会给压缩包加密,但是自己使用的时候又比较容易忘掉.还有一种情况,在网上找了半天,下载了半天的资源,打开压缩包发现有密码... 今天给大家带来一款可以破解压缩包密码的软件-- ...

  7. python入门教程NO.3 用python破解谍报密码

    python入门教程NO.3 用python破解谍报密码 本文涉及的python基础语法为:列表及其方法 列表 我们发现了一段存在**[]中的谍报密码,为了破解他,我们必须先来学习一下,这个存放着谍报 ...

  8. Python破解Wifi密码脚本

    Python破解Wifi密码脚本 使用pywifi 暴力破解wifi密码,就是使用使用多个密码与wifi进行连接测试.总的来说,破解成功的可能性是存在的,但需要付出很多的努力,当然,付出努力也不一定能 ...

  9. Kali Linux 系统暴力破解压缩包密码工具总结

    在 Kali Linux 系统中,有多种工具可以用于暴力破解压缩包密码.下面将介绍几种常用的工具,包括 fcrackzip.zipcracker 和 John the Ripper. 1.fcrack ...

最新文章

  1. AWS 中国宁夏和北京区正式上线 Amazon SageMaker,中国用户终于能用到新工具和功能!
  2. centos6.7部署solr-6.3.0
  3. 写博客一定程度上是在刷存在感~
  4. 【hdu 1527】取石子游戏
  5. 蓝桥杯第七届决赛真题大全题解(java版本)
  6. 移动端web开发,click touch tap区别
  7. 心灵之光、思想之树:推荐《作家曰》
  8. Java 文件的拷贝
  9. Python将绝对路径转换为相对路径方法实例
  10. c++ vector排序_个性化推荐系统源代码之基于LR模型的推荐系统离线排序方案
  11. boot客户管理系统实训报告_客户太多,客户转化困难?分析报告迟迟出不来,CRM客户管理系统助你一臂之力...
  12. Scala,一门「特立独行」的语言!
  13. stm32按键矩阵代码_STM32学习日志——电容触摸按键实验(20-06-27)
  14. C++基础:第七章 函数
  15. Inside Google’s language detection tool
  16. 微机课设 | 基于STC15单片机的简易数字密码锁设计
  17. matlab的grid网格线属性设置,修改网格线密度
  18. 雷达imu联合标定lidar_imu_calib-main
  19. 贝叶斯算法(bayesian)在反垃圾邮件中的应用
  20. 解决Attribute url invalid for tag page according to TLD的问题

热门文章

  1. Android 获取手机状态栏高度
  2. 关于信息检索(IR)、搜索引擎的学与思
  3. 倒排索引(Inverted index)
  4. 12306泄露数据可视化分析
  5. Android MVP详解
  6. mvp的全称_库里常规赛mvp是哪一年,分别于2014-15和2015-16赛季荣膺
  7. appcrash事件怎么解决?三种方法教你
  8. 低成本、快速造测试数据,这个工具你指的拥有
  9. 高德地图接口申请 地图接口集成 高德地图API文档
  10. HPD健康产品申明认证