因为EXCEL的密码加密码方法与我们平常的不一样.
EXCEL中是把你输入的密码转化成" ABABBBABAAA* "这种形式的:
前面11位每一位A或B组成,第12位才是任意一个字符.
举例:你输入1234为密码,结果用1257也能打开是一样的:
这样子就算你输入的密码1000万种情况,到EXCEL中就只有20多万种情况了.
用VBA代码很快就破了,下面这段代码就是破解工作表保护的,你看下就知道了:
所以说工作表保护密码是非常脆弱的:
Sub RemovePPW()
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
If ActiveSheet.ProtectContents = False Then
' MsgBox "该工作表没有保护密码!"
Exit Sub
End If
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 "已经解除了工作表保护!"
Exit Sub
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
End Sub
当Excel工作表采用密码保护时,就会生成一个16位(双字节)长hash值。
当输入密码进行验证时,真正进行比较的就是这个hash值。事实上,有很多不同的密码都可以生成同样的hash值。你可以试试:当你用“test”(不含双引号)作为Excel工作表保护密码,你同样可以用
“zzyw”(同样不含双引号)这个密码进行解锁。怎么样,神奇吧?