Python破解excel進入密碼的過程詳解

一、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')

到此這篇關於Python破解excel進入密碼的過程詳解的文章就介紹到這瞭,更多相關Python破解excel內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: