我正在逆向某种协议,看起来它正在使用 zlib 压缩,当前数据包是:
170300002009254CBCE1DC7A5578D1588577EF63AE8DDCA721FFCA453775BCA7375CB65EE31703000090AA883A355CB9A7450EA7BA8D485C655EB5FCB71E22F274E9FF03F326296E7F2D5960AB7CFB2986C4985D6B7D33BE2C7348142D738B522C3B89AA3723A5CADB9C3DF124B3AB405E0513766384D3C0C6C11395D51E317F1DF342F3731D498C84EE0BE9172C130A89C7EE287560E64337E4A0D49A211E40F846DBAF019ADEF2F2F601A145C1F587C792CF3C2EE1CEE558031703000020259BAFBADABE5B22360C727D6E2494C41542FC3E14EEE3B5317C13F06044BB77170300005012E5BF7E631E9E3C5F0D133890808281A769C3AEC50ACF8BB0FBF39CAEC0E2EA75C09BAD7A3F22A15DC2B5C3751561DB3219164AB80E55A7DB141F5F6FAB4DE9189CC145C47E49D741075DDAA6EFD2A6
如果我们看一下 rfc1950,我们会看到格式的规范,在我的脚本(php)中,我提取 zlib 相关信息上面的数据包:
compression method : 1
compression info : 7
------------------------------
flag check : 0
flag dict : 0
flag level : 3
但是我找不到解压缩十六进制数据的方法,即使我使用 pack('H*',$data)
将其转换为二进制字符串,它仍然会给出有关错误的错误数据。
是否可以使用命令行程序并向其提供上述十六进制数据,其中命令行实用程序以十六进制形式返回未压缩的字符串。
I am reversing some kind of protocol and it looks like it is using zlib compression, the current packet is :
170300002009254CBCE1DC7A5578D1588577EF63AE8DDCA721FFCA453775BCA7375CB65EE31703000090AA883A355CB9A7450EA7BA8D485C655EB5FCB71E22F274E9FF03F326296E7F2D5960AB7CFB2986C4985D6B7D33BE2C7348142D738B522C3B89AA3723A5CADB9C3DF124B3AB405E0513766384D3C0C6C11395D51E317F1DF342F3731D498C84EE0BE9172C130A89C7EE287560E64337E4A0D49A211E40F846DBAF019ADEF2F2F601A145C1F587C792CF3C2EE1CEE558031703000020259BAFBADABE5B22360C727D6E2494C41542FC3E14EEE3B5317C13F06044BB77170300005012E5BF7E631E9E3C5F0D133890808281A769C3AEC50ACF8BB0FBF39CAEC0E2EA75C09BAD7A3F22A15DC2B5C3751561DB3219164AB80E55A7DB141F5F6FAB4DE9189CC145C47E49D741075DDAA6EFD2A6
If we take a look at rfc1950 we see the specifications of the format, in my script (php) i extract the zlib related info for the above packet :
compression method : 1
compression info : 7
------------------------------
flag check : 0
flag dict : 0
flag level : 3
However I cannot find a way to uncompress the hex data, even if I convert it to a binary string with pack('H*',$data)
it still gives an error about wrong data.
Is it possible to use a commandline program and feed it with the above hex data where the commandline utility returns the uncompressed string in HEX.
发布评论
评论(1)
这是一个用于解压缩 zlib 流的 python 脚本:
https://web.archive.org/web/20130305133247/http://blog.2of1.org/2011/03/03/decompressing-zlib-images/
..但是您的数据未经过 zlib 压缩。
粗略地看一下,您的数据被 4 字节标记“17 03 00 00”清楚地划分,后面跟着一个指示该段大小的长度字节。
所以这里的长度是:
这与标记位置正确对应。
我可以花一些时间来扭转这个局面,但我认为这应该足以让你回到正确的道路。
希望这有帮助。
Here's a python script for decompressing zlib streams:
https://web.archive.org/web/20130305133247/http://blog.2of1.org/2011/03/03/decompressing-zlib-images/
.. but your data is not zlib compressed.
Cursory look shows that your data is cleanly divided by a 4 byte marker "17 03 00 00" followed by a length byte indicating size of that segment.
So lengths here are:
And this corresponds correctly with marker positions.
I could spend a while to reverse this, but I think this should be enough to bring you back to correct path.
Hope this helps.