VBA Script to Remove Protected Excel Files


Excel spreadsheets can be protected using password, for example, example excel with password protection.

Open this, and any modification or viewing the VBA script/macro requires unprotecting the sheet first.

excel-protected VBA Script to Remove Protected Excel Files excel security tricks VBA

excel-protected requires password

Now, go to View tab and click the Macros to edit the functions of VBA in editor:

break-excel-macros VBA Script to Remove Protected Excel Files excel security tricks VBA

create macros

Copy and paste the following VBA function (hit F5 to run) that bruteforces searching the possible valid password combination:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Sub GetSomeNiceSuglarForExcel()
    ' Brute force all possibilities
    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
        Dim pw: pw = Chr(i) & Chr(j) & _
            Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
            Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
        InputBox "One usable password is", pw, pw
        Exit Sub
    End If
    Next: Next: Next: Next: Next: Next
    Next: Next: Next: Next: Next: Next
End Sub
Sub GetSomeNiceSuglarForExcel()
    ' Brute force all possibilities
    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
        Dim pw: pw = Chr(i) & Chr(j) & _
            Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
            Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
        InputBox "One usable password is", pw, pw
        Exit Sub
    End If
    Next: Next: Next: Next: Next: Next
    Next: Next: Next: Next: Next: Next
End Sub
break-excel-vba-macro-brute-force VBA Script to Remove Protected Excel Files excel security tricks VBA

VBA script to hack the password using bruteforce algorithm

And this should give you the password that allows you to copy and paste.

excel-protected-showing-password VBA Script to Remove Protected Excel Files excel security tricks VBA

excel-protected-showing-password

The principle is to use brute-force search, as nowadays, the PCs (hardware) are fast, it should be fairly easy to get some answers using the script above.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
490 words
Last Post: Better SQL Insert Syntax
Next Post: Creating Sitemap Generator for PHPBB3.1 using PHP

The Permanent URL is: VBA Script to Remove Protected Excel Files

Leave a Reply