Python破解压缩包密码的具体步骤是什么
Admin 2022-11-11 群英技术资讯 791 次浏览
今天这篇我们来学习和了解“Python破解压缩包密码的具体步骤是什么”,下文的讲解详细,步骤过程清晰,对大家进一步学习和理解“Python破解压缩包密码的具体步骤是什么”有一定的帮助。有这方面学习需要的朋友就继续往下看吧!破解rar和zip压缩包。Windows下使用PyCharm软件。
type = os.path.splitext(path)[-1][1:] if type == "zip": elif type == "rar":
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 & 0x1
if is_encrypted:
print("have password ")
break
else:
pass
elif type == "rar":
fileGet = rarfile.RarFile(path)
with fileGet as z:
if z.needs_password():
print("have password ")
else:
print("no password")
return
1.zip和rar
fileGet = zipfile.ZipFile(path)
fileGet = rarfile.RarFile(path)
2.解压
fileExtr.extractall(pwd=password)
import sys
import zipfile
import rarfile
import threading
import datetime
import os
import subprocess
import getopt
i = 0
fileGet = ""
class MyThread(threading.Thread):
def __init__(self, func, args, name=''):
threading.Thread.__init__(self)
self.name = name
self.func = func
self.args = args
self.result = self.func(*self.args)
def get_result(self):
try:
return self.result
except Exception:
return None
def extractFile(fileExtr, password, fileType):
try:
encodestr = str.encode(password)
if (fileType == "zip"):
fileExtr.extractall(pwd=str.encode(password))
else:
fileExtr.extractall(pwd=password)
global i
i = i + 1
print("search count : %d,real password is : %s" % (i, password))
return password
except:
i = i + 1
print("search count : %d,test password : %s, err:%s" % (i, password, sys.exc_info()[0]))
pass
def mainStep():
path = input("please input path:")
try:
if os.path.exists(path) == False:
print("%s : path error!"%(path))
return
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 & 0x1
if is_encrypted:
print("have password ")
break
else:
pass
fileGet = 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")
return
else:
print("file not right")
return
pwdLists = 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):
break
endTime = datetime.datetime.now()
timeSpan = endTime - startTime
print("search time:%ss" % (timeSpan.total_seconds()))
except:
print("err:%s" % sys.exc_info()[0])
if __name__ == '__main__':
mainStep()


免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章给大家分享的是Django模板中两个变量运算的实现,文中示例代码介绍的非常详细,对大家学习和理解Django模板中的变量运算有一定的帮助,感兴趣的朋友接下来一起跟随小编看看吧。
提到线程,你的大脑应该有这样的印象:我们可以控制它何时开始,却无法控制它何时结束,那么如何获取线程的返回值呢?今天就分享一下自己的一些做法
这篇文章主要介绍了Python字符串对齐方法使用(ljust()、rjust()和center()),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
什么是模板匹配?模板匹配,就是在一幅图像中寻找另一幅模板图像最匹配(也就是最相似)的部分的技术。
这篇文章给大家分享的是NumPy中多维数组的相关内容,下文会介绍多维数组的创建、属性、元素的类型转换和运算等等。对大家学习和理解ndarray多维数组有一定的帮助,感兴趣的朋友接下来一起跟随小编看看吧。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008