excel 工作表保护密码破解代码

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

今天应朋友所托破解一个遗忘了密码的excel文档,故有此,发博以记录。所用excel版本为Microsoft office Standard Edition 2003

操作流程如下:

一、

二、 

三、 把下面代码粘贴到模块中,如下图,代码在图下提供

 

四、代码

Public Sub 工作表保护密码破解()Const DBLSPACE As String = vbNewLine & vbNewLineConst AUTHORS As String = DBLSPACE & vbNewLine & _"作者:圣天"Const HEADER As String = "工作表保护密码破解"Const VERSION As String = DBLSPACE & "版本 Version 1.1.1"Const REPBACK As String = DBLSPACE & ""Const ZHENGLI As String = DBLSPACE & "                   XXXXXXX"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 66For j = 65 To 66For k = 65 To 66For l = 65 To 66For m = 65 To 66For i1 = 65 To 66For i2 = 65 To 66For i3 = 65 To 66For i4 = 65 To 66For i5 = 65 To 66For i6 = 65 To 66For 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 WithNextNextNextNextNextNextNextNextNextNextNextNextLoop 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 66For j = 65 To 66For k = 65 To 66For l = 65 To 66For m = 65 To 66For i1 = 65 To 66For i2 = 65 To 66For i3 = 65 To 66For i4 = 65 To 66For i5 = 65 To 66For i6 = 65 To 66For 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 IfNextNextNextNextNextNextNextNextNextNextNextNextLoop Until TrueOn Error GoTo 0End IfEnd WithNext w1End IfMsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK & ZHENGLI, vbInformation, HEADER
End Sub

五、运行代码,如下所示

 

六、最后把excel文件另存为即可


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

相关文章

Excel文档保护密码破解

为了保护Excel文档的安全性,往往会给Excel文档加密码,其实加密码有几种形式: 1、给整个文档加密码,打开时就得输入密码; 2、给sheet加编辑密码,可以查看,但是编辑时需要输入密码。 本文针对第二…

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…