系列文章目录
前言
excel进入密码测试(穷举)
代码如下(示例):
源码引用
# coding=utf-8
from win32com.client import DispatchEx
from random import choice
import string
def read_excel_password(filename, password=None):
excel = DispatchEx("Excel.Application") # 启动excel
excel.Visible = False # 去掉可视化
try:
demo = excel.Workbooks.Open(filename,
UpdateLinks=False,
ReadOnly=False,
Format=None,
Password=password) # 打开文件并将密码传入
except BaseException:
print("错误密码:[%s]" % password)
return 0
else:
print("正确密码:[%s]" % password)
demo.Close(True)
return 666
def demo_keys(length=3, types="默认"):
# 导入字符集
chars_zd = {
"字母": string.ascii_letters,
"数字": string.digits,
#"符号": "`-=[]\\;',./*-+~()_{}|:<>?\""
}
if types == "符号":
chars = chars_zd.values()
elif types == "默认":
chars = chars_zd['字母'] + chars_zd["数字"]
else:
chars = chars_zd[types]
password = ''.join([choice(chars) for i in range(length)])
return password
if __name__ == '__main__':
print("为了提升破解效率,请准确填写大概范围!填写符号则将进行最大穷举!!!")
print("密码类型默认是字母+数字组合")
print("密码位数默认是三位")
# types = input("请输入[字母,数字, 符号, 默认]:")
# length = input("请输入密码位数:")
types = "字母"
length = 3
# 导入文件地址
filename = r"abc.xlsx"
while True:
password = demo_keys(length=int(length), types=types)
biaozhi = read_excel_password(filename=filename, password=password)
if biaozhi == 666:
break
总结
分享:
每个人在成长中都会受很多伤,会哭泣悲伤,会觉得痛。许多事情,总是在经历过后才明白。痛过了,便坚强了;跨过了,便成熟了;傻过了,便懂得了适时的珍惜与放弃。