2 * Routines for Kerberos v4 packet dissection
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * PDU structure based on the document :
28 * Kerberos Authentication and Authorization System
30 * by S. P. Miller, B. C. Neuman, J. I. Schiller, and J. H. Saltzer
37 #include <epan/packet.h>
39 void proto_register_krb4(void);
40 void proto_reg_handoff_krb4(void);
42 static int proto_krb4 = -1;
43 static int hf_krb4_version = -1;
44 static int hf_krb4_auth_msg_type = -1;
45 static int hf_krb4_m_type = -1;
46 static int hf_krb4_byte_order = -1;
47 static int hf_krb4_name = -1;
48 static int hf_krb4_instance = -1;
49 static int hf_krb4_realm = -1;
50 static int hf_krb4_time_sec = -1;
51 static int hf_krb4_exp_date = -1;
52 static int hf_krb4_req_date = -1;
53 static int hf_krb4_lifetime = -1;
54 static int hf_krb4_s_name = -1;
55 static int hf_krb4_s_instance = -1;
56 static int hf_krb4_kvno = -1;
57 static int hf_krb4_length = -1;
58 static int hf_krb4_ticket_length = -1;
59 static int hf_krb4_request_length = -1;
60 static int hf_krb4_ticket_blob = -1;
61 static int hf_krb4_request_blob = -1;
62 static int hf_krb4_encrypted_blob = -1;
63 static int hf_krb4_unknown_transarc_blob = -1;
65 static gint ett_krb4 = -1;
66 static gint ett_krb4_auth_msg_type = -1;
68 #define UDP_PORT_KRB4 750
69 #define TRANSARC_SPECIAL_VERSION 0x63
71 static const value_string byte_order_vals[] = {
73 { 1, "Little Endian" },
77 #define AUTH_MSG_KDC_REQUEST 1
78 #define AUTH_MSG_KDC_REPLY 2
79 #define AUTH_MSG_APPL_REQUEST 3
80 #define AUTH_MSG_APPL_REQUEST_MUTUAL 4
81 #define AUTH_MSG_ERR_REPLY 5
82 #define AUTH_MSG_PRIVATE 6
83 #define AUTH_MSG_SAFE 7
84 #define AUTH_MSG_APPL_ERR 8
85 #define AUTH_MSG_DIE 63
86 static const value_string m_type_vals[] = {
87 { AUTH_MSG_KDC_REQUEST, "KDC Request" },
88 { AUTH_MSG_KDC_REPLY, "KDC Reply" },
89 { AUTH_MSG_APPL_REQUEST, "Appl Request" },
90 { AUTH_MSG_APPL_REQUEST_MUTUAL, "Appl Request Mutual" },
91 { AUTH_MSG_ERR_REPLY, "Err Reply" },
92 { AUTH_MSG_PRIVATE, "Private" },
93 { AUTH_MSG_SAFE, "Safe" },
94 { AUTH_MSG_APPL_ERR, "Appl Err" },
95 { AUTH_MSG_DIE, "Die" },
101 dissect_krb4_string(packet_info *pinfo _U_, int hf_index, proto_tree *tree, tvbuff_t *tvb, int offset)
103 proto_tree_add_item(tree, hf_index, tvb, offset, -1, ENC_ASCII|ENC_NA);
104 while(tvb_get_guint8(tvb, offset)!=0){
113 dissect_krb4_kdc_request(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean little_endian, int version)
118 if(version==TRANSARC_SPECIAL_VERSION){
119 proto_tree_add_item(tree, hf_krb4_unknown_transarc_blob, tvb, offset, 8, ENC_NA);
124 offset=dissect_krb4_string(pinfo, hf_krb4_name, tree, tvb, offset);
127 offset=dissect_krb4_string(pinfo, hf_krb4_instance, tree, tvb, offset);
130 offset=dissect_krb4_string(pinfo, hf_krb4_realm, tree, tvb, offset);
133 time_sec.secs=little_endian?tvb_get_letohl(tvb, offset):tvb_get_ntohl(tvb, offset);
135 proto_tree_add_time(tree, hf_krb4_time_sec, tvb, offset, 4, &time_sec);
139 lifetime=tvb_get_guint8(tvb, offset);
140 proto_tree_add_uint_format_value(tree, hf_krb4_lifetime, tvb, offset, 1, lifetime, "%d (%d minutes)", lifetime, lifetime*5);
144 offset=dissect_krb4_string(pinfo, hf_krb4_s_name, tree, tvb, offset);
146 /* service Instance */
147 offset=dissect_krb4_string(pinfo, hf_krb4_s_instance, tree, tvb, offset);
154 dissect_krb4_kdc_reply(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean little_endian)
160 offset=dissect_krb4_string(pinfo, hf_krb4_name, tree, tvb, offset);
163 offset=dissect_krb4_string(pinfo, hf_krb4_instance, tree, tvb, offset);
166 offset=dissect_krb4_string(pinfo, hf_krb4_realm, tree, tvb, offset);
169 time_sec.secs=little_endian?tvb_get_letohl(tvb, offset):tvb_get_ntohl(tvb, offset);
171 proto_tree_add_time(tree, hf_krb4_time_sec, tvb, offset, 4, &time_sec);
174 /*XXX unknown byte here */
178 time_sec.secs=little_endian?tvb_get_letohl(tvb, offset):tvb_get_ntohl(tvb, offset);
180 proto_tree_add_time(tree, hf_krb4_exp_date, tvb, offset, 4, &time_sec);
184 proto_tree_add_item(tree, hf_krb4_kvno, tvb, offset, 1, ENC_BIG_ENDIAN);
188 length=little_endian?tvb_get_letohs(tvb, offset):tvb_get_ntohs(tvb, offset);
189 proto_tree_add_uint_format_value(tree, hf_krb4_length, tvb, offset, 2, length, "%d", length);
193 proto_tree_add_item(tree, hf_krb4_encrypted_blob, tvb, offset, length, ENC_NA);
201 dissect_krb4_appl_request(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gboolean little_endian)
208 proto_tree_add_item(tree, hf_krb4_kvno, tvb, offset, 1, ENC_BIG_ENDIAN);
212 offset=dissect_krb4_string(pinfo, hf_krb4_realm, tree, tvb, offset);
215 tlen=tvb_get_guint8(tvb, offset);
216 proto_tree_add_item(tree, hf_krb4_ticket_length, tvb, offset, 1, ENC_BIG_ENDIAN);
220 rlen=tvb_get_guint8(tvb, offset);
221 proto_tree_add_item(tree, hf_krb4_request_length, tvb, offset, 1, ENC_BIG_ENDIAN);
225 proto_tree_add_item(tree, hf_krb4_ticket_blob, tvb, offset, tlen, ENC_NA);
229 proto_tree_add_item(tree, hf_krb4_request_blob, tvb, offset, rlen, ENC_NA);
233 time_sec.secs=little_endian?tvb_get_letohl(tvb, offset):tvb_get_ntohl(tvb, offset);
235 proto_tree_add_time(tree, hf_krb4_req_date, tvb, offset, 4, &time_sec);
239 lifetime=tvb_get_guint8(tvb, offset);
240 proto_tree_add_uint_format_value(tree, hf_krb4_lifetime, tvb, offset, 1, lifetime, "%d (%d minutes)", lifetime, lifetime*5);
244 offset=dissect_krb4_string(pinfo, hf_krb4_s_name, tree, tvb, offset);
246 /* service Instance */
247 offset=dissect_krb4_string(pinfo, hf_krb4_s_instance, tree, tvb, offset);
255 dissect_krb4_auth_msg_type(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, int version)
259 guint8 auth_msg_type;
261 auth_msg_type=tvb_get_guint8(tvb, offset);
262 item = proto_tree_add_item(parent_tree, hf_krb4_auth_msg_type, tvb, offset, 1, ENC_BIG_ENDIAN);
263 tree = proto_item_add_subtree(item, ett_krb4_auth_msg_type);
266 proto_tree_add_item(tree, hf_krb4_m_type, tvb, offset, 1, ENC_BIG_ENDIAN);
267 col_append_fstr(pinfo->cinfo, COL_INFO, "%s%s",
268 (version==TRANSARC_SPECIAL_VERSION)?"TRANSARC-":"",
269 val_to_str(auth_msg_type>>1, m_type_vals, "Unknown (0x%04x)"));
270 proto_item_append_text(item, " %s%s",
271 (version==TRANSARC_SPECIAL_VERSION)?"TRANSARC-":"",
272 val_to_str(auth_msg_type>>1, m_type_vals, "Unknown (0x%04x)"));
275 proto_tree_add_item(tree, hf_krb4_byte_order, tvb, offset, 1, ENC_BIG_ENDIAN);
276 proto_item_append_text(item, " (%s)", val_to_str(auth_msg_type&0x01, byte_order_vals, "Unknown (0x%04x)"));
283 dissect_krb4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
287 guint8 version, opcode;
290 /* this should better have the value 4 or it might be a weirdo
291 * Transarc AFS special unknown thing.
293 version=tvb_get_guint8(tvb, offset);
294 if((version!=4)&&(version!=TRANSARC_SPECIAL_VERSION)){
298 opcode=tvb_get_guint8(tvb, offset+1);
300 case AUTH_MSG_KDC_REQUEST:
301 case AUTH_MSG_KDC_REPLY:
302 case AUTH_MSG_APPL_REQUEST:
303 case AUTH_MSG_APPL_REQUEST_MUTUAL:
304 case AUTH_MSG_ERR_REPLY:
305 case AUTH_MSG_PRIVATE:
307 case AUTH_MSG_APPL_ERR:
314 /* create a tree for krb4 */
315 item = proto_tree_add_item(parent_tree, proto_krb4, tvb, offset, -1, ENC_NA);
316 tree = proto_item_add_subtree(item, ett_krb4);
318 col_set_str(pinfo->cinfo, COL_PROTOCOL, "KRB4");
319 col_clear(pinfo->cinfo, COL_INFO);
322 proto_tree_add_item(tree, hf_krb4_version, tvb, offset, 1, ENC_BIG_ENDIAN);
326 offset = dissect_krb4_auth_msg_type(pinfo, tree, tvb, offset, version);
329 case AUTH_MSG_KDC_REQUEST:
330 /*offset =*/ dissect_krb4_kdc_request(pinfo, tree, tvb, offset, opcode&0x01, version);
332 case AUTH_MSG_KDC_REPLY:
333 /*offset =*/ dissect_krb4_kdc_reply(pinfo, tree, tvb, offset, opcode&0x01);
335 case AUTH_MSG_APPL_REQUEST:
336 /*offset =*/ dissect_krb4_appl_request(pinfo, tree, tvb, offset, opcode&0x01);
338 case AUTH_MSG_APPL_REQUEST_MUTUAL:
339 case AUTH_MSG_ERR_REPLY:
340 case AUTH_MSG_PRIVATE:
342 case AUTH_MSG_APPL_ERR:
350 proto_register_krb4(void)
352 static hf_register_info hf[] = {
354 { "Version", "krb4.version",
355 FT_UINT8, BASE_DEC, NULL, 0x0,
356 "Kerberos(v4) version number", HFILL }},
357 { &hf_krb4_auth_msg_type,
358 { "Msg Type", "krb4.auth_msg_type",
359 FT_UINT8, BASE_HEX, NULL, 0x0,
360 "Message Type/Byte Order", HFILL }},
362 { "M Type", "krb4.m_type",
363 FT_UINT8, BASE_HEX, VALS(m_type_vals), 0xfe,
364 "Message Type", HFILL }},
365 { &hf_krb4_byte_order,
366 { "Byte Order", "krb4.byte_order",
367 FT_UINT8, BASE_HEX, VALS(byte_order_vals), 0x01,
370 { "Name", "krb4.name",
371 FT_STRINGZ, BASE_NONE, NULL, 0x00,
374 { "Instance", "krb4.instance",
375 FT_STRINGZ, BASE_NONE, NULL, 0x00,
378 { "Realm", "krb4.realm",
379 FT_STRINGZ, BASE_NONE, NULL, 0x00,
382 { "Time Sec", "krb4.time_sec",
383 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x00,
386 { "Exp Date", "krb4.exp_date",
387 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x00,
390 { "Req Date", "krb4.req_date",
391 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x00,
394 { "Lifetime", "krb4.lifetime",
395 FT_UINT8, BASE_DEC, NULL, 0x00,
396 "Lifetime (in 5 min units)", HFILL }},
398 { "Service Name", "krb4.s_name",
399 FT_STRINGZ, BASE_NONE, NULL, 0x00,
401 { &hf_krb4_s_instance,
402 { "Service Instance", "krb4.s_instance",
403 FT_STRINGZ, BASE_NONE, NULL, 0x00,
406 { "Kvno", "krb4.kvno",
407 FT_UINT8, BASE_DEC, NULL, 0x00,
408 "Key Version No", HFILL }},
410 { "Length", "krb4.length",
411 FT_UINT32, BASE_DEC, NULL, 0x00,
412 "Length of encrypted blob", HFILL }},
413 { &hf_krb4_ticket_length,
414 { "Ticket Length", "krb4.ticket.length",
415 FT_UINT8, BASE_DEC, NULL, 0x00,
416 "Length of ticket", HFILL }},
417 { &hf_krb4_request_length,
418 { "Request Length", "krb4.request.length",
419 FT_UINT8, BASE_DEC, NULL, 0x00,
420 "Length of request", HFILL }},
421 { &hf_krb4_ticket_blob,
422 { "Ticket Blob", "krb4.ticket.blob",
423 FT_BYTES, BASE_NONE, NULL, 0x00,
425 { &hf_krb4_request_blob,
426 { "Request Blob", "krb4.request.blob",
427 FT_BYTES, BASE_NONE, NULL, 0x00,
429 { &hf_krb4_encrypted_blob,
430 { "Encrypted Blob", "krb4.encrypted_blob",
431 FT_BYTES, BASE_NONE, NULL, 0x00,
433 { &hf_krb4_unknown_transarc_blob,
434 { "Unknown Transarc Blob", "krb4.unknown_transarc_blob",
435 FT_BYTES, BASE_NONE, NULL, 0x00,
436 "Unknown blob only present in Transarc packets", HFILL }},
438 static gint *ett[] = {
440 &ett_krb4_auth_msg_type,
443 proto_krb4 = proto_register_protocol("Kerberos v4",
445 new_register_dissector("krb4", dissect_krb4, proto_krb4);
446 proto_register_field_array(proto_krb4, hf, array_length(hf));
447 proto_register_subtree_array(ett, array_length(ett));
451 proto_reg_handoff_krb4(void)
453 dissector_handle_t krb4_handle;
455 krb4_handle = find_dissector("krb4");
456 dissector_add_uint("udp.port", UDP_PORT_KRB4, krb4_handle);