Imports Ionic.Zip
Imports System.IO
Imports System.Threading
Module Module1
Sub Main()
' 设置 zip 文件的路径
Dim zipPath As String = "C:\Users\Administrator\Desktop\1\1.zip"
' 读取密码字典文件
Dim passwordDictPath As String = "C:\Users\Administrator\Desktop\1\mm.txt"
Dim passwords() As String = File.ReadAllLines(passwordDictPath)
' 定义一个布尔变量来标识解压是否成功
Dim isExtractSuccessful As Boolean = False
For Each password As String In passwords
Try
Using zip As ZipFile = ZipFile.Read(zipPath)
zip.Password = password
Console.WriteLine("正在尝试密码:" & password)
Thread.Sleep(1000) ' 延时 1 秒,可根据需要调整时长
zip.ExtractAll("C:\Users\Administrator\Desktop\1\新建文件夹\", ExtractExistingFileAction.OverwriteSilently)
isExtractSuccessful = True
Console.WriteLine("文件解压缩成功,密码正确,密码为:" & password)
Exit For ' 找到密码后退出循环
End Using
Catch ex As Exception
' 忽略错误,继续尝试下一个密码
End Try
Next
If Not isExtractSuccessful Then
Console.WriteLine("所有密码尝试完毕,未找到正确密码。")
End If
Console.ReadLine()
End Sub
End Module