乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > 如何破解Excel VBA密码-excel2010 vba加密,excelvba代码加密

如何破解Excel VBA密码-excel2010 vba加密,excelvba代码加密

作者:乔山办公网日期:

返回目录:excel表格制作


VBA是脚本语言,可直接看到代码(VB的语法),所以需要你对VB这种编程语言有一定的了解。或者贴出来让大家帮你看看

Excel是一个专门用于整理数据的电子表格,为了保障表格的安全,用户可以为文档进行加密,可以设置以下类型密码:打开密码、编辑密码、工作表密码、共享账簿密码以及VBA密码。VBA全称是VisualBasicforApplications,是微软开发出来在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。VBA是VisualBasic的一种宏语言,主要能用来扩展Windows的应用程式功能,特别是MicrosoftOffice软件,特别是Excel表格。另外,也可说VBA是一种应用程式视觉化的Basic脚本。实际上VBA是寄生于VB应用程序的版本,可以具备VBA的宏功能。VBA密码就是为变成语言设置访问权限。破解VBA密码有两种方法:1、使用宏代码,这种方法比较专业,不具有普遍的适用性;2、使用专业的第三方密码破解工具,这个可以广泛被使用,传播比较广泛的是AdvancedOfficePasswordRecovery,使用软件打开Excel文档,程序会自动开始破解VBA密码的操作,一旦破解成功,用户可以更改Excel文档的VBA密码,重新获取权限。

关于破解EXCEL VBA工程密码的方法,以下代码非常有效,首先建一新EXCEL文件,在工作表标签处右点>>查看代码>>复制以下代码>>按F8执行在弹出窗中选你要你破解工程密码的EXCEL文件 >>再按F5执行即可.

 

Private Sub VBAPassword()
'你要解保护的Excel文件路径
Filename =Application.GetOpenFilename("Excel文件(*.xls & *.xla & *.xlt),*.xls;*.xla;*.xlt", , "VBA破解")
If Dir(Filename) = "" Then
MsgBox "没找到相关文件,清重新e79fa5e98193e78988e69d83333设置。"
Exit Sub
Else
FileCopy Filename, Filename &".bak" '备份文件。
End If
Dim GetData As String * 5
Open Filename For Binary As #1
Dim CMGs As Long
Dim DPBo As Long
For i = 1 To LOF(1)
Get #1, i, GetData
If GetData = "CMG="""Then CMGs = i
If GetData = "[Host" Then DPBo =i - 2: Exit For
Next
If CMGs = 0 Then
MsgBox "请先对VBA编码设置一个保护密码...", 32,"提示"
Exit Sub
End If
If Protect = False Then
Dim St As String * 2
Dim s20 As String * 1
'取得一个0D0A十六进制字串
Get #1, CMGs - 2, St
'取得一个20十六制字串
Get #1, DPBo + 16, s20
'替换加密部份机码
For i = CMGs To DPBo Step 2
Put #1, i, St
Next
'加入不配对符号
If (DPBo - CMGs) Mod 2 <> 0 Then
Put #1, DPBo + 1, s20
End If
MsgBox "文件解密成功......", 32, "提示"
End If
Close #1
End Su

如果上面代码不能运行或出错,请用以下代码重试.

Private Sub VBAPassword()
'你要解保护的Excel文件路径
Filename =Application.GetOpenFilename("Excel文件(*.xls & *.xla & *.xlt),*.xls;*.xla;*.xlt", , "VBA破解")
If Dir(Filename) = "" Then
MsgBox "没找到相关文件,清重新设置。"
Exit Sub
Else
FileCopy Filename, Filename &".bak" '备份文件。
End If
Dim GetData As String * 5
Open Filename For Binary As #1
Dim CMGs As Long
Dim DPBo As Long
For i = 1 To LOF(1)
Get #1, i, GetData
If GetData = "CMG="""Then CMGs = i
If GetData = "[Host" Then DPBo =i - 2: Exit For
Next
If CMGs = 0 Then
MsgBox "请先对VBA编码设置一个保护密码...", 32,"提示"
Exit Sub
End If
 
Dim St As String * 2
Dim s20 As String * 1
'取得一个0D0A十六进制字串
Get #1, CMGs - 2, St
'取得一个20十六制字串
Get #1, DPBo + 16, s20
'替换加密部份机码
For i = CMGs To DPBo Step 2
Put #1, i, St
Next
'加入不配对符号
If (DPBo - CMGs) Mod 2 <> 0 Then
Put #1, DPBo + 1, s20
End If
MsgBox "文件解密成功......", 32, "提示"
Close #1
End Sub


首先,尝试打开工作簿时,提示有密码:
  7a686964616fe58685e5aeb9361使用快捷键Ctrl+F11键,打开VBA编辑界面,点击“插入”菜单下的子菜单“模块”:
  在模块编辑器中输入以下代码:
  Option Explicit
  Public Sub AllInternalPasswords()
  Const DBLSPACE As String = vbNewLine & vbNewLine
  Const AUTHORS As String = DBLSPACE & vbNewLine & _
  "Adapted from Bob McCormick base code by" & _
  "Norman Harker and JE MCGImpsey"
  Const HEADER As String = "AllInternalPasswords User Message"
  Const VERSION As String = DBLSPACE
  Const REPBACK As String = DBLSPACE & "Please report failure " & _
  "to the microsoft.public.Excel.programming newsgroup."
  Const ALLCLEAR As String = DBLSPACE & "The workbook should " & _
  "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 to " & _
  "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, the " & _
  "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 by " & _
  "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 With
  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 With
  Next: Next: Next: Next: Next: Next
  Next: Next: 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: Next: Next
  Next: Next: Next: Next: Next: Next
  Loop Until True
  On Error GoTo 0
  End If
  End With
  Next w1
  End If
  MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
  End Sub
  点击运行:
  破解过程需要几分钟,有几次对话框弹出,都是英文的,留意对话框中如下内容:
  标注部分即为密码。虽然不是原始密码,但是用这个密码照样可以打开工作簿的。

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网