Ok, so I've got an Open Source Java client/server program that uses packets to communicate. I'm trying to write a python client for said program, but the contents of the packet seem to be compressed. A quick perusal through the source code suggested gzip as the compression schema (since that was the only compression module imported in the code that I could find), but when I saved the data from one of the packets out of wireshark and tried to do
import gzip
f = gzip.open('compressed_file')
f.read()
It told me that this wasn't a gzip file because the header was wrong. Can someone advise me what I've done wrong here? Did I change or mess up the format when I saved it out? Do I need to strip away some of the extraneous data from the packet before I try running this block on it?
if (zipped) {
// XML encode the data and GZIP it.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer zipOut = new BufferedWriter(new OutputStreamWriter(
new GZIPOutputStream(baos)));
PacketEncoder.encodeData(packet, zipOut);
zipOut.close();
// Base64 encode the commpressed data.
// Please note, I couldn't get anything other than a
// straight stream-to-stream encoding to work.
byte[] zipData = baos.toByteArray();
ByteArrayOutputStream base64 = new ByteArrayOutputStream(
(4 * zipData.length + 2) / 3);
Base64.encode(new ByteArrayInputStream(zipData), base64, false);
EDIT: Ok, sorry I have the information requested here. This was gathered using Wireshark to listen in on communication between two running copies of the original program on different computers. To get the hex stream below, I used the "Copy -> Hex (Byte Stream)" option in Wireshark.
001321cdc68ff4ce46e4f00d0800450000832a85400080061e51ac102cceac102cb004f8092a9909b32c10e81cb25018f734823e00000100000000000000521f8b08000000000000005bf39681b59c85818121a0b4884138da272bb12c512f27312f5dcf3f292b35b9c47ac2b988f902c59a394c0c0c150540758c250c5c2ea5b9b9950a2e89258900aa4c201a3f000000
I know this will contain the string "Dummy Data" in it. I believe it should also contain "Jonathanb" (the player name I used to send the message) and the integer 80 (80 is the command # for "Chat" as far as I can gather from the code).