1999-10-08 07:47:09 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995, 1996, 1997
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code distributions
|
|
|
|
* retain the above copyright notice and this paragraph in its entirety, (2)
|
|
|
|
* distributions including binary code include the above copyright notice and
|
|
|
|
* this paragraph in its entirety in the documentation or other materials
|
|
|
|
* provided with the distribution, and (3) all advertising materials mentioning
|
|
|
|
* features or use of this software display the following acknowledgement:
|
|
|
|
* ``This product includes software developed by the University of California,
|
|
|
|
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
|
|
|
* the University nor the names of its contributors may be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* Initial contribution from John Hawkinson (jhawk@mit.edu).
|
|
|
|
*/
|
|
|
|
|
2016-08-14 21:42:19 +08:00
|
|
|
/* \summary: Kerberos printer */
|
|
|
|
|
1999-11-21 17:36:43 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2018-01-22 04:27:08 +08:00
|
|
|
#include <config.h>
|
1999-10-08 07:47:09 +08:00
|
|
|
#endif
|
|
|
|
|
2018-01-20 22:59:49 +08:00
|
|
|
#include "netdissect-stdinc.h"
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
2002-12-11 13:40:09 +08:00
|
|
|
#include "extract.h"
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2017-11-19 02:42:06 +08:00
|
|
|
/*
|
|
|
|
* Kerberos 4:
|
|
|
|
*
|
|
|
|
* Athena Technical Plan
|
|
|
|
* Section E.2.1
|
|
|
|
* Kerberos Authentication and Authorization System
|
|
|
|
* by S. P. Miller, B. C. Neuman, J. I. Schiller, and J. H. Saltzer
|
|
|
|
*
|
|
|
|
* http://web.mit.edu/Saltzer/www/publications/athenaplan/e.2.1.pdf
|
|
|
|
*
|
|
|
|
* 7. Appendix I Design Specifications
|
|
|
|
*
|
|
|
|
* Kerberos 5:
|
|
|
|
*
|
|
|
|
* RFC 1510, RFC 2630, etc.
|
|
|
|
*/
|
|
|
|
|
2013-12-26 22:08:06 +08:00
|
|
|
|
2017-12-14 02:17:47 +08:00
|
|
|
static const u_char *c_print(netdissect_options *, const u_char *, const u_char *);
|
2014-03-28 18:43:43 +08:00
|
|
|
static const u_char *krb4_print_hdr(netdissect_options *, const u_char *);
|
|
|
|
static void krb4_print(netdissect_options *, const u_char *);
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
#define AUTH_MSG_KDC_REQUEST 1<<1
|
|
|
|
#define AUTH_MSG_KDC_REPLY 2<<1
|
|
|
|
#define AUTH_MSG_APPL_REQUEST 3<<1
|
|
|
|
#define AUTH_MSG_APPL_REQUEST_MUTUAL 4<<1
|
|
|
|
#define AUTH_MSG_ERR_REPLY 5<<1
|
|
|
|
#define AUTH_MSG_PRIVATE 6<<1
|
|
|
|
#define AUTH_MSG_SAFE 7<<1
|
|
|
|
#define AUTH_MSG_APPL_ERR 8<<1
|
|
|
|
#define AUTH_MSG_DIE 63<<1
|
|
|
|
|
|
|
|
#define KERB_ERR_OK 0
|
|
|
|
#define KERB_ERR_NAME_EXP 1
|
|
|
|
#define KERB_ERR_SERVICE_EXP 2
|
|
|
|
#define KERB_ERR_AUTH_EXP 3
|
|
|
|
#define KERB_ERR_PKT_VER 4
|
|
|
|
#define KERB_ERR_NAME_MAST_KEY_VER 5
|
|
|
|
#define KERB_ERR_SERV_MAST_KEY_VER 6
|
|
|
|
#define KERB_ERR_BYTE_ORDER 7
|
|
|
|
#define KERB_ERR_PRINCIPAL_UNKNOWN 8
|
|
|
|
#define KERB_ERR_PRINCIPAL_NOT_UNIQUE 9
|
|
|
|
#define KERB_ERR_NULL_KEY 10
|
|
|
|
|
|
|
|
struct krb {
|
2017-12-31 07:21:14 +08:00
|
|
|
nd_uint8_t pvno; /* Protocol Version */
|
|
|
|
nd_uint8_t type; /* Type+B */
|
2002-12-11 15:13:49 +08:00
|
|
|
};
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2013-09-25 00:46:24 +08:00
|
|
|
static const struct tok type2str[] = {
|
1999-10-08 07:47:09 +08:00
|
|
|
{ AUTH_MSG_KDC_REQUEST, "KDC_REQUEST" },
|
|
|
|
{ AUTH_MSG_KDC_REPLY, "KDC_REPLY" },
|
|
|
|
{ AUTH_MSG_APPL_REQUEST, "APPL_REQUEST" },
|
|
|
|
{ AUTH_MSG_APPL_REQUEST_MUTUAL, "APPL_REQUEST_MUTUAL" },
|
|
|
|
{ AUTH_MSG_ERR_REPLY, "ERR_REPLY" },
|
|
|
|
{ AUTH_MSG_PRIVATE, "PRIVATE" },
|
|
|
|
{ AUTH_MSG_SAFE, "SAFE" },
|
|
|
|
{ AUTH_MSG_APPL_ERR, "APPL_ERR" },
|
|
|
|
{ AUTH_MSG_DIE, "DIE" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2013-09-25 00:46:24 +08:00
|
|
|
static const struct tok kerr2str[] = {
|
1999-10-08 07:47:09 +08:00
|
|
|
{ KERB_ERR_OK, "OK" },
|
|
|
|
{ KERB_ERR_NAME_EXP, "NAME_EXP" },
|
|
|
|
{ KERB_ERR_SERVICE_EXP, "SERVICE_EXP" },
|
|
|
|
{ KERB_ERR_AUTH_EXP, "AUTH_EXP" },
|
|
|
|
{ KERB_ERR_PKT_VER, "PKT_VER" },
|
|
|
|
{ KERB_ERR_NAME_MAST_KEY_VER, "NAME_MAST_KEY_VER" },
|
|
|
|
{ KERB_ERR_SERV_MAST_KEY_VER, "SERV_MAST_KEY_VER" },
|
|
|
|
{ KERB_ERR_BYTE_ORDER, "BYTE_ORDER" },
|
|
|
|
{ KERB_ERR_PRINCIPAL_UNKNOWN, "PRINCIPAL_UNKNOWN" },
|
|
|
|
{ KERB_ERR_PRINCIPAL_NOT_UNIQUE,"PRINCIPAL_NOT_UNIQUE" },
|
|
|
|
{ KERB_ERR_NULL_KEY, "NULL_KEY"},
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
|
|
|
|
2002-09-06 05:25:34 +08:00
|
|
|
static const u_char *
|
2014-03-28 18:43:43 +08:00
|
|
|
c_print(netdissect_options *ndo,
|
2017-12-14 02:17:47 +08:00
|
|
|
const u_char *s, const u_char *ep)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
2017-12-14 02:17:47 +08:00
|
|
|
u_char c;
|
|
|
|
int flag;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
flag = 1;
|
|
|
|
while (s < ep) {
|
2017-11-23 06:54:09 +08:00
|
|
|
c = EXTRACT_U_1(s);
|
2017-11-22 03:23:59 +08:00
|
|
|
s++;
|
1999-10-08 07:47:09 +08:00
|
|
|
if (c == '\0') {
|
|
|
|
flag = 0;
|
|
|
|
break;
|
|
|
|
}
|
2018-02-14 20:58:11 +08:00
|
|
|
fn_print_char(ndo, c);
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
|
|
|
if (flag)
|
|
|
|
return NULL;
|
|
|
|
return (s);
|
|
|
|
}
|
|
|
|
|
2002-09-06 05:25:34 +08:00
|
|
|
static const u_char *
|
2014-03-28 18:43:43 +08:00
|
|
|
krb4_print_hdr(netdissect_options *ndo,
|
|
|
|
const u_char *cp)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
|
|
|
cp += 2;
|
|
|
|
|
2014-03-28 18:43:43 +08:00
|
|
|
#define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
PRINT;
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(".");
|
1999-10-08 07:47:09 +08:00
|
|
|
PRINT;
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("@");
|
1999-10-08 07:47:09 +08:00
|
|
|
PRINT;
|
|
|
|
return (cp);
|
|
|
|
|
|
|
|
trunc:
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
#undef PRINT
|
|
|
|
}
|
|
|
|
|
2002-09-06 05:25:34 +08:00
|
|
|
static void
|
2014-03-28 18:43:43 +08:00
|
|
|
krb4_print(netdissect_options *ndo,
|
|
|
|
const u_char *cp)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
2017-12-14 02:17:47 +08:00
|
|
|
const struct krb *kp;
|
1999-10-08 07:47:09 +08:00
|
|
|
u_char type;
|
|
|
|
u_short len;
|
|
|
|
|
2014-03-28 18:43:43 +08:00
|
|
|
#define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
|
1999-10-08 07:47:09 +08:00
|
|
|
/* True if struct krb is little endian */
|
2017-12-31 07:21:14 +08:00
|
|
|
#define IS_LENDIAN(kp) ((EXTRACT_U_1((kp)->type) & 0x01) != 0)
|
2017-11-23 06:54:09 +08:00
|
|
|
#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? EXTRACT_LE_U_2(cp) : EXTRACT_BE_U_2(cp))
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
kp = (const struct krb *)cp;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2017-12-31 07:21:14 +08:00
|
|
|
if (!ND_TTEST_1(kp->type)) {
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-31 07:21:14 +08:00
|
|
|
type = EXTRACT_U_1(kp->type) & (0xFF << 1);
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" %s %s: ",
|
|
|
|
IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type));
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
|
|
case AUTH_MSG_KDC_REQUEST:
|
2014-03-28 18:43:43 +08:00
|
|
|
if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
|
1999-10-08 07:47:09 +08:00
|
|
|
return;
|
|
|
|
cp += 4; /* ctime */
|
2017-12-05 03:21:48 +08:00
|
|
|
ND_TCHECK_1(cp);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" %umin ", EXTRACT_U_1(cp) * 5);
|
2017-11-24 03:12:25 +08:00
|
|
|
cp++;
|
1999-10-08 07:47:09 +08:00
|
|
|
PRINT;
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(".");
|
1999-10-08 07:47:09 +08:00
|
|
|
PRINT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUTH_MSG_APPL_REQUEST:
|
|
|
|
cp += 2;
|
2017-12-05 03:21:48 +08:00
|
|
|
ND_TCHECK_1(cp);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("v%u ", EXTRACT_U_1(cp));
|
2017-11-22 22:27:53 +08:00
|
|
|
cp++;
|
1999-10-08 07:47:09 +08:00
|
|
|
PRINT;
|
2017-12-05 03:21:48 +08:00
|
|
|
ND_TCHECK_1(cp);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" (%u)", EXTRACT_U_1(cp));
|
2017-11-22 22:27:53 +08:00
|
|
|
cp++;
|
2017-12-05 03:21:48 +08:00
|
|
|
ND_TCHECK_1(cp);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" (%u)", EXTRACT_U_1(cp));
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUTH_MSG_KDC_REPLY:
|
2014-03-28 18:43:43 +08:00
|
|
|
if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
|
1999-10-08 07:47:09 +08:00
|
|
|
return;
|
|
|
|
cp += 10; /* timestamp + n + exp + kvno */
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(cp, sizeof(short));
|
1999-10-08 07:47:09 +08:00
|
|
|
len = KTOHSP(kp, cp);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" (%u)", len);
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUTH_MSG_ERR_REPLY:
|
2014-03-28 18:43:43 +08:00
|
|
|
if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
|
1999-10-08 07:47:09 +08:00
|
|
|
return;
|
|
|
|
cp += 4; /* timestamp */
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(cp, sizeof(short));
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp)));
|
1999-10-08 07:47:09 +08:00
|
|
|
cp += 4;
|
|
|
|
PRINT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("(unknown)");
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
trunc:
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-03-28 18:43:43 +08:00
|
|
|
krb_print(netdissect_options *ndo,
|
|
|
|
const u_char *dat)
|
1999-10-08 07:47:09 +08:00
|
|
|
{
|
2017-12-14 02:17:47 +08:00
|
|
|
const struct krb *kp;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "krb";
|
2015-04-27 08:24:42 +08:00
|
|
|
kp = (const struct krb *)dat;
|
1999-10-08 07:47:09 +08:00
|
|
|
|
2014-03-28 18:43:43 +08:00
|
|
|
if (dat >= ndo->ndo_snapend) {
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
1999-10-08 07:47:09 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-31 07:21:14 +08:00
|
|
|
switch (EXTRACT_U_1(kp->pvno)) {
|
1999-10-08 07:47:09 +08:00
|
|
|
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" v%u", EXTRACT_U_1(kp->pvno));
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" v%u", EXTRACT_U_1(kp->pvno));
|
2014-03-28 18:43:43 +08:00
|
|
|
krb4_print(ndo, (const u_char *)kp);
|
1999-10-08 07:47:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 106:
|
|
|
|
case 107:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" v5");
|
1999-10-08 07:47:09 +08:00
|
|
|
/* Decode ASN.1 here "someday" */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|