猜测配置以使ZLIB压缩数据充气

发布于 2025-02-07 07:01:51 字数 929 浏览 5 评论 0原文

我想充气ZLIB压缩数据。我在Python中尝试了以下内容:

zlib.decompress(data)

- >它返回以下错误:Zlib.Error:Decompressress数据时错误-3:数据检查不正确,

因此我找到了一种忽略数据检查的方法:

def decompress_corrupted(data):
    d = zlib.decompressobj(zlib.MAX_WBITS | 32)
    f = BytesIO(data)
    result_str = b''
    buffer = f.read(1)
    try:
        while buffer:
            result_str += d.decompress(buffer)
            buffer = f.read(1)
    except zlib.error:
        pass
    return result_str

但是所产生的结果部分“损坏”:我得到了一个.rtf内容,而错误很少。

我的问题:由于我知道压缩使用Zlib算法,所以我可以尝试获取原始文档的配置零件(或预/后处理)?

上下文:用于压缩这些文件的解决方案不再是编辑的,编辑器从未回答我们的消息。我们只有一个编译的观众,但需要确切的算法才能迁移到替代解决方案。我们知道这些文件没有损坏,因为当前的查看器能够正确显示它们。

如果可以提供帮助:

  • 这是数据的负责人:789C 95 54 5d 6f D3 30 14 ...
  • 和尾巴:.. 79 AE C5 E2 E2 17 82 5E 3F 85

I want to inflate a zlib compressed data. I've tried the following in python:

zlib.decompress(data)

-> it return the following error: zlib.error: Error -3 while decompressing data: incorrect data check

So I found a way to ignore data check:

def decompress_corrupted(data):
    d = zlib.decompressobj(zlib.MAX_WBITS | 32)
    f = BytesIO(data)
    result_str = b''
    buffer = f.read(1)
    try:
        while buffer:
            result_str += d.decompress(buffer)
            buffer = f.read(1)
    except zlib.error:
        pass
    return result_str

But the result produced is partially "corrupted": I get a .rtf content with few mistakes.

My question: since I know that the compression uses zlib algorithm, what are the configurations parts (or pre/post-processes) I could try to get the original document?

Context: the solution used to compress these files is no more edited and the editor has never answered our messages. We only possess a compiled viewer but need the exact algorithm to make a migration to alternative solution. We know these files are not corrupted since the current viewer is able to display them properly.

If it can help:

  • here is the head of the data: 789C 95 54 5D 6F D3 30 14 ...
  • and the tail: .. 79 AE C5 E2 17 82 5E 3F 85

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

メ斷腸人バ 2025-02-14 07:01:51

无需“配置”。 Zlib的膨胀将使任何有效的压缩Zlib流无效地膨胀到原始内容。

因此,尽管您证明了您的数据,但您的数据在此过程中的某个地方正在损坏或故意修改。

There are no "configurations" needed. zlib's inflate will inflate any valid compressed zlib stream losslessly to the original content.

Therefore, despite your attestation, your data is getting corrupted or deliberately modified somewhere along the way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文