1999-12-03 21:50:31 +00:00
|
|
|
/* packet-tacacs.c
|
2001-07-10 21:06:53 +00:00
|
|
|
* Routines for cisco tacacs/xtacacs/tacacs+ packet dissection
|
|
|
|
* Copyright 2001, Paul Ionescu <paul@acorp.ro>
|
1999-12-03 21:50:31 +00:00
|
|
|
*
|
2001-07-10 21:06:53 +00:00
|
|
|
* $Id: packet-tacacs.c,v 1.13 2001/07/10 21:06:53 guy Exp $
|
1999-12-03 21:50:31 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2001-07-10 21:06:53 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-12-03 21:50:31 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2001-07-10 21:06:53 +00:00
|
|
|
* Copied from old packet-tacacs.c
|
1999-12-03 21:50:31 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2001-07-10 21:06:53 +00:00
|
|
|
|
|
|
|
/* rfc-1492 for tacacs and xtacacs
|
|
|
|
* draft-grant-tacacs-00.txt for tacacs+ (tacplus)
|
|
|
|
*/
|
|
|
|
|
1999-12-03 21:50:31 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
# include <netinet/in.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include "packet.h"
|
|
|
|
|
|
|
|
static int proto_tacacs = -1;
|
|
|
|
|
|
|
|
static gint ett_tacacs = -1;
|
|
|
|
|
2001-07-10 21:06:53 +00:00
|
|
|
static const value_string tacacs_type_vals[] = {
|
|
|
|
{ 1 , "Login" },
|
|
|
|
{ 2 , "Response" },
|
|
|
|
{ 3 , "Change" },
|
|
|
|
{ 4 , "Follow" },
|
|
|
|
{ 5 , "Connect" },
|
|
|
|
{ 6 , "Superuser" },
|
|
|
|
{ 7 , "Logout" },
|
|
|
|
{ 8 , "Reload" },
|
|
|
|
{ 9 , "SLIP on" },
|
|
|
|
{ 10 , "SLIP off" },
|
|
|
|
{ 11 , "SLIP Addr" },
|
|
|
|
{ 0 , NULL }};
|
|
|
|
|
|
|
|
static const value_string tacacs_reason_vals[] = {
|
|
|
|
{ 0 , "none" },
|
|
|
|
{ 1 , "expiring" },
|
|
|
|
{ 2 , "password" },
|
|
|
|
{ 3 , "denied" },
|
|
|
|
{ 4 , "quit" },
|
|
|
|
{ 5 , "idle" },
|
|
|
|
{ 6 , "drop" },
|
|
|
|
{ 7 , "bad" }};
|
|
|
|
|
|
|
|
static const value_string tacacs_resp_vals[] = {
|
|
|
|
{ 0 , "this is not a response" },
|
|
|
|
{ 1 , "accepted" },
|
|
|
|
{ 2 , "rejected" }};
|
|
|
|
|
|
|
|
#define TAC_PLUS_AUTHEN 1
|
|
|
|
#define TAC_PLUS_AUTHOR 2
|
|
|
|
#define TAC_PLUS_ACCT 3
|
|
|
|
|
|
|
|
static const value_string tacplus_type_vals[] = {
|
|
|
|
{ TAC_PLUS_AUTHEN , "Authentication" },
|
|
|
|
{ TAC_PLUS_AUTHOR , "Authorization" },
|
|
|
|
{ TAC_PLUS_ACCT , "Accounting" },
|
|
|
|
{ 0 , NULL }};
|
|
|
|
|
2000-04-08 07:07:42 +00:00
|
|
|
#define UDP_PORT_TACACS 49
|
|
|
|
#define TCP_PORT_TACACS 49
|
|
|
|
|
|
|
|
static void
|
2001-02-28 10:28:55 +00:00
|
|
|
dissect_tacacs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
1999-12-03 21:50:31 +00:00
|
|
|
{
|
|
|
|
proto_tree *tacacs_tree, *ti;
|
2001-07-10 21:06:53 +00:00
|
|
|
guint8 txt_buff[256],version,type,userlen,passlen;
|
1999-12-03 21:50:31 +00:00
|
|
|
|
2001-07-10 21:06:53 +00:00
|
|
|
version = tvb_get_guint8(tvb,0);
|
|
|
|
type = tvb_get_guint8(tvb,1);
|
|
|
|
|
2001-02-28 10:28:55 +00:00
|
|
|
if (check_col(pinfo->fd, COL_PROTOCOL))
|
2001-07-10 21:06:53 +00:00
|
|
|
col_set_str(pinfo->fd, COL_PROTOCOL, version==0 ? "TACACS":"XTACACS");
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
|
2001-02-28 10:28:55 +00:00
|
|
|
if (check_col(pinfo->fd, COL_INFO))
|
2001-07-10 21:06:53 +00:00
|
|
|
col_add_str(pinfo->fd, COL_INFO, val_to_str(type, tacacs_type_vals, "Unknown Type"));
|
1999-12-03 21:50:31 +00:00
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
2001-07-10 21:06:53 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_tacacs,
|
|
|
|
tvb, 0, tvb_length(tvb), version==0?"TACACS":"XTACACS");
|
1999-12-03 21:50:31 +00:00
|
|
|
tacacs_tree = proto_item_add_subtree(ti, ett_tacacs);
|
|
|
|
|
2001-07-10 21:06:53 +00:00
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 0, 1, "Version = %s ",version==0?"TACACS":"XTACACS" );
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 1, 1, "Type = %s ",val_to_str(type, tacacs_type_vals, "Unknown Type"));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 2, 2, "Nonce = 0x%04X ",tvb_get_ntohs(tvb,2));
|
|
|
|
|
|
|
|
if (version==0)
|
|
|
|
{
|
|
|
|
if (type!=2)
|
|
|
|
{
|
|
|
|
userlen=tvb_get_guint8(tvb,4);
|
|
|
|
passlen=tvb_get_guint8(tvb,5);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 4, 1, "Username length = %d ",userlen);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 5, 1, "Password length = %d ",passlen);
|
|
|
|
tvb_get_nstringz0(tvb,6,userlen,txt_buff);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 6, userlen, "User = %s ",txt_buff);
|
|
|
|
tvb_get_nstringz0(tvb,6+userlen,passlen,txt_buff);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 6+userlen, passlen, "Password = %s ",txt_buff);
|
1999-12-03 21:50:31 +00:00
|
|
|
}
|
2001-07-10 21:06:53 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 4, 1, "Response = %s",
|
|
|
|
val_to_str(tvb_get_guint8(tvb,4), tacacs_resp_vals, "Unknown Response"));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 5, 1, "Reason = %s",
|
|
|
|
val_to_str(tvb_get_guint8(tvb,5), tacacs_reason_vals, "Unknown Reason"));
|
1999-12-03 21:50:31 +00:00
|
|
|
}
|
2001-07-10 21:06:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
userlen=tvb_get_guint8(tvb,4);
|
|
|
|
passlen=tvb_get_guint8(tvb,5);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 4, 1, "Username length = %d ",userlen);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 5, 1, "Password length = %d ",passlen);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 6, 1, "Response = %s",
|
|
|
|
val_to_str(tvb_get_guint8(tvb,6), tacacs_resp_vals, "Unknown Response"));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 7, 1, "Reason = %s",
|
|
|
|
val_to_str(tvb_get_guint8(tvb,7), tacacs_reason_vals, "Unknown Reason"));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 8, 4, "Result1 = 0x%08X ",tvb_get_ntohl(tvb,8));
|
|
|
|
tvb_memcpy(tvb,txt_buff,12,4);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 12, 4, "IP addr = %s ",ip_to_str(txt_buff));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 16, 2, "Dst port = %d ",tvb_get_ntohs(tvb,16));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 18, 2, "Line = tty%d ",tvb_get_ntohs(tvb,18));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 20, 4, "Result2 = 0x%08X ",tvb_get_ntohl(tvb,20));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 24, 2, "Result3 = 0x%04X ",tvb_get_ntohs(tvb,24));
|
|
|
|
if (type!=2)
|
|
|
|
{
|
|
|
|
tvb_get_nstringz0(tvb,26,userlen,txt_buff);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 26, userlen, "User = %s ",txt_buff);
|
|
|
|
tvb_get_nstringz0(tvb,26+userlen,passlen,txt_buff);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 26+userlen, passlen, "Password = %s ",txt_buff);
|
|
|
|
}
|
|
|
|
}
|
1999-12-03 21:50:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-08 07:07:42 +00:00
|
|
|
static void
|
2001-02-28 10:28:55 +00:00
|
|
|
dissect_tacplus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
1999-12-03 21:50:31 +00:00
|
|
|
{
|
|
|
|
proto_tree *tacacs_tree, *ti;
|
2001-07-10 21:06:53 +00:00
|
|
|
guint8 version,type,seq_no,flags;
|
|
|
|
guint32 len;
|
|
|
|
gboolean request=(pinfo->match_port == pinfo->destport);
|
1999-12-03 21:50:31 +00:00
|
|
|
|
2001-02-28 10:28:55 +00:00
|
|
|
if (check_col(pinfo->fd, COL_PROTOCOL))
|
2001-07-10 21:06:53 +00:00
|
|
|
col_set_str(pinfo->fd, COL_PROTOCOL, "TACACS+");
|
1999-12-03 21:50:31 +00:00
|
|
|
|
2001-02-28 10:28:55 +00:00
|
|
|
if (check_col(pinfo->fd, COL_INFO))
|
1999-12-03 21:50:31 +00:00
|
|
|
{
|
2001-02-28 10:28:55 +00:00
|
|
|
col_add_str(pinfo->fd, COL_INFO,
|
2001-07-10 21:06:53 +00:00
|
|
|
request ? "Request" : "Response");
|
1999-12-03 21:50:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
2001-07-10 21:06:53 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_tacacs,
|
|
|
|
tvb, 0, tvb_length(tvb), "TACACS+");
|
1999-12-03 21:50:31 +00:00
|
|
|
|
2001-07-10 21:06:53 +00:00
|
|
|
version = tvb_get_guint8(tvb,0);
|
|
|
|
type = tvb_get_guint8(tvb,1);
|
|
|
|
seq_no = tvb_get_guint8(tvb,2);
|
|
|
|
flags = tvb_get_guint8(tvb,3);
|
|
|
|
len = tvb_get_ntohl(tvb,8);
|
1999-12-03 21:50:31 +00:00
|
|
|
|
2001-07-10 21:06:53 +00:00
|
|
|
tacacs_tree = proto_item_add_subtree(ti, ett_tacacs);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 0, 1, "Major version = %s ",(version&0xf0)==0xc0?"TACACS+":"Unknown Version" );
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 0, 1, "Minor version = %d ",version&0xf);
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 1, 1, "Type = %s ",val_to_str(type, tacplus_type_vals, "Unknown Type"));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 2, 1, "Seq. no = %d ",tvb_get_guint8(tvb,2));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 3, 1, "Flags = %s, %s ",
|
|
|
|
(flags&1)==0?"Encripted payload":"Unencripted payload",(flags&4)==0?"Multiple Connections":"Single connection");
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 4, 4, "Session ID = %d ",tvb_get_ntohl(tvb,4));
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 8, 4, "Packet len = %d ",len);
|
|
|
|
|
|
|
|
if ((flags&1)==0)
|
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 12, len, "Encripted payload");
|
1999-12-03 21:50:31 +00:00
|
|
|
else
|
2001-07-10 21:06:53 +00:00
|
|
|
proto_tree_add_text(tacacs_tree, tvb, 12, len, "Payload");
|
|
|
|
|
|
|
|
|
1999-12-03 21:50:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_tacacs(void)
|
|
|
|
{
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_tacacs,
|
|
|
|
};
|
2001-01-03 06:56:03 +00:00
|
|
|
proto_tacacs = proto_register_protocol("TACACS", "TACACS", "tacacs");
|
1999-12-03 21:50:31 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
2000-04-08 07:07:42 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_tacacs(void)
|
|
|
|
{
|
2001-02-28 10:28:55 +00:00
|
|
|
dissector_add("udp.port", UDP_PORT_TACACS, dissect_tacacs,
|
2001-01-09 06:32:10 +00:00
|
|
|
proto_tacacs);
|
2001-02-28 10:28:55 +00:00
|
|
|
dissector_add("tcp.port", TCP_PORT_TACACS, dissect_tacplus,
|
2001-01-09 06:32:10 +00:00
|
|
|
proto_tacacs);
|
2000-04-08 07:07:42 +00:00
|
|
|
}
|