破解密码保护的Excel文件方法,Excel文件密码破解教程
破解密码保护Excel文件的方法
方法一,要是我们知道密码,直接打开Excel,点“工具”――》“保护”――》“撤消工作簿保护”,弹出窗口后输入密码就行。
方法二,没有密码的话,我们可以用“宏模块”来破解,具体步骤看下面。
1、打开要处理的Excel文件,然后按“ALT”+“F11”,就像下图那样。
2、接着点菜单上的“插入”――“模块”,如图所示。
3、把下面这段代码复制,粘贴到空白的地方;
代码如下
复制代码
Public Sub AllInternalPasswords()
' Breaks worksheet and workbook structure passwords. Bob McCormick
' probably originator of base code algorithm modified for coverage
' of workbook structure / windows passwords and for multiple passwords
'
' Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)
' Modified 2003-Apr-04 by JEM: All msgs to constants, and
' eliminate one Exit Sub (Version 1.1.1)
' Reveals hashed passwords NOT original passwords
Const DBLSPACE As String=vbNewLine & vbNewLine
Const AUTHORS As String=DBLSPACE & vbNewLine & _
"Adapted from Bob McCormick base code by" & _
"Norman Harker and JE McGimpsey"
Const HEADER As String="AllInternalPasswords User Message"
Const VERSION As String=DBLSPACE & "Version 1.1.1 2003-Apr-04"
Const REPBACK As String=DBLSPACE & "Please report failure " & _
"to the microsoft.public.excel.programming newsgroup."
Const ALLCLEAR As String=DBLSPACE & "The workbook should " & _
"now be free of all password protection, so make sure you:" & _
DBLSPACE & "SAVE IT NOW!" & DBLSPACE & "and also" & _
DBLSPACE & "BACKUP!, BACKUP!!, BACKUP!!!" & _
DBLSPACE & "Also, remember that the password was " & _
"put there for a reason. Don't stuff up crucial formulas " & _
"or data." & DBLSPACE & "Access and use of some data " & _
"may be an offense. If in doubt, don't."
Const MSGNOPWORDS1 As String="There were no passwords on " & _
"sheets, or workbook structure or windows." & AUTHORS & VERSION
Const MSGNOPWORDS2 As String="There was no protection to " & _
"workbook structure or windows." & DBLSPACE & _
"Proceeding to unprotect sheets." & AUTHORS & VERSION
Const MSGTAKETIME As String="After pressing OK button this " & _
"will take some time." & DBLSPACE & "Amount of time " & _
"depends on how many different passwords, the " & _
"passwords, and your computer's specification." & DBLSPACE & _
"Just be patient! Make me a coffee!" & AUTHORS & VERSION
Const MSGPWORDFOUND1 As String="You had a Worksheet " & _
"Structure or Windows Password set." & DBLSPACE & _
"The password found was: " & DBLSPACE & "
&\#x22; &\#x26; DBLSPACE &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;Note it down for potential future use in other workbooks by &\#x22; &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;the same person who set this password.&\#x22; &\#x26; DBLSPACE &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;Now to check and clear other passwords.&\#x22; &\#x26; AUTHORS &\#x26; VERSION&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Const MSGPWORDFOUND2 As String=&\#x22;You had a Worksheet &\#x22; &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;password set.&\#x22; &\#x26; DBLSPACE &\#x26; &\#x22;The password found was: &\#x22; &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;DBLSPACE &\#x26; &\#x22;
"future use in other workbooks by same person who " & _
"set this password." & DBLSPACE & "Now to check and clear " & _
"other passwords." & AUTHORS & VERSION
Const MSGONLYONE As String="Only structure / windows " & _
"protected with the password that was just found." & _
ALLCLEAR & AUTHORS & VERSION & REPBACK
Dim w1 As Worksheet, w2 As Worksheet
Dim i As Integer, j As Integer, k As Integer, l As Integer
Dim m As Integer, n As Integer, i1 As Integer, i2 As Integer
Dim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer
Dim PWord1 As String
Dim ShTag As Boolean, WinTag As Boolean
Application.ScreenUpdating=False
With ActiveWorkbook
WinTag=.ProtectStructure Or .ProtectWindows
End With
ShTag=False
For Each w1 In Worksheets
ShTag=ShTag Or w1.ProtectContents
Next w1
If Not ShTag And Not WinTag Then
MsgBox MSGNOPWORDS1, vbInformation, HEADER
Exit Sub
End If
MsgBox MSGTAKETIME, vbInformation, HEADER
If Not WinTag Then
MsgBox MSGNOPWORDS2, vbInformation, HEADER
Else
On Error Resume Next
Do 'dummy do loop
For i=65 To 66: For j=65 To 66: For k=65 To 66
For l=65 To 66: For m=65 To 66: For i1=65 To 66
For i2=65 To 66: For i3=65 To 66: For i4=65 To 66
For i5=65 To 66: For i6=65 To 66: For n=32 To 126
With 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 Then
PWord1=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, _
"
&\#x22;, PWord1), vbInformation, HEADER&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Exit Do &\#x27;Bypass all for...nexts&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;End If&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;End With&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Next: Next: Next: Next: Next: Next&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Next: Next: Next: Next: Next: Next&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Loop Until True&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;On Error GoTo 0&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;End If&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;If WinTag And Not ShTag Then&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;MsgBox MSGONLYONE, vbInformation, HEADER&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Exit Sub&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;End If&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;On Error Resume Next&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For Each w1 In Worksheets&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x27;Attempt clearance with PWord1&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;w1.Unprotect PWord1&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Next w1&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;On Error GoTo 0&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;ShTag=False&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For Each w1 In Worksheets&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x27;Checks for all clear ShTag triggered to 1 if not.&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;ShTag=ShTag Or w1.ProtectContents&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Next w1&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;If ShTag Then&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For Each w1 In Worksheets&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;With w1&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;If .ProtectContents Then&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;On Error Resume Next&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Do &\#x27;Dummy do loop&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For i=65 To 66: For j=65 To 66: For k=65 To 66&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For l=65 To 66: For m=65 To 66: For i1=65 To 66&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For i2=65 To 66: For i3=65 To 66: For i4=65 To 66&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;For i5=65 To 66: For i6=65 To 66: For n=32 To 126&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;.Unprotect Chr(i) &\#x26; Chr(j) &\#x26; Chr(k) &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Chr(l) &\#x26; Chr(m) &\#x26; Chr(i1) &\#x26; Chr(i2) &\#x26; Chr(i3) &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Chr(i4) &\#x26; Chr(i5) &\#x26; Chr(i6) &\#x26; Chr(n)&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;If Not .ProtectContents Then&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;PWord1=Chr(i) &\#x26; Chr(j) &\#x26; Chr(k) &\#x26; Chr(l) &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Chr(m) &\#x26; Chr(i1) &\#x26; Chr(i2) &\#x26; Chr(i3) &\#x26; _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;Chr(i4) &\#x26; Chr(i5) &\#x26; Chr(i6) &\#x26; Chr(n)&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;MsgBox Application.Substitute(MSGPWORDFOUND2, _&\#x3C;/p&\#x3E; &\#x3C;p&\#x3E;&\#x3000;&\#x3000;&\#x22;
'leverage finding Pword by trying on other sheets
For Each w2 In Worksheets
w2.Unprotect PWord1
Next w2
Exit Do 'Bypass all for...nexts
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
End With
Next w1
End If
MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
End Sub
4、好了,确定没问题后按一下“F5”运行宏模块,开始密码破解。先点击确定,之后就能看到红框处的密码数字了
5、完成之后,再去尝试编辑Excel,就不会有任何问题了哦。
需要注意的是,破解他人加密的Excel文件可能会涉及隐私问题,一定要在合法合规的前提下使用这些方法,可不能乱用哦。
你有没有遇到过破解Excel密码的情况呀?用这些方法尝试的时候顺利吗?可以在评论区说说你的经历。