Excel文档保护密码破解

news/2024/10/30 13:36:49/

为了保护Excel文档的安全性,往往会给Excel文档加密码,其实加密码有几种形式:
1、给整个文档加密码,打开时就得输入密码;
2、给sheet加编辑密码,可以查看,但是编辑时需要输入密码。
本文针对第二种,工作表保护。设置如下图:
在这里插入图片描述
如果在如上图中设置了密码并且密码忘记了时,可以使用如下解决方案。
注意:本方法也是属于“死马当活马医”方案,也并不一定能解决问题。因为本文用此方法破解了密码,所以记录下来,万一遇到问题的小伙伴试试也能解决问题呢。

1、打开Excel,选择被保护的sheet,按alt+F11,弹出如下窗口,然后选择ThisWorkbook右击查看代码,弹出代码输入框。
在这里插入图片描述

2、输入如下代码:

Public Sub 工作表保护密码破解()Const DBLSPACE As String = vbNewLine & vbNewLineConst AUTHORS As String = DBLSPACE & vbNewLine & _"作者:McCormick   JE McGimpsey "Const HEADER As String = "工作表保护密码破解"Const VERSION As String = DBLSPACE & "版本 Version 1.1.1"Const REPBACK As String = DBLSPACE & ""Const ZHENGLI As String = DBLSPACE & ""Const ALLCLEAR As String = DBLSPACE & "该工作簿中的工作表密码保护已全部解除!!" & DBLSPACE & "请记得另保存" _& DBLSPACE & "注意:不要用在不当地方,要尊重他人的劳动成果!"Const MSGNOPWORDS1 As String = "该文件工作表中没有加密"Const MSGNOPWORDS2 As String = "该文件工作表中没有加密2"Const MSGTAKETIME As String = "解密需花费一定时间,请耐心等候!" & DBLSPACE & "按确定开始破解!"Const MSGPWORDFOUND1 As String = "密码重新组合为:" & DBLSPACE & "$$" & DBLSPACE & _"如果该文件工作表有不同密码,将搜索下一组密码并修改清除"Const MSGPWORDFOUND2 As String = "密码重新组合为:" & DBLSPACE & "$$" & DBLSPACE & _"如果该文件工作表有不同密码,将搜索下一组密码并解除"Const MSGONLYONE As String = "确保为唯一的?"Dim w1 As Worksheet, w2 As WorksheetDim i As Integer, j As Integer, k As Integer, l As IntegerDim m As Integer, n As Integer, i1 As Integer, i2 As IntegerDim i3 As Integer, i4 As Integer, i5 As Integer, i6 As IntegerDim PWord1 As StringDim ShTag As Boolean, WinTag As BooleanApplication.ScreenUpdating = FalseWith ActiveWorkbookWinTag = .ProtectStructure Or .ProtectWindowsEnd WithShTag = FalseFor Each w1 In WorksheetsShTag = ShTag Or w1.ProtectContentsNext w1If Not ShTag And Not WinTag ThenMsgBox MSGNOPWORDS1, vbInformation, HEADERExit SubEnd IfMsgBox MSGTAKETIME, vbInformation, HEADERIf Not WinTag ThenElseOn Error Resume NextDo 'dummy do loopFor i = 65 To 66: For j = 65 To 66: For k = 65 To 66For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126With ActiveWorkbook.Unprotect Chr(i) & Chr(j) & Chr(k) & _Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)If .ProtectStructure = False And _.ProtectWindows = False ThenPWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)MsgBox Application.Substitute(MSGPWORDFOUND1, _"$$", PWord1), vbInformation, HEADERExit Do 'Bypass all for...nextsEnd IfEnd WithNext: Next: Next: Next: Next: NextNext: Next: Next: Next: Next: NextLoop Until TrueOn Error GoTo 0End IfIf WinTag And Not ShTag ThenMsgBox MSGONLYONE, vbInformation, HEADERExit SubEnd IfOn Error Resume NextFor Each w1 In Worksheets'Attempt clearance with PWord1w1.Unprotect PWord1Next w1On Error GoTo 0ShTag = FalseFor Each w1 In Worksheets'Checks for all clear ShTag triggered to 1 if not.ShTag = ShTag Or w1.ProtectContentsNext w1If ShTag ThenFor Each w1 In WorksheetsWith w1If .ProtectContents ThenOn Error Resume NextDo 'Dummy do loopFor i = 65 To 66: For j = 65 To 66: For k = 65 To 66For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126.Unprotect Chr(i) & Chr(j) & Chr(k) & _Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)If Not .ProtectContents ThenPWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)MsgBox Application.Substitute(MSGPWORDFOUND2, _"$$", PWord1), vbInformation, HEADER'leverage finding Pword by trying on other sheetsFor Each w2 In Worksheetsw2.Unprotect PWord1Next w2Exit Do 'Bypass all for...nextsEnd IfNext: Next: Next: Next: Next: NextNext: Next: Next: Next: Next: NextLoop Until TrueOn Error GoTo 0End IfEnd WithNext w1End IfMsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK & ZHENGLI, vbInformation, HEADER
End Sub

3、然后点击如下图的执行按钮或者按F5运行代码
在这里插入图片描述
4、执行过程中会弹出几个弹框,点确定就好了。如下图:
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
以上就是本文解决Excel文档工作表加密破解问题的过程,希望能帮到有需要的小伙伴。


http://www.ppmy.cn/news/265563.html

相关文章

python2 破解 excel 密码

上代码 import pyexcelerator def test_passwords(filepath, passwords): # 读取加密文件 try: book pyexcelerator.parse_xls(filepath, passwordNone) return True except: # 尝试所有密码组合 for password in passwords: try: book pyexcelerator.parse_xls(filepath, pa…

Python知识点:lambda 表达式

大家好,欢迎来到 Crossin的编程教室 ! Python 是一门简洁的语言,lambda 表达式则充分体现了 Python 这一特点。 lambda 表达可以被看做是一种匿名函数。它可以让你快速定义一个极度简单的单行函数。譬如这样一个实现三个数相加的函数&#xf…

excel被密码保护如何破解获得原密码

excel被密码保护如何破解获得原密码 1、打开Excel表格中的Excel选项,选择自定义,得到如下画面: 2、然后在左边侧框栏中选择“查看宏”之后双击或者选择添加按钮,则可以看到右边栏中有了查看宏按钮,之后点击右下角的确…

EXCEL密码清除(破解找回密码)——巧用宏代码

各位朋友估计都经历过excel 设置了密码,N久以后本以为这辈子都不会忘记的密码,真的忘记了。 唯一能做的就是破解,但网上各种破解工具又不可靠,各种担心,好不容易鼓起勇气决定下载破解软件,结果一次次中招&…

excel 破解密码

新建宏,运行 Sub PasswordBreaker()Breaks worksheet password protection.Dim i As Integer, j As Integer, k As Integer Dim l As Integer, m As Integer, n As Integer Dim i1 As Integer, i2 As Integer, i3 As Integer Dim i4 As Integer, i5 As Integer, i6 …

Excel破解工作表保护密码

目录: 一、破解过程 1、新建一个EXCEL文件“BOOK1”,在工具栏空白位置,任意右击,选择Visual Basic项,弹出Visual Basic工具栏 2、在Visual Basic工具栏中,点击“录制”按钮,弹出“录制新宏”…

Excel密码保护破解代码

声明:本文图片、文章来源于网络,版权归原作者所有,如有侵权,请与我联系删除。 1、打开Excel表格中的Excel选项,选择自定义,得到如下画面: 2、然后在左边侧框栏中选择“查看宏”之后双击或者选择添加按钮&a…

Excel文件加密后忘记密码破解方法

最好使用VBA 工程密码破解方法 新建一个excel文档,然后打开,同时按Alt和F11,进入VBA界面 点击菜单上的插入,模块 在新的窗口粘贴以下代码: 1 Sub crack()