Excel 2013及更高版本中使用VBA的受保护工作表的密码破解程序

时间:2016-05-19 21:32:00

标签: excel vba excel-vba

有人知道在excel中是否还有其他方法可以破解受保护工作表的密码?从那以后我一直在使用这些代码,但现在它似乎不再起作用了。该文件只是说"没有回复"每次我运行代码。我使用的是MS Office 2013。

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 As Integer
On Error Resume Next
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
ActiveSheet.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 ActiveSheet.ProtectContents = False Then
    MsgBox "One usable password is " & Chr(i) & Chr(j) & _
        Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
        Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
     Exit Sub
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
End Sub

4 个答案:

答案 0 :(得分:7)

Excel已在Excel 2013及更新版本中更新了其表单保护安全性,因此该宏不再起作用,请参阅here

从链接中听起来如果将文件保存为xls文件(Excel 1997-2003),它会被迫删除较新的安全性,因为它与文件类型不兼容。然后,您可以运行您的宏。

保存为较旧的文件版本可能会使工作簿的某些部分无法正常工作。

答案 1 :(得分:1)

感谢卡维,它运行得很好。

这是经过Kawi修改的完整代码:

    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 As Integer
    On Error Resume Next
    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
    Debug.Print Chr(i) & Chr(j) & Chr(k) _
          & Chr(l) & Chr(m) & Chr(i1) _
          & Chr(i2) & Chr(i3) & Chr(i4) _
          & Chr(i5) & Chr(i6) & Chr(n)
    DoEvents
    ActiveSheet.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 ActiveSheet.ProtectContents = False Then
        MsgBox "One usable password is " & Chr(i) & Chr(j) & _
            Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
            Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
         Exit Sub
    End If

答案 2 :(得分:0)

我不确定这是如何工作的,但我能够取消保护工作表。我做了“另存为”并将类型更改为:“Excel 97-2003”。当我打开文件&取消保护工作表,它不再要求输入密码了。 :)我的工作簿仍然可以正常工作。

答案 3 :(得分:-1)

自最近更新以来,Excel出现了一个高命令率命令Unprotect的问题。一些减速使代码再次运行:在Unprotect行之前放置这样的东西,即进入最内层循环:

Debug.Print Chr(i) & Chr(j) & Chr(k) _
      & Chr(l) & Chr(m) & Chr(i1) _
      & Chr(i2) & Chr(i3) & Chr(i4) _
      & Chr(i5) & Chr(i6) & Chr(n)
DoEvents

通过此(速度)修改,最初提到的方法也适用于Excel 2013和Excel 2016。