Clyme February 2016

Java/Minecraft - How to read/understand packets

I have written a Packet Sniffer in Java and it works perfect but now I have a text file with integers and I dont know how to decode them. I already tried to use this : Minecraft Protocol, but I still can't decode the packets...

Output:

[Client] 15
[Client] 0
[Client] 47
[Client] 9
[Client] 108
[Client] 111
[Client] 99
[Client] 97
[Client] 108
[Client] 104
[Client] 111
[Client] 115
[Client] 116
[Client] 30
[Client] 97
[Client] 1
[Client] 1
[Client] 0


[Server] 118
[Server] 0
[Server] 116
[Server] 123
[Server] 34
[Server] 100
[Server] 101
[Server] 115
[Server] 99
[Server] 114
[Server] 105
[Server] 112
[Server] 116
[Server] 105
[Server] 111
[Server] 110
[Server] 34
[Server] 58
[Server] 34
[Server] 65
[Server] 32
[Server] 77
[Server] 105
[Server] 110
[Server] 101
[Server] 99
[Server] 114
[Server] 97
[Server] 102
[Server] 116
[Server] 32
[Server] 83
[Server] 101
[Server] 114
[Server] 118
[Server] 101
[Server] 114
[Server] 34
[Server] 44
[Server] 34
[Server] 112
[Server] 108
[Server] 97
[Server] 121
[Server] 101
[Server] 114
[Server] 115
[Server] 34
[Server] 58
[Server] 123
[Server] 34
[Server] 109
[Server] 97
[Server] 120
[Server] 34
[Server] 58
[Server] 50
[Server] 48
[Server] 44
[Server] 34
[Server] 111
[Server] 110
[Server] 108
[Server] 105
[Server] 110
[Server] 101
[Server] 34
[Server] 58
[Server] 48
[Server] 125
[Server] 44
[Server] 34
[Server] 118
[Server] 101
[Server] 114
[Server] 115
[Server] 105
[Server] 111
[Server] 110
[Server] 34
[Server] 58
[Server] 123
[Server] 34
[Server] 110
[Server] 97
[Server] 109
[Server] 101
[Server] 34
[Server] 58
[Server] 34
[Server] 83
[Server] 112
[Server] 105
[Server] 103
[Server] 111
[Server] 116
[Server] 32
[Server] 49
[Server] 46
[Server] 56
[Server] 46
[Server] 55
[Server] 34
[Server] 44
[Server] 34
[Server] 112
[Server] 114
[Server] 111
[Server] 116
[Server] 111
[Server] 99
[Server] 111
[Server] 108
[Server] 34
[Server] 58
[Server] 52
[Server] 5        

Answers


jpou February 2016

It seems that no integer is higher than 255, so this is a single byte per line output. The packet that you are seeing might be compressed, but it is impossible to say without seeing the configuration of your Minecraft user/server. If they are actually compressed - you will need to unzip them before you will be able to analyze them.

To help you with decoding, I highly recommend Wireshark. Download it and re-run your network capture. Then compare the decoded output with that of your program. Wireshark will give the meaning of each data member in a packet.

EDIT: What part of decoding is unclear for you? Using pen and paper and windows calculator in programming mode here is the decoding of first packet:

15 - Varint - length of the packet
0  - Varint - packet ID - Handshake
47 - VarInt - protocol version
     Following bytes are length prefixed server address in UTF-8:
9  - Lenght
108 - l
111 - o
99  - c
97  - a
108 - l
104 - h
111 - o
115 - s
116 - t
     Following 2 bytes are server port in unsigned short format (I guess 7777)
30
97

1  - Varint - Next state

Last 2 bytes are unclear to me.

In short - for each packet:

  1. Find length of the packet
  2. Find the packet type
  3. Using packet type decode the rest

Post Status

Asked in February 2016
Viewed 2,338 times
Voted 13
Answered 1 times

Search




Leave an answer