2003-06-09 10:08:40 +00:00
|
|
|
/* tap-smbsids.c
|
|
|
|
* smbstat 2003 Ronnie Sahlberg
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2003-06-09 10:08:40 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2003-06-09 10:08:40 +00:00
|
|
|
|
2012-09-20 01:29:52 +00:00
|
|
|
#include "config.h"
|
2003-06-09 10:08:40 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2013-11-10 15:59:37 +00:00
|
|
|
#include <stdlib.h>
|
2003-06-09 10:08:40 +00:00
|
|
|
#include <string.h>
|
2013-11-10 15:59:37 +00:00
|
|
|
|
2016-01-25 01:10:20 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/packet_info.h>
|
2004-07-18 18:06:47 +00:00
|
|
|
#include <epan/dissectors/packet-smb-sidsnooping.h>
|
2004-09-29 00:06:36 +00:00
|
|
|
#include <epan/tap.h>
|
2014-11-14 18:51:40 +00:00
|
|
|
#include <epan/stat_tap_ui.h>
|
2016-01-25 01:10:20 +00:00
|
|
|
#include <epan/value_string.h>
|
2005-09-17 00:31:15 +00:00
|
|
|
#include <epan/dissectors/packet-smb.h>
|
2003-06-09 10:08:40 +00:00
|
|
|
|
2019-01-01 00:55:23 +00:00
|
|
|
#include <ui/cmdarg_err.h>
|
2018-12-30 02:24:56 +00:00
|
|
|
|
2013-11-14 06:21:02 +00:00
|
|
|
void register_tap_listener_smbsids(void);
|
2003-06-09 10:08:40 +00:00
|
|
|
|
|
|
|
static int
|
2005-01-01 02:57:02 +00:00
|
|
|
smbsids_packet(void *pss _U_, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *psi _U_)
|
2003-06-09 10:08:40 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-09-23 06:08:19 +00:00
|
|
|
static void
|
2015-11-25 22:15:58 +00:00
|
|
|
enum_sids(gpointer key, gpointer value, gpointer userdata _U_)
|
2003-06-09 10:08:40 +00:00
|
|
|
{
|
2015-11-25 22:15:58 +00:00
|
|
|
const char *sid = (const char *)key;
|
|
|
|
const char *name = (const char *)value;
|
2003-06-09 10:08:40 +00:00
|
|
|
|
2015-11-25 22:15:58 +00:00
|
|
|
printf("%-60s %s\n", sid, name);
|
2003-06-09 10:08:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
smbsids_draw(void *pss _U_)
|
|
|
|
{
|
|
|
|
printf("\n");
|
|
|
|
printf("===================================================================\n");
|
|
|
|
printf("SMB SID List:\n");
|
|
|
|
g_hash_table_foreach(sid_name_table, enum_sids, NULL);
|
|
|
|
printf("===================================================================\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2014-10-13 19:04:21 +00:00
|
|
|
smbsids_init(const char *opt_arg _U_, void *userdata _U_)
|
2003-06-09 10:08:40 +00:00
|
|
|
{
|
2016-06-19 09:01:56 +00:00
|
|
|
GString *error_string;
|
2003-06-09 10:08:40 +00:00
|
|
|
|
2014-10-13 19:04:21 +00:00
|
|
|
if (!sid_name_snooping) {
|
|
|
|
fprintf(stderr, "The -z smb,sids function needs SMB/SID-Snooping to be enabled.\n");
|
|
|
|
fprintf(stderr, "Either enable Edit/Preferences/Protocols/SMB/Snoop SID name mappings in wireshark\n");
|
|
|
|
fprintf(stderr, "or override the preference file by specifying\n");
|
|
|
|
fprintf(stderr, " -o \"smb.sid_name_snooping=TRUE\"\n");
|
|
|
|
fprintf(stderr, "on the tshark command line.\n");
|
2003-06-09 10:08:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-21 00:07:19 +00:00
|
|
|
error_string = register_tap_listener("smb", NULL, NULL, 0, NULL, smbsids_packet, smbsids_draw, NULL);
|
2014-10-13 19:04:21 +00:00
|
|
|
if (error_string) {
|
2018-12-30 02:24:56 +00:00
|
|
|
cmdarg_err("Couldn't register smb,sids tap: %s",
|
2016-06-19 09:01:56 +00:00
|
|
|
error_string->str);
|
|
|
|
g_string_free(error_string, TRUE);
|
2003-06-09 10:08:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-14 18:42:26 +00:00
|
|
|
static stat_tap_ui smbsids_ui = {
|
2014-11-14 18:31:04 +00:00
|
|
|
REGISTER_STAT_GROUP_GENERIC,
|
|
|
|
NULL,
|
|
|
|
"smb,sids",
|
|
|
|
smbsids_init,
|
|
|
|
0,
|
|
|
|
NULL
|
|
|
|
};
|
2003-06-09 10:08:40 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_listener_smbsids(void)
|
|
|
|
{
|
2014-11-14 18:42:26 +00:00
|
|
|
register_stat_tap_ui(&smbsids_ui, NULL);
|
2003-06-09 10:08:40 +00:00
|
|
|
}
|
|
|
|
|
2014-10-13 19:04:21 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|