vba 了解密码破解器的工作原理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25964762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 04:37:19  来源:igfitidea点击:

Understanding how a password breaker works

excelvbapassword-protection

提问by andrewdotn

Why does the following code break the excel password protect? Every sheet I have broken with it has had a password similar to 'AAAAABABABAWA', but I doubt these are the actual passwords.

为什么以下代码会破坏excel密码保护?我用它打破的每张纸都有一个类似于“AAAAABABABAWA”的密码,但我怀疑这些是实际的密码。

It seems we have a bunch of integers with a strange range. Any idea how it works?

似乎我们有一堆范围很奇怪的整数。知道它是如何工作的吗?

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

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

回答by andrewdotn

This particular password mechanism is terrible. Many different passwords will work to unlock it. The script tries a bunch starting from AAAAAAAAAAAA, and stops on the first one that works. That's why it says “One usable password is”—there are many usable passwords.

这种特殊的密码机制很糟糕。许多不同的密码将用于解锁它。该脚本从 AAAAAAAAAAAA 开始尝试一堆,并在第一个有效的时候停止。这就是为什么它说“一个可用的密码是”——有许多可用的密码。

In detail, the input password is passed through a scrambler that produces a 16-bit output, regardless of input password length. Since there are only 65,536 possible ‘scrambled' values that are checked against, and many billions of possible input passwords, for any password that you set, there are billions of other different passwords that will work to unlock it.

具体来说,输入密码通过一个产生 16 位输出的扰码器,而不管输入密码的长度如何。由于只有 65,536 个可能的“乱码”值需要检查,并且有数十亿个可能的输入密码,因此对于您设置的任何密码,还有数十亿个其他不同的密码可以用来解锁它。

Most password mechanisms are not so insecure.

大多数密码机制并不是那么不安全。

See: How does Excel's worksheet password protection work

请参阅:Excel 的工作表密码保护如何工作