这不是一个真正的问题,而是好奇心。在谷歌搜索有关如何解锁受密码保护的工作表的方法时,以下代码始终位于解决方案列表中。从它的结构来看,似乎没有对猜测受保护工作表的密码进行“暴力破解”攻击。
我能看到以下内容:
猜测密码的前11个字符是字母“A”或“B”。 (注意大字母和字母组合,大约2,048种可能的组合。)
第十二个字符是“其他字符”,范围从“空格”到“〜”(?)。
我的问题是,当密码的第一个字母绝对不是字母“A”或“B”时,这段代码如何删除密码保护,也不是这些字母的组合?
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