Unable to unzip ZLIB / DEFLATE data

I am trying to extract data from compressed bytes from a network capture file (PCAP.)

The data from some of these packages does not have a ZLIB header (the first 2 bytes, where the lower 4 bits of the first byte are always 8) and therefore gave an exception when I tried to unpack it using ZlibStream. Header data seems to be working fine.

As I understand it, ZLIB is just the header and footer above DEFLATE, I pass this data without headers to DeflateStream. This time it DeflateStreamdoes not produce any error, it just gave the wrong data (but gave the correct length) ...

This is sample data. The C # code example uses DotNetZip:

byte[] test3 = new byte[] { 0x1a, 0x6d, 0xf, 0x8d, 0xb6, 0x87, 0x46, 0xdb, 0x43, 0xa3, 0xed, 0xa1, 0xd1, 
                0xf6, 0xd0, 0x68, 0x7b, 0x68, 0xb4, 0x3d, 0x34, 0xda, 0x1e, 0xb2, 0x44, 0x3a, 0x39, 0x6f, 0x24, 
                0xae, 0x1f, 0x2, 0x0, 0x0, 0x0, 0xff, 0xff };


static void UncompressData(byte[] data)
{
    if ((data[0] & 0x0F) != 0x08)
    {        
        var uncompressed = DeflateStream.UncompressBuffer(data);
        Console.WriteLine("Uncompressed Deflate data : {0} => {1} bytes", data.Length, uncompressed.Length);
    }
    else
    {
        var uncompressed = ZlibStream.UncompressBuffer(data);
        Console.WriteLine("Uncompressed ZLIB data : {0} => {1} bytes", data.Length, uncompressed.Length);
    }
}

# System.IO.Compression.DeflateStream, Ionic.Zlib.DeflateStream ( DotNetZip) Java java.util.zip.Inflater. , 0s..

, ? , ZLIB/DEFLATE ?

.

+3
1

, "", .

zlib . , , , , . () "".

+2

All Articles