1996-08-19 20:34:12 +00:00
|
|
|
/*
|
1998-09-15 19:36:32 +00:00
|
|
|
* Copyright (c) 1995, 1996, 1997
|
1996-08-19 20:34:12 +00:00
|
|
|
* 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).
|
|
|
|
*/
|
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
#define NETDISSECT_REWORKED
|
2000-01-30 00:45:58 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
1996-08-19 20:34:12 +00:00
|
|
|
#endif
|
|
|
|
|
2004-03-31 09:17:26 +00:00
|
|
|
#include <tcpdump-stdinc.h>
|
1996-08-19 20:34:12 +00:00
|
|
|
|
|
|
|
#include "interface.h"
|
2004-03-31 09:17:26 +00:00
|
|
|
#include "extract.h"
|
1996-08-19 20:34:12 +00:00
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
static const char tstr[] = " [|kerberos]";
|
|
|
|
|
|
|
|
static const u_char *c_print(netdissect_options *, register const u_char *, register const u_char *);
|
|
|
|
static const u_char *krb4_print_hdr(netdissect_options *, const u_char *);
|
|
|
|
static void krb4_print(netdissect_options *, const u_char *);
|
1996-08-19 20:34:12 +00: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 {
|
2015-01-06 19:03:11 +00:00
|
|
|
uint8_t pvno; /* Protocol Version */
|
|
|
|
uint8_t type; /* Type+B */
|
1996-08-19 20:34:12 +00:00
|
|
|
};
|
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
static const struct tok type2str[] = {
|
1998-09-15 19:36:32 +00: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 }
|
1996-08-19 20:34:12 +00:00
|
|
|
};
|
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
static const struct tok kerr2str[] = {
|
1998-09-15 19:36:32 +00: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}
|
1996-08-19 20:34:12 +00:00
|
|
|
};
|
|
|
|
|
2004-03-31 09:17:26 +00:00
|
|
|
static const u_char *
|
2015-01-06 19:03:11 +00:00
|
|
|
c_print(netdissect_options *ndo,
|
|
|
|
register const u_char *s, register const u_char *ep)
|
1996-08-19 20:34:12 +00:00
|
|
|
{
|
|
|
|
register u_char c;
|
|
|
|
register int flag;
|
|
|
|
|
|
|
|
flag = 1;
|
1998-09-15 19:36:32 +00:00
|
|
|
while (s < ep) {
|
1996-08-19 20:34:12 +00:00
|
|
|
c = *s++;
|
|
|
|
if (c == '\0') {
|
|
|
|
flag = 0;
|
|
|
|
break;
|
|
|
|
}
|
2015-01-06 19:03:11 +00:00
|
|
|
if (!ND_ISASCII(c)) {
|
|
|
|
c = ND_TOASCII(c);
|
|
|
|
ND_PRINT((ndo, "M-"));
|
1996-08-19 20:34:12 +00:00
|
|
|
}
|
2015-01-06 19:03:11 +00:00
|
|
|
if (!ND_ISPRINT(c)) {
|
1996-08-19 20:34:12 +00:00
|
|
|
c ^= 0x40; /* DEL to ?, others to alpha */
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, "^"));
|
1996-08-19 20:34:12 +00:00
|
|
|
}
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, "%c", c));
|
1996-08-19 20:34:12 +00:00
|
|
|
}
|
|
|
|
if (flag)
|
|
|
|
return NULL;
|
1998-09-15 19:36:32 +00:00
|
|
|
return (s);
|
1996-08-19 20:34:12 +00:00
|
|
|
}
|
|
|
|
|
2004-03-31 09:17:26 +00:00
|
|
|
static const u_char *
|
2015-01-06 19:03:11 +00:00
|
|
|
krb4_print_hdr(netdissect_options *ndo,
|
|
|
|
const u_char *cp)
|
1996-08-19 20:34:12 +00:00
|
|
|
{
|
1998-09-15 19:36:32 +00:00
|
|
|
cp += 2;
|
1996-08-19 20:34:12 +00:00
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
#define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
|
1996-08-19 20:34:12 +00:00
|
|
|
|
|
|
|
PRINT;
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, "."));
|
1998-09-15 19:36:32 +00:00
|
|
|
PRINT;
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, "@"));
|
1998-09-15 19:36:32 +00:00
|
|
|
PRINT;
|
|
|
|
return (cp);
|
1996-08-19 20:34:12 +00:00
|
|
|
|
|
|
|
trunc:
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
1998-09-15 19:36:32 +00:00
|
|
|
return (NULL);
|
1996-08-19 20:34:12 +00:00
|
|
|
|
|
|
|
#undef PRINT
|
|
|
|
}
|
|
|
|
|
2004-03-31 09:17:26 +00:00
|
|
|
static void
|
2015-01-06 19:03:11 +00:00
|
|
|
krb4_print(netdissect_options *ndo,
|
|
|
|
const u_char *cp)
|
1996-08-19 20:34:12 +00:00
|
|
|
{
|
|
|
|
register const struct krb *kp;
|
|
|
|
u_char type;
|
|
|
|
u_short len;
|
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
#define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
|
1996-08-19 20:34:12 +00:00
|
|
|
/* True if struct krb is little endian */
|
|
|
|
#define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0)
|
2004-03-31 09:17:26 +00:00
|
|
|
#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? EXTRACT_LE_16BITS(cp) : EXTRACT_16BITS(cp))
|
1996-08-19 20:34:12 +00:00
|
|
|
|
|
|
|
kp = (struct krb *)cp;
|
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
if ((&kp->type) >= ndo->ndo_snapend) {
|
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
1996-08-19 20:34:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
type = kp->type & (0xFF << 1);
|
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, " %s %s: ",
|
|
|
|
IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type)));
|
1996-08-19 20:34:12 +00:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
|
|
case AUTH_MSG_KDC_REQUEST:
|
2015-01-06 19:03:11 +00:00
|
|
|
if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
|
1996-08-19 20:34:12 +00:00
|
|
|
return;
|
1998-09-15 19:36:32 +00:00
|
|
|
cp += 4; /* ctime */
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_TCHECK(*cp);
|
|
|
|
ND_PRINT((ndo, " %dmin ", *cp++ * 5));
|
1998-09-15 19:36:32 +00:00
|
|
|
PRINT;
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, "."));
|
1998-09-15 19:36:32 +00:00
|
|
|
PRINT;
|
|
|
|
break;
|
1996-08-19 20:34:12 +00:00
|
|
|
|
|
|
|
case AUTH_MSG_APPL_REQUEST:
|
|
|
|
cp += 2;
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_TCHECK(*cp);
|
|
|
|
ND_PRINT((ndo, "v%d ", *cp++));
|
1996-08-19 20:34:12 +00:00
|
|
|
PRINT;
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_TCHECK(*cp);
|
|
|
|
ND_PRINT((ndo, " (%d)", *cp++));
|
|
|
|
ND_TCHECK(*cp);
|
|
|
|
ND_PRINT((ndo, " (%d)", *cp));
|
1996-08-19 20:34:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUTH_MSG_KDC_REPLY:
|
2015-01-06 19:03:11 +00:00
|
|
|
if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
|
1996-08-19 20:34:12 +00:00
|
|
|
return;
|
|
|
|
cp += 10; /* timestamp + n + exp + kvno */
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_TCHECK2(*cp, sizeof(short));
|
1996-08-19 20:34:12 +00:00
|
|
|
len = KTOHSP(kp, cp);
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, " (%d)", len));
|
1996-08-19 20:34:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AUTH_MSG_ERR_REPLY:
|
2015-01-06 19:03:11 +00:00
|
|
|
if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
|
1996-08-19 20:34:12 +00:00
|
|
|
return;
|
|
|
|
cp += 4; /* timestamp */
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_TCHECK2(*cp, sizeof(short));
|
|
|
|
ND_PRINT((ndo, " %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp))));
|
1996-08-19 20:34:12 +00:00
|
|
|
cp += 4;
|
|
|
|
PRINT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, "(unknown)"));
|
1996-08-19 20:34:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
trunc:
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
1996-08-19 20:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-06 19:03:11 +00:00
|
|
|
krb_print(netdissect_options *ndo,
|
|
|
|
const u_char *dat)
|
1996-08-19 20:34:12 +00:00
|
|
|
{
|
|
|
|
register const struct krb *kp;
|
|
|
|
|
|
|
|
kp = (struct krb *)dat;
|
|
|
|
|
2015-01-06 19:03:11 +00:00
|
|
|
if (dat >= ndo->ndo_snapend) {
|
|
|
|
ND_PRINT((ndo, "%s", tstr));
|
1996-08-19 20:34:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (kp->pvno) {
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, " v%d", kp->pvno));
|
1996-08-19 20:34:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, " v%d", kp->pvno));
|
|
|
|
krb4_print(ndo, (const u_char *)kp);
|
1996-08-19 20:34:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 106:
|
|
|
|
case 107:
|
2015-01-06 19:03:11 +00:00
|
|
|
ND_PRINT((ndo, " v5"));
|
1996-08-19 20:34:12 +00:00
|
|
|
/* Decode ASN.1 here "someday" */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|