利用itertools生成密码字典,多线程撞库破解rar压缩文件密码
脚本功能:
利用itertools生成密码字典(迭代器形式)
多线程并发从密码字典中取出密码进行验证
验证成功后把密码写入文件中保存
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Author:Leslie-x
import itertools as its
import threading
import rarfile
import os words = '0123456789abcdefghijklmnopqrstuvwxyz' # 涉及到生成密码的参数 flag = True # 是否关闭线程的标志 def append_on_file(password,file_name):
# 把解析出的密码写入到文件中
with open('password.txt', 'a', encoding='utf8') as f:
text = file_name+':'+password + '\n'
f.write(text) def get_password(min_digits, max_digits, words):
"""
:param min_digits: 密码最小长度
:param max_digits: 密码最大长度
:param words: 密码可能涉及的字符
:return: 密码生成器
"""
while min_digits <= max_digits:
pwds = its.product(words, repeat=min_digits)
for pwd in pwds:
yield ''.join(pwd)
min_digits += 1 def extract(File,file_name):
"""
若线程关闭标志为True,就执行循环,从密码生成器中取出密码,验证密码是否正确
密码正确,则把密码写入文件中,并将线程关闭标志flag设定为False,通知其他线程关闭
"""
global flag
while flag:
p = next(passwords)
try:
File.extractall(pwd=p) # 打开压缩文件,提供密码...
flag = False
print("password is " + p) ###破解到密码
append_on_file(p,file_name)
break
except:
print(p) def mainStep(file_path,file_name):
"""
多线程并发验证密码
:param file_path: rar压缩文件路径列表
:return:
"""
file = rarfile.RarFile(file_path)
for pwd in range(3):
t = threading.Thread(target=extract, args=(file,file_name))
t.start() if __name__ == '__main__':
# 主程序
base_dir = r'E:\迅雷下载\rar'
for file_info in os.listdir(base_dir):
try:
# 拼接压缩文件路径
file_path = os.path.join(base_dir, file_info)
# 压缩文件名称
file_name = file_info.split('.')[0]
# 生成密码字典:密码长度最小为4,最大为11
passwords = get_password(4, 11, words)
# 将任务分发给线程执行
mainStep(file_path,file_name)
except:
pass
注意:当前脚本在知道密码长度大概范围,可能涉及的字符具体范围下效率可行;如果对密码长度和涉及字符完全不知,撞库难度非常大
利用itertools生成密码字典,多线程撞库破解rar压缩文件密码的更多相关文章
- mac电脑下使用fcrackzip破解zip压缩文件密码
fcrackzip简介 fcrackzip是一款专门破解zip类型压缩文件密码的工具,工具小巧方便.破解速度快,能使用字典和指定字符集破解,适用于linux.mac osx 系统 fcrackzip安 ...
- zip、rar压缩文件密码破解——使用ARCHPR Professional Edition
直链下载地址: https://pan.abn.cc/weiyun/down.php?u=82441366e3c1f43fc69210e8ece93470.undefined.zip (压缩包内含解压 ...
- 破解ZIP加密文件密码fcrackzip
破解ZIP加密文件密码fcrackzip ZIP是最常见的文件压缩方式.由于其压缩算法开源,主流操作系统都支持这种压缩算法.ZIP压缩方式支持密码加密.加密的时候会在文件头部保存密钥相关信息.利用这个 ...
- 破解压缩文件密码rarcrack
破解压缩文件密码rarcrack 常见的压缩文件格式有ZIP.RAR和7z.这三种格式都支持使用密码进行加密压缩.前面讲过破解ZIP压缩文件,可以使用fcrackzip.对于RAR和7z格式,可以 ...
- 利用CMake生成动态或静态链接库工程
install解释: TARGETS版本的install命令 install(TARGETS targets... [EXPORT <export-name>] [[ARCHIVE|LIB ...
- 利用python暴力破解压缩文件密码
import randomimport sysimport zipfileimport timefrom threading import Threadfrom multiprocessing imp ...
- Python真牛逼,获取压缩文件密码,我只要一分钟!
事情的经过是这样的: 又是奶茶,行吧行吧. 快点开工,争取李大伟回来之前搞定. 李大伟说是6位数字密码 那么我们可以利用python生成全部的六位数字密码 这样,我们就生成了一个从000000到999 ...
- centos破解压缩文件密码
rarcrack是linux系统端的一款破解加密压缩包的工具,rarcrack使用的穷举法进行破解已经加密的rar.zip和7z压缩包,支持设置多线程,和文件类型进行破解. 1.rarcrack下载页 ...
- 利用pyinstaller生成exe之后,运行不能正常产生结果文件问题记录
https://segmentfault.com/q/1010000011284617/a-1020000011493026 在此链接已解决问题,现在在这里在详细记录一次 问题描述: 利用pychar ...
随机推荐
- ace -- about
Built for Code Ace is an embeddable code editor written in JavaScript. It matches the features and p ...
- PAT甲题题解-1027. Colors in Mars (20)-水。。。
#include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...
- PAT甲题题解-1076. Forwards on Weibo (30)-BFS
题目大意:给出每个用户id关注的人,和转发最多的层数L,求一个id发了条微博最多会有多少个人转发,每个人只考虑转发一次.用BFS,同时每个节点要记录下所在的层数,由于只能转发一次,所以每个节点要用vi ...
- 在eclipse中编译调试ns3
1首先把ns3项目导入eclipse 然后把上面的的ns3按照上面的提示即可导入成功. 然后可以运行一下 ./waf configure 2 配置C/C++ Build 右键工程,选择属性 ...
- psp进度统计
每周例行报告 本周PSP 类别 任务 开始时间 结束时间 被打断时间 总计工作时间 11月8日 代码 参与团队项目 10:13 11:30 0 77min 写博客 词频统计总结 13:35 14 ...
- [转帖]shell 中的>/dev/null 2>&1 是什么鬼?
shell 中的>/dev/null 2>&1 是什么鬼? http://blog.jobbole.com/109355/ 背景 我们经常能在shell脚本中发现>/dev/ ...
- poj3368 Frequent values(线段树)
Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In ad ...
- 选择提供器 - 选择监听器(selection provider-selection listener)模式
- Tomcat源码解析-整体流程介绍
一.架构 下面谈谈我对Tomcat架构的理解 总体架构: 1.面向组件架构 2.基于JMX 3.事件侦听 1)面向组件架构 tomcat代码看似很庞大,但从结构上看却很清晰和简单,它主要由一堆组件组成 ...
- Maven变量及常见插件配置详解(转)
一.变量-自定义变量及内置变量 1.自定义变量 <properties> <project.build.name>tools</project.build.name> ...