0% found this document useful (0 votes)
78 views

VBA Code

This document provides instructions to break password protection on a Microsoft Excel worksheet using VBA macros. It involves the following steps: 1. Creating a test file with a simple password and extracting the encrypted project binary file. 2. Copying the encrypted password value (DPB parameter) from this file. 3. Opening the target protected file and replacing its encrypted DPB value with the one from the test file. 4. Saving the modified binary file back to the target file, which will now be unprotected using the test password.

Uploaded by

EngrFaisal
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

VBA Code

This document provides instructions to break password protection on a Microsoft Excel worksheet using VBA macros. It involves the following steps: 1. Creating a test file with a simple password and extracting the encrypted project binary file. 2. Copying the encrypted password value (DPB parameter) from this file. 3. Opening the target protected file and replacing its encrypted DPB value with the one from the test file. 4. Saving the modified binary file back to the target file, which will now be unprotected using the test password.

Uploaded by

EngrFaisal
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

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

1. Create a new .xlsm file.


2. In the VBA part, set a simple password (for instance 'macro').
3. Save the file and exit.
4. Change file extention to '.zip', open it by any archiver program.
5. Find the file: 'vbaProject.bin' (in 'xl' folder).
6. Extract it from archive.
7. Open the file you just extracted with a hex editor (for example HxD).
8. Find and copy the value from parameter DPB (value in quotation mark), example:

DPB="282A84CBA1CBA1345FCCB154E20721DE77F7D2378D0EAC90427A22021A46E9CE6F17188A".
(This value generated for 'macro' password. You can use this DPB value to skip
steps 1-8)

9. Do steps 4-7 for file with unknown password (file you want to unlock).
10. Change DBP value in this file on value that you have copied in step 8.
>>If copied value is shorter than in encrypted file you should populate missing
characters with 0 (zero). If value is longer - that is not a problem (paste as it
is).

11. Save the 'vbaProject.bin' file and exit from hex editor.
12. Replace existing 'vbaProject.bin' file with modified one.
13. Change extention from '.zip' back to '.xlsm'
14. Now, open the excel file you need to see the VBA code in. The password for the
VBA code
will simply be macro (as in the example I'm showing here).

You might also like