Python破解excel

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Python破解excel

用余生去守护   2022-05-23 我要评论

一、excel进入密码

加密算法cipher Algorithm=“AES”

AES加密算法的详细介绍与实现

二、密码解除思路

通过排列组合的方式进行查找

注意:此方法比较考验对密码字典的选取,且耗费时间较长,仅供参考学习!!

文件夹如图所示:

将待破解的文件放到excel文件夹中。

三、python

1.conf.ini

将准备好的密码字典添加到conf.ini中password后面,用","分隔开!!!

部分字典如下(示例):

[Conf]
path=./excel/
password=12345678,1234,qwerty,12345,dragon,pussy,baseball,football,letmein,monkey,696969,abc123,mustang,michael,shadow,master,jennifer,111111,2000,jordan,superman,harley,1234567,fuckme,hunter,fuckyou,trustno1,ranger,buster,thomas,tigger,robert,soccer,fuck,batman,test,pass,killer,hockey,george,charlie,andrew,michelle,love,sunshine,jessica,asshole,6969,pepper,daniel,access,123456789,654321,joshua,maggie,starwars,silver,william,dallas,yankees,123123,ashley,666666,hello,amanda,orange,biteme,freedom,computer,sexy,thunder,nicole,ginger,heather,hammer,summer,corvette,taylor,fucker,austin,1111,merlin,matthew,121212,golfer,cheese,princess,martin,chelsea,patrick,richard,diamond,yellow,bigdog,secret,asdfgh,sparky,cowboy,camaro,anthony,matrix,falcon,iloveyou,bailey,guitar,jackson,purple,scooter,phoenix,aaaaaa,morgan,tigers,porsche,mickey,maverick,cookie,nascar,peanut,justin,131313,money,horny,samantha,panties,steelers,joseph,snoopy,boomer,whatever,iceman,smokey,gateway,dakota,cowboys,eagles,chicken,dick,black,zxcvbn,please,andrea,ferrari,knight,hardcore,melissa,compa

2.crack.py

代码如下(示例):

#!/usr/bin/env python3
import configparser
import os
import win32com.client
import turtle
import time
import math
import shutil
import threading
import sched
 
#创建文件夹
def mkdir(path):
    path = path.strip()
    path = path.rstrip("\\")
    isExists = os.path.exists(path)
    if not isExists:
        os.makedirs(path)
        print (path + ' 创建成功')
        return True
    else:
        print (path + ' 目录已存在')
        return False
def delpwdtry(xcl,filename,pw_str):
    try:
        wb = xcl.Workbooks.Open(filename, False, False, None, pw_str)
        xcl.DisplayAlerts = False
        # # 保存时可设置访问密码.
        wb.SaveAs(filename, None, '', '')
        # 保存文件
        wb.Save()
        # 文件保存并关闭
        wb.Close(SaveChanges=True)
        xcl.Quit()
        return True
    except:
        xcl.Quit()
        return False
 
 
def makefile(path, content):
    if os.path.exists(path):
        return
    else:
        f = open(path, 'w+')
        f.write(content)
        f.seek(0)
        read = f.readline()
        f.close()
        print('excel文件放加密excel  config配置密码 okdir是成功文件夹')
        os.system('pause')
        exit(0)
def aaaa(starttime,filename,num,pwds,i,file,xcl):
    haoshi = round(time.time() - starttime, 2)
    print((str(i) + "/" + str(num)), haoshi, '秒', file)
    pwdok = 0
    i2 = 0
    for pwd in pwds:
        i2 = i2 + 1
        print ((str(i) + "/" + str(num)), '第', i2, "次尝试", pwd)
        pwd_end = ''
        boo = delpwdtry(xcl, filename, pwd)
        if boo:
            pwdok = 1
            pwd_end = pwd
            break
    if pwdok:
        print ((str(i) + "/" + str(num)), 'ok')
        # print ('10秒后移动文件')
        s = threading.Timer(10, movee, (filename,))
        s.start()
    else:
        print ('失败')
    xcl.Quit()
def movee(filename):
    shutil.move(filename, './okdir')
def delpwd(okdir,starttime):
    conf = configparser.ConfigParser()
    # 指定配置文件路径和编码
    conf.read('conf1.ini', 'utf-8')  # 文件路径
    # 读取配置信息
    path = conf.get("Conf", "path")
    password = conf.get("Conf", "password")
    pwds = password.split(',')
    xcl = win32com.client.Dispatch("Excel.Application")
    # pw_str为打开密码, 若无 访问密码, 则设为 ''
    xcl.Visible = False
    filelist = os.listdir(path)
    num = len(filelist)
    i = 0
    for file in filelist:
        i = i + 1
        filename = os.path.abspath(os.path.join(path, file))
        aaaa(starttime,filename,num,pwds,i,file,xcl)
 
starttime = time.time()
endtime = time.time()
okdir = './okdir'
mkdir('./excel')
mkdir(okdir)
makefile('./conf.ini', "[Conf]\npath=./excel/\npassword=mima1,mima2,3...")
delpwd(okdir,starttime)
 
haoshi = round(time.time()-starttime,2)
print("执行完成 耗时",haoshi , "秒")
os.system('pause')

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们