Public Sub 工作表保护密码破解() 4\ )WMP
Const DBLSPACE As String = vbNewLine & vbNewLine ^ yF
Wvfh4
Const AUTHORS As String = DBLSPACE & vbNewLine & _ ?;(!(<{
"作者:XXXXXXX" i!JSEQ_8
Const HEADER As String = "工作表保护密码破解" |pU>^
Const VERSION As String = DBLSPACE & "版本 Version 1.1.1" ,O^kZ}b
Const REPBACK As String = DBLSPACE & "" H.l
WHM+H4
Const ZHENGLI As String = DBLSPACE & " XXXXXXX" zH~g5xgh
Const ALLCLEAR As String = DBLSPACE & "该工作簿中的工作表密码保护已全部解除!!" & DBLSPACE & "请记得另保存" _ Kuk@x.~0m
& DBLSPACE & "注意:不要用在不当地方,要尊重他人的劳动成果!" }095U(@
Const MSGNOPWORDS1 As String = "该文件工作表中没有加密" ntL%&wY
Const MSGNOPWORDS2 As String = "该文件工作表中没有加密2" s-&i!d
Const MSGTAKETIME As String = "解密需花费一定时间,请耐心等候!" & DBLSPACE & "按确定开始破解!" {S%;By&[
Const MSGPWORDFOUND1 As String = "密码重新组合为:" & DBLSPACE & "$$" & DBLSPACE & _ 7<2?NLE8*
"如果该文件工作表有不同密码,将搜索下一组密码并修改清除" 4IM_6
Const MSGPWORDFOUND2 As String = "密码重新组合为:" & DBLSPACE & "$$" & DBLSPACE & _ eUgKwu;
"如果该文件工作表有不同密码,将搜索下一组密码并解除" XC390t
Const MSGONLYONE As String = "确保为唯一的?" $SniQ
Dim w1 As Worksheet, w2 As Worksheet 9NU-1vd~
Dim i As Integer, j As Integer, k As Integer, l As Integer TC:t!:
Dim m As Integer, n As Integer, i1 As Integer, i2 As Integer u+jx3aP:
Dim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer $m+Pl[s
Dim PWord1 As String
Bv%dy[I
Dim ShTag As Boolean, WinTag As Boolean lfwBUb
Application.ScreenUpdating = False abEdZ)$
With ActiveWorkbook :N
xksL^
WinTag = .ProtectStructure Or .ProtectWindows `@:k*d
End With 9N) Ea:N
ShTag = False -*?{/QmKb
For Each w1 In Worksheets k9\n='OI
ShTag = ShTag Or w1.ProtectContents Nk F2'Z{$+
Next w1 REk^pZ3B
If Not ShTag And Not WinTag Then (t,|FkVLV
MsgBox MSGNOPWORDS1, vbInformation, HEADER $uK[[k~=S
Exit Sub &,]yqG 2
End If [t5D d
MsgBox MSGTAKETIME, vbInformation, HEADER |FFMQ"
If Not WinTag Then n.P $E
Else x_4{MD^%
On Error Resume Next ~%: TE}
Do 'dummy do loop ]ddL'>$c$
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66 gvP.\,U
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66 mT1Q7ta*P
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66 C$v
!emu
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126 's I @es
With ActiveWorkbook $')Uie<!8
.Unprotect Chr(i) & Chr(j) & Chr(k) & _ cavzXz
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _ %8|? YxiZ:
Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) gGbqXG^
If .ProtectStructure = False And _ -N2m|%B
.ProtectWindows = False Then e#tWQM3
PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _ 2-"`%rE
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _ lstnxi%x
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) oR<;Tr~{q
MsgBox Application.Substitute(MSGPWORDFOUND1, _ &=.7-iC|W
"$$", PWord1), vbInformation, HEADER .Na'yS `J
Exit Do 'Bypass all for...nexts GIUyW
End If :Ui'x8yt
End With ?T[K{t;~jo
Next: Next: Next: Next: Next: Next 1|3vwgRhs
Next: Next: Next: Next: Next: Next 8RVeKnpXTV
Loop Until True l-[5Zl;"
On Error GoTo 0 piPV&ytI
End If k,[[
CZ0j
If WinTag And Not ShTag Then NX<Q}3cC
MsgBox MSGONLYONE, vbInformation, HEADER yfe4}0}
Exit Sub 2|8$@*-\
End If YzAGhAyw
On Error Resume Next 7{
QjE
For Each w1 In Worksheets ery{>|k
'Attempt clearance with PWord1 d1d:5b
w1.Unprotect PWord1
:DBJ2n
Next w1 "I[uD)$
On Error GoTo 0 =,W~^<\"
ShTag = False QPsvc6ds
For Each w1 In Worksheets <d3N2
'Checks for all clear ShTag triggered to 1 if not. I%ZSh]On
ShTag = ShTag Or w1.ProtectContents =$vy_UN
Next w1 ,V=]QHcg
If ShTag Then t-J\j"~%+
For Each w1 In Worksheets iA+zZVwO
With w1 T4"*w
If .ProtectContents Then x*F_XE1#M
On Error Resume Next LGC3"z\=
Do 'Dummy do loop 6C*4' P9>
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66 7C^W <SUo
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66 A)o%\j
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66 `[.4SIah
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
C6}`qD
.Unprotect Chr(i) & Chr(j) & Chr(k) & _ (0bXsfe
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _ [~IFg~*,
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) CLY>M`%?+p
If Not .ProtectContents Then )%(H'omvl
PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _ ? `#
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _ &0@AM_b
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n) SV_b(wP9
MsgBox Application.Substitute(MSGPWORDFOUND2, _ I~U;M+n*y
"$$", PWord1), vbInformation, HEADER A ]~%<=b
'leverage finding Pword by trying on other sheets >]l7AZ:,
For Each w2 In Worksheets 4ew#@
w2.Unprotect PWord1 Vb8{OD3PK
Next w2 C Z/:(sOJ
Exit Do 'Bypass all for...nexts Zk
9 i}H
End If G!m;J8#m(
Next: Next: Next: Next: Next: Next w,zgYX&
Next: Next: Next: Next: Next: Next L)/^%/!
Loop Until True CK RnkTTiV
On Error GoTo 0 6SmawPPP
End If i@spd5.
End With ;"DI)hdz
Next w1 ?O#,|\v?]
End If $8Y|&P
MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK & ZHENGLI, vbInformation, HEADER Qx}hiv/
End Sub tY$4k26