vb程序中怎么解开压缩包,vb中怎么打开文件

首页 > 实用技巧 > 作者:YD1662024-01-08 20:48:07

(1)xls文档破解方法

打开Excel文档,按Alt F11进入“开发工具”界面,在左边的工程栏(Project)中选定节点“ThisWorkbook”,双击左键,然后把下面的代码复制到右边的代码编辑框中。然后按F5键执行代码开始破解,破解期间会出现两次提示的对话框,都选择“确认”。密码破解完毕之后会出现提示“该工作簿中的工作表密码保护已被全部解除”,这说明工作表或工作簿的保护密码已被成功清除。最后删除“ThisWorkbook”节点中的代码,保存工作表。至此,破解完成。

Public Sub 工作表保护密码破解()

Const DBLSPACE As String = vbNewLine & vbNewLine

Const AUTHORS As String = DBLSPACE & vbNewLine & _

"作者:McCormick JE McGimpsey "

Const HEADER As String = "工作表保护密码破解"

Const VERSION As String = DBLSPACE & "版本 Version 1.1.1"

Const REPBACK As String = DBLSPACE & ""

Const ZHENGLI As String = DBLSPACE & ""

Const ALLCLEAR As String = DBLSPACE & "该工作簿中的工作表密码保护已全部解除!!" & DBLSPACE & "请记得另保存" _

& DBLSPACE & "注意:不要用在不当地方,要尊重他人的劳动成果!"

Const MSGNOPWORDS1 As String = "该文件工作表中没有加密"

Const MSGNOPWORDS2 As String = "该文件工作表中没有加密2"

Const MsgTAKETIME As String = "解密需花费一定时间,请耐心等候!" & DBLSPACE & "按确定开始破解!"

Const MSGPWORDFOUND1 As String = "密码重新组合为:" & DBLSPACE & "$$" & DBLSPACE & _

"如果该文件工作表有不同密码,将搜索下一组密码并修改清除"

Const MSGPWORDFOUND2 As String = "密码重新组合为:" & DBLSPACE & "$$" & DBLSPACE & _

"如果该文件工作表有不同密码,将搜索下一组密码并解除"

Const MSGONLYONE As String = "确保为唯一的?"

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

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 & ZHENGLI, vbInformation, HEADER

End Sub

(2)Xlsx文档破解方法

Xlsx文档本质上其实是一个压缩包,里面包含了许多xml文档,工作表、工作簿的保护密码就保存在这些xml文档中,我们可以直接修改内容,就可以去掉工作表、工作簿的保护密码了。

具体方法如下:

将文档扩展名修改为rar然后用压缩软件打开。

在打开的文件中找到“xl”文件夹,双击进入,“workbook.xml”中即包含工作簿的保护密码,将此文件复制出来,用记事本打开该文档,搜索“workbookProtection”,将带有“workbookProtection”的那一段代码删除,然后在压缩文件中替换原文件。代码格式如:

<workbookProtection workbookAlgorithmName="SHA-512" workbookHashValue="******" workbookSaltValue="******" workbookSpinCount="100000" lockStructure="1"/>

另外,“xl\worksheets”文件夹下的“sheet1.xml”、“sheet2.xml”中则保存了各工作表的密码,同样将“sheet1.xml”、“sheet2.xml”复制出来,用记事本打开,搜索“sheetProtection”,将带有“sheetProtection”的那一段代码删除,然后在压缩文件中替换原文件。

代码格式如:

<sheetProtection algorithmName="SHA-512" hashValue="******" saltValue="******" spinCount="100000" sheet="1" formatCells="0" formatColumns="0" formatRows="0" insertColumns="0" insertRows="0" insertHyperlinks="0" deleteColumns="0" deleteRows="0" sort="0" autoFilter="0" pivotTables="0"/>

最后保存文件,然后把这个压缩包的后缀重新修改回xlsx。至此,破解完成。

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.