Use simple code to crack the Excel password protection

Source: Internet
Author: User

1. Open an encrypted EXCEL File
2 tool --- macro ---- recording new macro --- input name such as aa
3. Stop recording (an empty macro is obtained)
4 tools --- macro ---- macro. Select aa and click Edit.
5. Delete All characters (only a few characters) in the window and replace them with the following code.
6. Close the editing window.
7 Tools --- macro ----- macro, select AllInternalPasswords, run, OK twice !!!
It will take 2 minutes to complete the process (using the written code for background computing). After that, you will be prompted to confirm.
Last save

Code written with VB
Code
Public Sub AllInternalPasswords ()
'Breaks worksheet and workbook structure passwords. Bob McCormick
'Bably originator of base code algorithm modified for coverage
'Of workbook structure/windows passwords and for multiple passwords
'
'Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)
'Modified 2003-Apr-04 by JEM: All msgs to constants, and
'Eliminate one Exit Sub (Version 1.1.1)
'Reveals hashed passwords NOT original passwords
Const DBLSPACE As String = vbNewLine & vbNewLine
Const AUTHORS As String = DBLSPACE & vbNewLine &_
"Adapted from Bob McCormick base code "&_
"Norman Harker and JE McGimpsey"
Const HEADER As String = "AllInternalPasswords User Message"
Const VERSION As String = DBLSPACE & "Version 1.1.1 2003-Apr-04"
Const REPBACK As String = DBLSPACE & "Please report failure "&_
"To the microsoft. public. excel. programming newsgroup ."
Const ALLCLEAR As String = DBLSPACE & "The workbook shocould "&_
"Now be free of all password protection, so make sure you :"&_
DBLSPACE & "save it now! "& DBLSPACE &" and also "&_
DBLSPACE & "BACKUP !, BACKUP !!, BACKUP !!! "&_
DBLSPACE & "Also, remember that the password was "&_
"Put there for a reason. Don't stuff up crucial formulas "&_
"Or data." & DBLSPACE & "Access and use of some data "&_
"May be an offense. If in doubt, don't ."
Const MSGNOPWORDS1 As String = "There were no passwords on "&_
"Sheets, or workbook structure or windows." & AUTHORS & VERSION
Const MSGNOPWORDS2 As String = "There was no protection "&_
"Workbook structure or windows." & DBLSPACE &_
"Proceeding to unprotect sheets." & AUTHORS & VERSION
Const MSGTAKETIME As String = "After pressing OK button this "&_
"Will take some time." & DBLSPACE & "Amount of time "&_
"Depends on how many different passwords, "&_
"Passwords, and your computer's specification." & DBLSPACE &_
"Just be patient! Make me a coffee! "& AUTHORS & VERSION
Const MSGPWORDFOUND1 As String = "You had a Worksheet "&_
"Structure or Windows Password set." & DBLSPACE &_
"The password found was:" & DBLSPACE & "$" & DBLSPACE &_
"Note it down for potential future use in other workbooks "&_
"The same person who set this password." & DBLSPACE &_
"Now to check and clear other passwords." & AUTHORS & VERSION
Const MSGPWORDFOUND2 As String = "You had a Worksheet "&_
"Password set." & DBLSPACE & "The password found was :"&_
DBLSPACE & "$" & DBLSPACE & "Note it down for potential "&_
"Future use in other workbooks by same person who "&_
"Set this password." & DBLSPACE & "Now to check and clear "&_
"Other passwords." & AUTHORS & VERSION
Const MSGONLYONE As String = "Only structure/windows "&_
"Protected with the password that was just found ."&_
ALLCLEAR & AUTHORS & VERSION & REPBACK
Dim w1 As Worksheet, w2 As Worksheet
Dim I As Integer, j As Integer, k As Integer, l As Integer
Dim m As Integer, n As Integer, i1 As Integer, i2 As Integer
Dim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer
Dim PWord1 As String
Dim ShTag As Boolean, WinTag As Boolean
Application. ScreenUpdating = False
With ActiveWorkbook
WinTag =. ProtectStructure Or. ProtectWindows
End
ShTag = False
For Each w1 In Worksheets
ShTag = ShTag Or w1.ProtectContents
Next w1
If Not ShTag And Not WinTag Then
MsgBox MSGNOPWORDS1, vbInformation, HEADER
Exit Sub
End If
MsgBox MSGTAKETIME, vbInformation, HEADER
If Not WinTag Then
MsgBox MSGNOPWORDS2, vbInformation, HEADER
Else
On Error Resume Next
Do 'dummy do loop
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.
With ActiveWorkbook
. 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. ProtectStructure = False And _
. ProtectWindows = False Then
PWord1 = Chr (I) & Chr (j) & Chr (k) & Chr (l )&_
Chr (m) & Chr (i1) & Chr (i2) & Chr (i3 )&_
Chr (i4) & Chr (i5) & Chr (i6) & Chr (n)
MsgBox Application. Substitute (MSGPWORDFOUND1 ,_
"$", PWord1), vbInformation, HEADER
Exit Do 'Bypass all for... nexts
End If
End
Next: Next
Next: Next
Loop Until True
On Error GoTo 0
End If
If WinTag And Not ShTag Then
MsgBox MSGONLYONE, vbInformation, HEADER
Exit Sub
End If
On Error Resume Next
For Each w1 In Worksheets
'Attempt clearance with PWord1
W1.Unprotect PWord1
Next w1
On Error GoTo 0
ShTag = False
For Each w1 In Worksheets
'Checks for all clear ShTag triggered to 1 if not.
ShTag = ShTag Or w1.ProtectContents
Next w1
If ShTag Then
For Each w1 In Worksheets
With w1
If. ProtectContents Then
On Error Resume Next
Do 'dummy do loop
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.
. 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 Not. ProtectContents Then
PWord1 = Chr (I) & Chr (j) & Chr (k) & Chr (l )&_
Chr (m) & Chr (i1) & Chr (i2) & Chr (i3 )&_
Chr (i4) & Chr (i5) & Chr (i6) & Chr (n)
MsgBox Application. Substitute (MSGPWORDFOUND2 ,_
"$", PWord1), vbInformation, HEADER
'Leverage finding Pword by trying on other sheets
For Each w2 In Worksheets
W2.Unprotect PWord1
Next w2
Exit Do 'Bypass all for... nexts
End If
Next: Next
Next: Next
Loop Until True
On Error GoTo 0
End If
End
Next w1
End If
MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.