我正在尝试构建一个小型CommandoLine-app,该应用程序可以暴力破解加密Zip的密码。我的方法是生成密码,然后使用CheckZipPassword()尝试密码。但是我收到此错误:
Unhandled Exception: Ionic.Zlib.ZlibException: Bad state (invalid distance code)
at Ionic.Zlib.InflateManager.Inflate(FlushType flush)
at Ionic.Zlib.ZlibCodec.Inflate(FlushType flush)
at Ionic.Zlib.ZlibBaseStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Ionic.Zlib.DeflateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Ionic.Crc.CrcCalculatorStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Ionic.Zip.ZipEntry.ExtractAndCrc(Stream archiveStream, Stream targetOutput, Int16 compressionMethod, Int64 compressedFileDataSize, Int64 uncompressedSize)
at Ionic.Zip.ZipEntry.ExtractToStream(Stream archiveStream, Stream output, EncryptionAlgorithm encryptionAlgorithm, Int32 expectedCrc32)
at Ionic.Zip.ZipEntry.InternalExtractToStream(Stream outStream, String password, ZipContainer zipContainer, ZipEntrySource zipEntrySource, String fileName)
at Ionic.Zip.ZipFile.CheckZipPassword(String zipFileName, String password)
at SuperZipCracker.Program.Main(String[] args) in C:\..\Program.cs:line 54
这是我检查密码的代码:
for (int j = 0; j < 100; j++)
{
var pwString = pw.GenerateString();
Console.Write($"{pwString}\n");
var bingo = ZipFile.CheckZipPassword(pathFdf, pwString);
if (bingo != false)
{
finalPassword = pwString;
}
}
第54行是“ var bingo ...”。
如果我运行此循环少于93次,则终止。但是在j <93时,它会以显示的异常崩溃,并且总是在同一位置。在该循环中测试的密码为“ cde”。我不知道此值是否与此有关,可能会误导我自己。
这是密码生成器,基本上是答案here中的这个密码生成器。
我在做什么错了?