2 XXX Fixme : shouldnt show [malformed frame] for long packets
6 * Routines for SMB named pipe packet dissection
7 * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
8 * significant rewrite to tvbuffify the dissector, Ronnie Sahlberg and
11 * $Id: packet-smb-pipe.c,v 1.50 2001/11/20 07:47:41 guy Exp $
13 * Ethereal - Network traffic analyzer
14 * By Gerald Combs <gerald@ethereal.com>
15 * Copyright 1998 Gerald Combs
17 * Copied from packet-pop.c
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #ifdef HAVE_SYS_TYPES_H
41 # include <sys/types.h>
44 #ifdef HAVE_NETINET_IN_H
45 # include <netinet/in.h>
53 #include "conversation.h"
55 #include "packet-smb-pipe.h"
56 #include "packet-smb-browse.h"
57 #include "packet-dcerpc.h"
59 static int proto_smb_pipe = -1;
60 static int hf_pipe_function = -1;
61 static int hf_pipe_priority = -1;
62 static int hf_pipe_peek_available = -1;
63 static int hf_pipe_peek_remaining = -1;
64 static int hf_pipe_peek_status = -1;
65 static int hf_pipe_getinfo_info_level = -1;
66 static int hf_pipe_getinfo_output_buffer_size = -1;
67 static int hf_pipe_getinfo_input_buffer_size = -1;
68 static int hf_pipe_getinfo_maximum_instances = -1;
69 static int hf_pipe_getinfo_current_instances = -1;
70 static int hf_pipe_getinfo_pipe_name_length = -1;
71 static int hf_pipe_getinfo_pipe_name = -1;
72 static int hf_pipe_write_raw_bytes_written = -1;
74 static gint ett_smb_pipe = -1;
76 static int proto_smb_lanman = -1;
77 static int hf_function_code = -1;
78 static int hf_param_desc = -1;
79 static int hf_return_desc = -1;
80 static int hf_aux_data_desc = -1;
81 static int hf_detail_level = -1;
82 static int hf_recv_buf_len = -1;
83 static int hf_send_buf_len = -1;
84 static int hf_continuation_from = -1;
85 static int hf_status = -1;
86 static int hf_convert = -1;
87 static int hf_ecount = -1;
88 static int hf_acount = -1;
89 static int hf_share_name = -1;
90 static int hf_share_type = -1;
91 static int hf_share_comment = -1;
92 static int hf_share_permissions = -1;
93 static int hf_share_max_uses = -1;
94 static int hf_share_current_uses = -1;
95 static int hf_share_path = -1;
96 static int hf_share_password = -1;
97 static int hf_server_name = -1;
98 static int hf_server_major = -1;
99 static int hf_server_minor = -1;
100 static int hf_server_comment = -1;
101 static int hf_abytes = -1;
102 static int hf_current_time = -1;
103 static int hf_msecs = -1;
104 static int hf_hour = -1;
105 static int hf_minute = -1;
106 static int hf_second = -1;
107 static int hf_hundredths = -1;
108 static int hf_tzoffset = -1;
109 static int hf_timeinterval = -1;
110 static int hf_day = -1;
111 static int hf_month = -1;
112 static int hf_year = -1;
113 static int hf_weekday = -1;
114 static int hf_enumeration_domain = -1;
115 static int hf_computer_name = -1;
116 static int hf_user_name = -1;
117 static int hf_workstation_domain = -1;
118 static int hf_workstation_major = -1;
119 static int hf_workstation_minor = -1;
120 static int hf_logon_domain = -1;
121 static int hf_other_domains = -1;
122 static int hf_password = -1;
123 static int hf_workstation_name = -1;
124 static int hf_ustruct_size = -1;
125 static int hf_logon_code = -1;
126 static int hf_privilege_level = -1;
127 static int hf_operator_privileges = -1;
128 static int hf_num_logons = -1;
129 static int hf_bad_pw_count = -1;
130 static int hf_last_logon = -1;
131 static int hf_last_logoff = -1;
132 static int hf_logoff_time = -1;
133 static int hf_kickoff_time = -1;
134 static int hf_password_age = -1;
135 static int hf_password_can_change = -1;
136 static int hf_password_must_change = -1;
137 static int hf_script_path = -1;
138 static int hf_logoff_code = -1;
139 static int hf_duration = -1;
140 static int hf_user_comment = -1;
141 static int hf_full_name = -1;
142 static int hf_homedir = -1;
143 static int hf_parameters = -1;
144 static int hf_logon_server = -1;
145 static int hf_country_code = -1;
146 static int hf_workstations = -1;
147 static int hf_max_storage = -1;
148 static int hf_units_per_week = -1;
149 static int hf_logon_hours = -1;
150 static int hf_code_page = -1;
151 static int hf_new_password = -1;
152 static int hf_old_password = -1;
153 static int hf_reserved = -1;
155 static gint ett_lanman = -1;
156 static gint ett_lanman_shares = -1;
157 static gint ett_lanman_share = -1;
158 static gint ett_lanman_servers = -1;
159 static gint ett_lanman_server = -1;
164 * ftp://ftp.microsoft.com/developr/drg/CIFS/cifsrap2.txt
166 * among other documents.
169 static const value_string status_vals[] = {
171 {5, "User has insufficient privilege"},
172 {65, "Network access is denied"},
173 {86, "The specified password is invalid"},
174 {SMBE_moredata, "Additional data is available"},
175 {2114, "Service is not running on the remote computer"},
176 {2123, "Supplied buffer is too small"},
177 {2141, "Server is not configured for transactions (IPC$ not shared)"},
178 {2212, "An error occurred while loading or running the logon script"},
179 {2214, "The logon was not validated by any server"},
180 {2217, "The logon server is running an older software version"},
181 {2221, "The user name was not found"},
182 {2240, "The user is not allowed to logon from this computer"},
183 {2241, "The user is not allowed to logon at this time"},
184 {2242, "The user password has expired"},
185 {2243, "The password cannot be changed"},
186 {2246, "The password is too short"},
190 static const value_string share_type_vals[] = {
191 {0, "Directory tree"},
192 {1, "Printer queue"},
193 {2, "Communications device"},
198 static const value_string privilege_vals[] = {
201 {2, "Administrator"},
205 static const value_string op_privilege_vals[] = {
206 {0, "Print operator"},
207 {1, "Communications operator"},
208 {2, "Server operator"},
209 {3, "Accounts operator"},
213 static const value_string weekday_vals[] = {
225 add_word_param(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
226 proto_tree *tree, int convert, int hf_index)
231 proto_tree_add_item(tree, hf_index, tvb, offset, 2, TRUE);
233 WParam = tvb_get_letohs(tvb, offset);
234 proto_tree_add_text(tree, tvb, offset, 2,
235 "Word Param: %u (0x%04X)", WParam, WParam);
242 add_dword_param(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
243 proto_tree *tree, int convert, int hf_index)
248 proto_tree_add_item(tree, hf_index, tvb, offset, 4, TRUE);
250 LParam = tvb_get_letohl(tvb, offset);
251 proto_tree_add_text(tree, tvb, offset, 4,
252 "Doubleword Param: %u (0x%08X)", LParam, LParam);
259 add_byte_param(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
260 proto_tree *tree, int convert, int hf_index)
265 proto_tree_add_item(tree, hf_index, tvb, offset, count, TRUE);
268 BParam = tvb_get_guint8(tvb, offset);
269 proto_tree_add_text(tree, tvb, offset, count,
270 "Byte Param: %u (0x%02X)",
273 proto_tree_add_text(tree, tvb, offset, count,
274 "Bytes Param: %s, type is wrong",
275 tvb_bytes_to_str(tvb, offset, count));
283 add_pad_param(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
284 proto_tree *tree, int convert, int hf_index)
287 * This is for parameters that have descriptor entries but that
288 * are, in practice, just padding.
295 add_null_pointer_param(tvbuff_t *tvb, int offset, int count,
296 packet_info *pinfo, proto_tree *tree, int convert, int hf_index)
298 if (hf_index != -1) {
299 proto_tree_add_text(tree, tvb, offset, 0,
301 proto_registrar_get_name(hf_index));
303 proto_tree_add_text(tree, tvb, offset, 0,
304 "String Param (Null pointer)");
309 add_string_param(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
310 proto_tree *tree, int convert, int hf_index)
314 string_len = tvb_strsize(tvb, offset);
315 if (hf_index != -1) {
316 proto_tree_add_item(tree, hf_index, tvb, offset, string_len,
319 proto_tree_add_text(tree, tvb, offset, string_len,
321 tvb_format_text(tvb, offset, string_len));
323 offset += string_len;
328 get_pointer_value(tvbuff_t *tvb, int offset, int convert, int *cptrp, int *lenp)
333 /* pointer to string */
334 cptr = (tvb_get_letohl(tvb, offset)&0xffff)-convert;
338 if (tvb_offset_exists(tvb, cptr) &&
339 (string_len = tvb_strnlen(tvb, cptr, -1)) != -1) {
340 string_len++; /* include the terminating '\0' */
342 return tvb_format_text(tvb, cptr, string_len - 1);
348 add_pointer_param(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
349 proto_tree *tree, int convert, int hf_index)
355 string = get_pointer_value(tvb, offset, convert, &cptr, &string_len);
359 if (string != NULL) {
360 if (hf_index != -1) {
361 proto_tree_add_item(tree, hf_index, tvb, cptr,
364 proto_tree_add_text(tree, tvb, cptr, string_len,
365 "String Param: %s", string);
368 if (hf_index != -1) {
369 proto_tree_add_text(tree, tvb, 0, 0,
370 "%s: <String goes past end of frame>",
371 proto_registrar_get_name(hf_index));
373 proto_tree_add_text(tree, tvb, 0, 0,
374 "String Param: <String goes past end of frame>");
382 add_detail_level(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
383 proto_tree *tree, int convert, int hf_index)
385 struct smb_info *smb_info = pinfo->private_data;
386 smb_transact_info_t *trp = smb_info->sip->extra_info;
389 level = tvb_get_letohs(tvb, offset);
390 if (!pinfo->fd->flags.visited)
391 trp->info_level = level; /* remember this for the response */
392 proto_tree_add_uint(tree, hf_index, tvb, offset, 2, level);
398 add_max_uses(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
399 proto_tree *tree, int convert, int hf_index)
403 WParam = tvb_get_letohs(tvb, offset);
404 if (WParam == 0xffff) { /* -1 */
405 proto_tree_add_uint_format(tree, hf_index, tvb,
408 proto_registrar_get_name(hf_index));
410 proto_tree_add_uint(tree, hf_index, tvb,
418 add_server_type(tvbuff_t *tvb, int offset, int count,
419 packet_info *pinfo, proto_tree *tree, int convert, int hf_index)
421 dissect_smb_server_type_flags(tvb, pinfo, tree, offset, FALSE);
427 add_server_type_info(tvbuff_t *tvb, int offset, int count,
428 packet_info *pinfo, proto_tree *tree, int convert, int hf_index)
430 dissect_smb_server_type_flags(tvb, pinfo, tree, offset, TRUE);
436 add_reltime(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
437 proto_tree *tree, int convert, int hf_index)
441 nstime.secs = tvb_get_letohl(tvb, offset);
443 proto_tree_add_time_format(tree, hf_index, tvb, offset, 4,
444 &nstime, "%s: %s", proto_registrar_get_name(hf_index),
445 time_secs_to_str(nstime.secs));
451 * Sigh. These are for handling Microsoft's annoying almost-UNIX-time-but-
452 * it's-local-time-not-UTC time.
455 add_abstime_common(tvbuff_t *tvb, int offset, int count,
456 packet_info *pinfo, proto_tree *tree, int convert, int hf_index,
457 const char *absent_name)
462 nstime.secs = tvb_get_letohl(tvb, offset);
464 if (nstime.secs == -1) {
465 proto_tree_add_time_format(tree, hf_index, tvb, offset, 4,
466 &nstime, "%s: %s", proto_registrar_get_name(hf_index),
470 * Run it through "gmtime()" to break it down, and then
471 * run it through "mktime()" to put it back together
474 tmp = gmtime(&nstime.secs);
475 tmp->tm_isdst = -1; /* we don't know if it's DST or not */
476 nstime.secs = mktime(tmp);
477 proto_tree_add_time(tree, hf_index, tvb, offset, 4,
485 add_abstime_absent_never(tvbuff_t *tvb, int offset, int count,
486 packet_info *pinfo, proto_tree *tree, int convert, int hf_index)
488 return add_abstime_common(tvb, offset, count, pinfo, tree,
489 convert, hf_index, "Never");
493 add_abstime_absent_unknown(tvbuff_t *tvb, int offset, int count,
494 packet_info *pinfo, proto_tree *tree, int convert, int hf_index)
496 return add_abstime_common(tvb, offset, count, pinfo, tree,
497 convert, hf_index, "Unknown");
501 add_nlogons(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
502 proto_tree *tree, int convert, int hf_index)
506 nlogons = tvb_get_letohs(tvb, offset);
507 if (nlogons == 0xffff) /* -1 */
508 proto_tree_add_uint_format(tree, hf_index, tvb, offset, 2,
509 nlogons, "%s: Unknown",
510 proto_registrar_get_name(hf_index));
512 proto_tree_add_uint(tree, hf_index, tvb, offset, 2,
519 add_max_storage(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
520 proto_tree *tree, int convert, int hf_index)
524 max_storage = tvb_get_letohl(tvb, offset);
525 if (max_storage == 0xffffffff)
526 proto_tree_add_uint_format(tree, hf_index, tvb, offset, 4,
527 max_storage, "%s: No limit",
528 proto_registrar_get_name(hf_index));
530 proto_tree_add_uint(tree, hf_index, tvb, offset, 4,
537 add_logon_hours(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
538 proto_tree *tree, int convert, int hf_index)
542 /* pointer to string */
543 cptr = (tvb_get_letohl(tvb, offset)&0xffff)-convert;
547 /* XXX - should actually carve up the bits */
548 proto_tree_add_item(tree, hf_index, tvb, cptr, 21, TRUE);
554 add_tzoffset(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
555 proto_tree *tree, int convert, int hf_index)
559 tzoffset = tvb_get_letohs(tvb, offset);
561 proto_tree_add_int_format(tree, hf_tzoffset, tvb, offset, 2,
562 tzoffset, "%s: %s east of UTC",
563 proto_registrar_get_name(hf_index),
564 time_secs_to_str(-tzoffset*60));
565 } else if (tzoffset > 0) {
566 proto_tree_add_int_format(tree, hf_tzoffset, tvb, offset, 2,
567 tzoffset, "%s: %s west of UTC",
568 proto_registrar_get_name(hf_index),
569 time_secs_to_str(tzoffset*60));
571 proto_tree_add_int_format(tree, hf_tzoffset, tvb, offset, 2,
572 tzoffset, "%s: at UTC",
573 proto_registrar_get_name(hf_index));
580 add_timeinterval(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
581 proto_tree *tree, int convert, int hf_index)
583 guint16 timeinterval;
585 timeinterval = tvb_get_letohs(tvb, offset);
586 proto_tree_add_uint_format(tree, hf_timeinterval, tvb, offset, 2,
587 timeinterval, "%s: %f seconds", proto_registrar_get_name(hf_index),
594 add_logon_args(tvbuff_t *tvb, int offset, int count, packet_info *pinfo,
595 proto_tree *tree, int convert, int hf_index)
598 proto_tree_add_text(tree, tvb, offset, count,
599 "Bogus NetWkstaUserLogon parameters: length is %d, should be 54",
606 proto_tree_add_item(tree, hf_user_name, tvb, offset, 21, TRUE);
613 proto_tree_add_item(tree, hf_password, tvb, offset, 15, TRUE);
619 /* workstation name */
620 proto_tree_add_item(tree, hf_workstation_name, tvb, offset, 16, TRUE);
626 * The following data structure describes the Remote API requests we
629 * Simply fill in the number and parameter information.
630 * Try to keep them in order.
632 * We will extend this data structure as we try to decode more.
636 * This is a pointer to a function to process an item.
638 typedef int (*item_func)(tvbuff_t *, int, int, packet_info *, proto_tree *,
642 * Type of an item; determines what parameter strings are valid for
646 PARAM_NONE, /* for the end-of-list stopper */
647 PARAM_WORD, /* 'W' or 'h' - 16-bit word */
648 PARAM_DWORD, /* 'D' or 'i' - 32-bit word */
649 PARAM_BYTES, /* 'B' or 'b' or 'g' or 'O' - one or more bytes */
650 PARAM_STRINGZ, /* 'z' or 'O' - null-terminated string */
654 * This structure describes an item; "hf_index" points to the index
655 * for the field corresponding to that item, "func" points to the
656 * function to use to add that item to the tree, and "type" is the
657 * type that the item is supposed to have.
666 * This structure describes a list of items; each list of items
667 * has a corresponding detail level.
671 const item_t *item_list;
677 proto_item *(*req_data_item)(tvbuff_t *, packet_info *,
680 const item_t *req_data;
681 const item_t *req_aux_data;
683 proto_item *(*resp_data_item)(tvbuff_t *, packet_info *,
686 proto_item *(*resp_data_element_item)(tvbuff_t *, packet_info *,
688 gint *ett_resp_data_element_item;
689 const item_list_t *resp_data_list;
690 const item_t *resp_aux_data;
693 static int no_hf = -1; /* for padding crap */
695 static const item_t lm_params_req_netshareenum[] = {
696 { &hf_detail_level, add_detail_level, PARAM_WORD },
697 { &hf_recv_buf_len, add_word_param, PARAM_WORD },
698 { NULL, NULL, PARAM_NONE }
701 static const item_t lm_params_resp_netshareenum[] = {
702 { &hf_acount, add_word_param, PARAM_WORD },
703 { NULL, NULL, PARAM_NONE }
707 * Create a subtree for all available shares.
710 netshareenum_shares_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
714 return proto_tree_add_text(tree, tvb, offset,
715 tvb_length_remaining(tvb, offset),
722 * Create a subtree for a share.
725 netshareenum_share_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
729 return proto_tree_add_text(tree, tvb, offset,
730 tvb_length_remaining(tvb, offset),
731 "Share %.13s", tvb_get_ptr(tvb, offset, 13));
736 static const item_t lm_null[] = {
737 { NULL, NULL, PARAM_NONE }
740 static const item_list_t lm_null_list[] = {
744 static const item_t lm_data_resp_netshareenum_1[] = {
745 { &hf_share_name, add_byte_param, PARAM_BYTES },
746 { &no_hf, add_pad_param, PARAM_BYTES },
747 { &hf_share_type, add_word_param, PARAM_WORD },
748 { &hf_share_comment, add_pointer_param, PARAM_STRINGZ },
749 { NULL, NULL, PARAM_NONE }
752 static const item_list_t lm_data_resp_netshareenum[] = {
753 { 1, lm_data_resp_netshareenum_1 },
757 static const item_t lm_params_req_netsharegetinfo[] = {
758 { &hf_share_name, add_string_param, PARAM_STRINGZ },
759 { &hf_detail_level, add_detail_level, PARAM_WORD },
760 { NULL, NULL, PARAM_NONE }
763 static const item_t lm_params_resp_netsharegetinfo[] = {
764 { &hf_abytes, add_word_param, PARAM_WORD },
765 { NULL, NULL, PARAM_NONE }
768 static const item_t lm_data_resp_netsharegetinfo_0[] = {
769 { &hf_share_name, add_byte_param, PARAM_BYTES },
770 { NULL, NULL, PARAM_NONE }
773 static const item_t lm_data_resp_netsharegetinfo_1[] = {
774 { &hf_share_name, add_byte_param, PARAM_BYTES },
775 { &no_hf, add_pad_param, PARAM_BYTES },
776 { &hf_share_type, add_word_param, PARAM_WORD },
777 { &hf_share_comment, add_pointer_param, PARAM_STRINGZ },
778 { NULL, NULL, PARAM_NONE }
781 static const item_t lm_data_resp_netsharegetinfo_2[] = {
782 { &hf_share_name, add_byte_param, PARAM_BYTES },
783 { &no_hf, add_pad_param, PARAM_BYTES },
784 { &hf_share_type, add_word_param, PARAM_WORD },
785 { &hf_share_comment, add_pointer_param, PARAM_STRINGZ },
786 { &hf_share_permissions, add_word_param, PARAM_WORD }, /* XXX - do as bit fields */
787 { &hf_share_max_uses, add_max_uses, PARAM_WORD },
788 { &hf_share_current_uses, add_word_param, PARAM_WORD },
789 { &hf_share_path, add_pointer_param, PARAM_STRINGZ },
790 { &hf_share_password, add_byte_param, PARAM_BYTES },
791 { NULL, NULL, PARAM_NONE }
794 static const item_list_t lm_data_resp_netsharegetinfo[] = {
795 { 0, lm_data_resp_netsharegetinfo_0 },
796 { 1, lm_data_resp_netsharegetinfo_1 },
797 { 2, lm_data_resp_netsharegetinfo_2 },
801 static const item_t lm_params_req_netservergetinfo[] = {
802 { &hf_detail_level, add_detail_level, PARAM_WORD },
803 { NULL, NULL, PARAM_NONE }
806 static const item_t lm_params_resp_netservergetinfo[] = {
807 { &hf_abytes, add_word_param, PARAM_WORD },
808 { NULL, NULL, PARAM_NONE }
811 static const item_t lm_data_serverinfo_0[] = {
812 { &hf_server_name, add_byte_param, PARAM_BYTES },
813 { NULL, NULL, PARAM_NONE }
816 static const item_t lm_data_serverinfo_1[] = {
817 { &hf_server_name, add_byte_param, PARAM_BYTES },
818 { &hf_server_major, add_byte_param, PARAM_BYTES },
819 { &hf_server_minor, add_byte_param, PARAM_BYTES },
820 { &no_hf, add_server_type, PARAM_DWORD },
821 { &hf_server_comment, add_pointer_param, PARAM_STRINGZ },
822 { NULL, NULL, PARAM_NONE }
825 static const item_list_t lm_data_serverinfo[] = {
826 { 0, lm_data_serverinfo_0 },
827 { 1, lm_data_serverinfo_1 },
831 static const item_t lm_params_req_netusergetinfo[] = {
832 { &hf_detail_level, add_detail_level, PARAM_WORD },
833 { NULL, NULL, PARAM_NONE }
836 static const item_t lm_params_resp_netusergetinfo[] = {
837 { &hf_abytes, add_word_param, PARAM_WORD },
838 { NULL, NULL, PARAM_NONE }
841 static const item_t lm_data_resp_netusergetinfo_11[] = {
842 { &hf_user_name, add_byte_param, PARAM_BYTES },
843 { &no_hf, add_pad_param, PARAM_BYTES },
844 { &hf_user_comment, add_pointer_param, PARAM_STRINGZ },
845 { &hf_full_name, add_pointer_param, PARAM_STRINGZ },
846 { &hf_privilege_level, add_word_param, PARAM_WORD },
847 { &hf_operator_privileges, add_dword_param, PARAM_DWORD },
848 { &hf_password_age, add_reltime, PARAM_DWORD },
849 { &hf_homedir, add_pointer_param, PARAM_STRINGZ },
850 { &hf_parameters, add_pointer_param, PARAM_STRINGZ },
851 { &hf_last_logon, add_abstime_absent_unknown, PARAM_DWORD },
852 { &hf_last_logoff, add_abstime_absent_unknown, PARAM_DWORD },
853 { &hf_bad_pw_count, add_word_param, PARAM_WORD },
854 { &hf_num_logons, add_nlogons, PARAM_WORD },
855 { &hf_logon_server, add_pointer_param, PARAM_STRINGZ },
856 { &hf_country_code, add_word_param, PARAM_WORD },
857 { &hf_workstations, add_pointer_param, PARAM_STRINGZ },
858 { &hf_max_storage, add_max_storage, PARAM_DWORD },
859 { &hf_logon_hours, add_logon_hours, PARAM_DWORD },
860 { &hf_code_page, add_word_param, PARAM_WORD },
861 { NULL, NULL, PARAM_NONE }
864 static const item_list_t lm_data_resp_netusergetinfo[] = {
865 { 11, lm_data_resp_netusergetinfo_11 },
870 * Has no detail level; make it the default.
872 static const item_t lm_data_resp_netremotetod_nolevel[] = {
873 { &hf_current_time, add_abstime_absent_unknown, PARAM_DWORD },
874 { &hf_msecs, add_dword_param, PARAM_DWORD },
875 { &hf_hour, add_byte_param, PARAM_BYTES },
876 { &hf_minute, add_byte_param, PARAM_BYTES },
877 { &hf_second, add_byte_param, PARAM_BYTES },
878 { &hf_hundredths, add_byte_param, PARAM_BYTES },
879 { &hf_tzoffset, add_tzoffset, PARAM_WORD },
880 { &hf_timeinterval, add_timeinterval, PARAM_WORD },
881 { &hf_day, add_byte_param, PARAM_BYTES },
882 { &hf_month, add_byte_param, PARAM_BYTES },
883 { &hf_year, add_word_param, PARAM_WORD },
884 { &hf_weekday, add_byte_param, PARAM_BYTES },
885 { NULL, NULL, PARAM_NONE }
888 static const item_list_t lm_data_resp_netremotetod[] = {
889 { -1, lm_data_resp_netremotetod_nolevel },
892 static const item_t lm_params_req_netserverenum2[] = {
893 { &hf_detail_level, add_detail_level, PARAM_WORD },
894 { &no_hf, add_server_type_info, PARAM_DWORD },
895 { &hf_enumeration_domain, add_string_param, PARAM_STRINGZ },
896 { NULL, NULL, PARAM_NONE }
900 * Create a subtree for all servers.
903 netserverenum2_servers_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
907 return proto_tree_add_text(tree, tvb, offset,
908 tvb_length_remaining(tvb, offset), "Servers");
914 * Create a subtree for a share.
917 netserverenum2_server_entry(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
921 return proto_tree_add_text(tree, tvb, offset,
922 tvb_length_remaining(tvb, offset),
923 "Server %.16s", tvb_get_ptr(tvb, offset, 16));
927 static const item_t lm_params_resp_netserverenum2[] = {
928 { &hf_acount, add_word_param, PARAM_WORD },
929 { NULL, NULL, PARAM_NONE }
932 static const item_t lm_params_req_netwkstagetinfo[] = {
933 { &hf_detail_level, add_detail_level, PARAM_WORD },
934 { NULL, NULL, PARAM_NONE }
937 static const item_t lm_params_resp_netwkstagetinfo[] = {
938 { &hf_abytes, add_word_param, PARAM_WORD },
939 { NULL, NULL, PARAM_NONE }
942 static const item_t lm_data_resp_netwkstagetinfo_10[] = {
943 { &hf_computer_name, add_pointer_param, PARAM_STRINGZ },
944 { &hf_user_name, add_pointer_param, PARAM_STRINGZ },
945 { &hf_workstation_domain, add_pointer_param, PARAM_STRINGZ },
946 { &hf_workstation_major, add_byte_param, PARAM_BYTES },
947 { &hf_workstation_minor, add_byte_param, PARAM_BYTES },
948 { &hf_logon_domain, add_pointer_param, PARAM_STRINGZ },
949 { &hf_other_domains, add_pointer_param, PARAM_STRINGZ },
950 { NULL, NULL, PARAM_NONE }
953 static const item_list_t lm_data_resp_netwkstagetinfo[] = {
954 { 10, lm_data_resp_netwkstagetinfo_10 },
958 static const item_t lm_params_req_netwkstauserlogon[] = {
959 { &no_hf, add_pointer_param, PARAM_STRINGZ },
960 { &no_hf, add_pointer_param, PARAM_STRINGZ },
961 { &hf_detail_level, add_detail_level, PARAM_WORD },
962 { &no_hf, add_logon_args, PARAM_BYTES },
963 { &hf_ustruct_size, add_word_param, PARAM_WORD },
964 { NULL, NULL, PARAM_NONE }
967 static const item_t lm_params_resp_netwkstauserlogon[] = {
968 { &hf_abytes, add_word_param, PARAM_WORD },
969 { NULL, NULL, PARAM_NONE }
972 static const item_t lm_data_resp_netwkstauserlogon_1[] = {
973 { &hf_logon_code, add_word_param, PARAM_WORD },
974 { &hf_user_name, add_byte_param, PARAM_BYTES },
975 { &no_hf, add_pad_param, PARAM_BYTES },
976 { &hf_privilege_level, add_word_param, PARAM_WORD },
977 { &hf_operator_privileges, add_dword_param, PARAM_DWORD },
978 { &hf_num_logons, add_nlogons, PARAM_WORD },
979 { &hf_bad_pw_count, add_word_param, PARAM_WORD },
980 { &hf_last_logon, add_abstime_absent_unknown, PARAM_DWORD },
981 { &hf_last_logoff, add_abstime_absent_unknown, PARAM_DWORD },
982 { &hf_logoff_time, add_abstime_absent_never, PARAM_DWORD },
983 { &hf_kickoff_time, add_abstime_absent_never, PARAM_DWORD },
984 { &hf_password_age, add_reltime, PARAM_DWORD },
985 { &hf_password_can_change, add_abstime_absent_never, PARAM_DWORD },
986 { &hf_password_must_change, add_abstime_absent_never, PARAM_DWORD },
987 { &hf_server_name, add_pointer_param, PARAM_STRINGZ },
988 { &hf_logon_domain, add_pointer_param, PARAM_STRINGZ },
989 { &hf_script_path, add_pointer_param, PARAM_STRINGZ },
990 { &hf_reserved, add_dword_param, PARAM_DWORD },
991 { NULL, NULL, PARAM_NONE }
994 static const item_list_t lm_data_resp_netwkstauserlogon[] = {
995 { 1, lm_data_resp_netwkstauserlogon_1 },
999 static const item_t lm_params_req_netwkstauserlogoff[] = {
1000 { &hf_user_name, add_byte_param, PARAM_BYTES },
1001 { &no_hf, add_pad_param, PARAM_BYTES },
1002 { &hf_workstation_name, add_byte_param, PARAM_BYTES },
1003 { NULL, NULL, PARAM_NONE }
1006 static const item_t lm_params_resp_netwkstauserlogoff[] = {
1007 { &hf_abytes, add_word_param, PARAM_WORD },
1008 { NULL, NULL, PARAM_NONE }
1011 static const item_t lm_data_resp_netwkstauserlogoff_1[] = {
1012 { &hf_logoff_code, add_word_param, PARAM_WORD },
1013 { &hf_duration, add_reltime, PARAM_DWORD },
1014 { &hf_num_logons, add_nlogons, PARAM_WORD },
1015 { NULL, NULL, PARAM_NONE }
1018 static const item_list_t lm_data_resp_netwkstauserlogoff[] = {
1019 { 1, lm_data_resp_netwkstauserlogoff_1 },
1023 static const item_t lm_params_req_samoemchangepassword[] = {
1024 { &hf_user_name, add_string_param, PARAM_STRINGZ },
1025 { NULL, NULL, PARAM_NONE }
1028 static const item_t lm_data_req_samoemchangepassword[] = {
1029 { &hf_new_password, add_byte_param, PARAM_BYTES },
1030 { &hf_old_password, add_byte_param, PARAM_BYTES },
1031 { NULL, NULL, PARAM_NONE }
1034 #define LANMAN_NETSHAREENUM 0
1035 #define LANMAN_NETSHAREGETINFO 1
1036 #define LANMAN_NETSERVERGETINFO 13
1037 #define LANMAN_NETGROUPGETUSERS 52
1038 #define LANMAN_NETUSERGETINFO 56
1039 #define LANMAN_NETUSERGETGROUPS 59
1040 #define LANMAN_NETWKSTAGETINFO 63
1041 #define LANMAN_DOSPRINTQENUM 69
1042 #define LANMAN_DOSPRINTQGETINFO 70
1043 #define LANMAN_WPRINTQUEUEPAUSE 74
1044 #define LANMAN_WPRINTQUEUERESUME 75
1045 #define LANMAN_WPRINTJOBENUMERATE 76
1046 #define LANMAN_WPRINTJOBGETINFO 77
1047 #define LANMAN_RDOSPRINTJOBDEL 81
1048 #define LANMAN_RDOSPRINTJOBPAUSE 82
1049 #define LANMAN_RDOSPRINTJOBRESUME 83
1050 #define LANMAN_WPRINTDESTENUM 84
1051 #define LANMAN_WPRINTDESTGETINFO 85
1052 #define LANMAN_NETREMOTETOD 91
1053 #define LANMAN_WPRINTQUEUEPURGE 103
1054 #define LANMAN_NETSERVERENUM2 104
1055 #define LANMAN_WACCESSGETUSERPERMS 105
1056 #define LANMAN_SETUSERPASSWORD 115
1057 #define LANMAN_NETWKSTAUSERLOGON 132
1058 #define LANMAN_NETWKSTAUSERLOGOFF 133
1059 #define LANMAN_PRINTJOBINFO 147
1060 #define LANMAN_WPRINTDRIVERENUM 205
1061 #define LANMAN_WPRINTQPROCENUM 206
1062 #define LANMAN_WPRINTPORTENUM 207
1063 #define LANMAN_SAMOEMCHANGEPASSWORD 214
1065 static const struct lanman_desc lmd[] = {
1066 { LANMAN_NETSHAREENUM,
1067 lm_params_req_netshareenum,
1072 lm_params_resp_netshareenum,
1073 netshareenum_shares_list,
1075 netshareenum_share_entry,
1077 lm_data_resp_netshareenum,
1080 { LANMAN_NETSHAREGETINFO,
1081 lm_params_req_netsharegetinfo,
1086 lm_params_resp_netsharegetinfo,
1091 lm_data_resp_netsharegetinfo,
1094 { LANMAN_NETSERVERGETINFO,
1095 lm_params_req_netservergetinfo,
1100 lm_params_resp_netservergetinfo,
1108 { LANMAN_NETUSERGETINFO,
1109 lm_params_req_netusergetinfo,
1114 lm_params_resp_netusergetinfo,
1119 lm_data_resp_netusergetinfo,
1122 { LANMAN_NETREMOTETOD,
1133 lm_data_resp_netremotetod,
1136 { LANMAN_NETSERVERENUM2,
1137 lm_params_req_netserverenum2,
1142 lm_params_resp_netserverenum2,
1143 netserverenum2_servers_list,
1144 &ett_lanman_servers,
1145 netserverenum2_server_entry,
1150 { LANMAN_NETWKSTAGETINFO,
1151 lm_params_req_netwkstagetinfo,
1156 lm_params_resp_netwkstagetinfo,
1161 lm_data_resp_netwkstagetinfo,
1164 { LANMAN_NETWKSTAUSERLOGON,
1165 lm_params_req_netwkstauserlogon,
1170 lm_params_resp_netwkstauserlogon,
1175 lm_data_resp_netwkstauserlogon,
1178 { LANMAN_NETWKSTAUSERLOGOFF,
1179 lm_params_req_netwkstauserlogoff,
1184 lm_params_resp_netwkstauserlogoff,
1189 lm_data_resp_netwkstauserlogoff,
1192 { LANMAN_SAMOEMCHANGEPASSWORD,
1193 lm_params_req_samoemchangepassword,
1196 lm_data_req_samoemchangepassword,
1221 static const struct lanman_desc *
1222 find_lanman(int lanman_num)
1226 for (i = 0; lmd[i].lanman_num != -1; i++) {
1227 if (lmd[i].lanman_num == lanman_num)
1233 static const guchar *
1234 get_count(const guchar *desc, int *countp)
1236 int count = 0, off = 0;
1239 if (!isdigit(*desc)) {
1240 *countp = 1; /* no count was supplied */
1244 while ((c = *desc) != '\0' && isdigit(c)) {
1245 count = (count * 10) + c - '0';
1249 *countp = count; /* XXX - what if it's 0? */
1254 dissect_request_parameters(tvbuff_t *tvb, int offset, packet_info *pinfo,
1255 proto_tree *tree, const guchar *desc, const item_t *items,
1256 gboolean *has_data_p)
1264 *has_data_p = FALSE;
1265 while ((c = *desc++) != '\0') {
1270 * A 16-bit word value in the request.
1272 if (items->func == NULL) {
1274 * We've run out of items in the table;
1275 * fall back on the default.
1277 offset = add_word_param(tvb, offset, 0, pinfo,
1279 } else if (items->type != PARAM_WORD) {
1281 * Descriptor character is 'W', but this
1282 * isn't a word parameter.
1284 WParam = tvb_get_letohs(tvb, offset);
1285 proto_tree_add_text(tree, tvb, offset, 2,
1286 "%s: Value is %u (0x%04X), type is wrong (W)",
1287 (*items->hf_index == -1) ?
1289 proto_registrar_get_name(*items->hf_index),
1294 offset = (*items->func)(tvb, offset, 0, pinfo,
1295 tree, 0, *items->hf_index);
1302 * A 32-bit doubleword value in the request.
1304 if (items->func == NULL) {
1306 * We've run out of items in the table;
1307 * fall back on the default.
1309 offset = add_dword_param(tvb, offset, 0, pinfo,
1311 } else if (items->type != PARAM_DWORD) {
1313 * Descriptor character is 'D', but this
1314 * isn't a doubleword parameter.
1316 LParam = tvb_get_letohl(tvb, offset);
1317 proto_tree_add_text(tree, tvb, offset, 2,
1318 "%s: Value is %u (0x%08X), type is wrong (D)",
1319 (*items->hf_index == -1) ?
1320 "Doubleword Param" :
1321 proto_registrar_get_name(*items->hf_index),
1326 offset = (*items->func)(tvb, offset, 0, pinfo,
1327 tree, 0, *items->hf_index);
1334 * A byte or multi-byte value in the request.
1336 desc = get_count(desc, &count);
1337 if (items->func == NULL) {
1339 * We've run out of items in the table;
1340 * fall back on the default.
1342 offset = add_byte_param(tvb, offset, count,
1343 pinfo, tree, 0, -1);
1344 } else if (items->type != PARAM_BYTES) {
1346 * Descriptor character is 'b', but this
1347 * isn't a byte/bytes parameter.
1349 proto_tree_add_text(tree, tvb, offset, count,
1350 "%s: Value is %s, type is wrong (b)",
1351 (*items->hf_index == -1) ?
1353 proto_registrar_get_name(*items->hf_index),
1354 tvb_bytes_to_str(tvb, offset, count));
1358 offset = (*items->func)(tvb, offset, count,
1359 pinfo, tree, 0, *items->hf_index);
1368 if (items->func == NULL) {
1370 * We've run out of items in the table;
1371 * fall back on the default.
1373 add_null_pointer_param(tvb, offset, 0,
1374 pinfo, tree, 0, -1);
1377 * If "*items->hf_index" is -1, this is
1378 * a reserved must-be-null field; don't
1379 * clutter the protocol tree by putting
1382 if (*items->hf_index != -1) {
1383 add_null_pointer_param(tvb,
1384 offset, 0, pinfo, tree, 0,
1393 * A null-terminated ASCII string.
1395 if (items->func == NULL) {
1397 * We've run out of items in the table;
1398 * fall back on the default.
1400 offset = add_string_param(tvb, offset, 0,
1401 pinfo, tree, 0, -1);
1402 } else if (items->type != PARAM_STRINGZ) {
1404 * Descriptor character is 'z', but this
1405 * isn't a string parameter.
1407 string_len = tvb_strsize(tvb, offset);
1408 proto_tree_add_text(tree, tvb, offset, string_len,
1409 "%s: Value is %s, type is wrong (z)",
1410 (*items->hf_index == -1) ?
1412 proto_registrar_get_name(*items->hf_index),
1413 tvb_format_text(tvb, offset, string_len));
1414 offset += string_len;
1417 offset = (*items->func)(tvb, offset, 0,
1418 pinfo, tree, 0, *items->hf_index);
1425 * One or more pad bytes.
1427 desc = get_count(desc, &count);
1428 proto_tree_add_text(tree, tvb, offset, count,
1435 * 16-bit receive buffer length.
1437 proto_tree_add_item(tree, hf_recv_buf_len, tvb,
1444 * 32-bit send buffer offset.
1445 * This appears not to be sent over the wire.
1452 * 16-bit send buffer length.
1453 * This also appears not to be sent over the wire.
1465 dissect_response_parameters(tvbuff_t *tvb, int offset, packet_info *pinfo,
1466 proto_tree *tree, const guchar *desc, const item_t *items,
1467 gboolean *has_data_p, gboolean *has_ent_count_p, guint16 *ent_count_p)
1474 *has_data_p = FALSE;
1475 *has_ent_count_p = FALSE;
1476 while ((c = *desc++) != '\0') {
1481 * 32-bit receive buffer offset.
1488 * A byte or series of bytes is returned.
1490 desc = get_count(desc, &count);
1491 if (items->func == NULL) {
1493 * We've run out of items in the table;
1494 * fall back on the default.
1496 offset = add_byte_param(tvb, offset, count,
1497 pinfo, tree, 0, -1);
1498 } else if (items->type != PARAM_BYTES) {
1500 * Descriptor character is 'b', but this
1501 * isn't a byte/bytes parameter.
1503 proto_tree_add_text(tree, tvb, offset, count,
1504 "%s: Value is %s, type is wrong (g)",
1505 (*items->hf_index == -1) ?
1507 proto_registrar_get_name(*items->hf_index),
1508 tvb_bytes_to_str(tvb, offset, count));
1512 offset = (*items->func)(tvb, offset, count,
1513 pinfo, tree, 0, *items->hf_index);
1520 * A 16-bit word is received.
1522 if (items->func == NULL) {
1524 * We've run out of items in the table;
1525 * fall back on the default.
1527 offset = add_word_param(tvb, offset, 0, pinfo,
1529 } else if (items->type != PARAM_WORD) {
1531 * Descriptor character is 'h', but this
1532 * isn't a word parameter.
1534 WParam = tvb_get_letohs(tvb, offset);
1535 proto_tree_add_text(tree, tvb, offset, 2,
1536 "%s: Value is %u (0x%04X), type is wrong (W)",
1537 (*items->hf_index == -1) ?
1539 proto_registrar_get_name(*items->hf_index),
1544 offset = (*items->func)(tvb, offset, 0, pinfo,
1545 tree, 0, *items->hf_index);
1552 * A 32-bit doubleword is received.
1554 if (items->func == NULL) {
1556 * We've run out of items in the table;
1557 * fall back on the default.
1559 offset = add_dword_param(tvb, offset, 0, pinfo,
1561 } else if (items->type != PARAM_DWORD) {
1563 * Descriptor character is 'i', but this
1564 * isn't a doubleword parameter.
1566 LParam = tvb_get_letohl(tvb, offset);
1567 proto_tree_add_text(tree, tvb, offset, 2,
1568 "%s: Value is %u (0x%08X), type is wrong (i)",
1569 (*items->hf_index == -1) ?
1570 "Doubleword Param" :
1571 proto_registrar_get_name(*items->hf_index),
1576 offset = (*items->func)(tvb, offset, 0, pinfo,
1577 tree, 0, *items->hf_index);
1584 * A 16-bit entry count is returned.
1586 WParam = tvb_get_letohs(tvb, offset);
1587 proto_tree_add_uint(tree, hf_ecount, tvb, offset, 2,
1590 *has_ent_count_p = TRUE;
1591 *ent_count_p = WParam; /* Save this for later retrieval */
1602 dissect_transact_data(tvbuff_t *tvb, int offset, int convert,
1603 packet_info *pinfo, proto_tree *tree, const guchar *desc,
1604 const item_t *items, guint16 *aux_count_p)
1614 if (aux_count_p != NULL)
1617 while ((c = *desc++) != '\0') {
1622 * A 16-bit word value.
1623 * XXX - handle the count?
1625 desc = get_count(desc, &count);
1626 if (items->func == NULL) {
1628 * We've run out of items in the table;
1629 * fall back on the default.
1631 offset = add_word_param(tvb, offset, 0, pinfo,
1633 } else if (items->type != PARAM_WORD) {
1635 * Descriptor character is 'W', but this
1636 * isn't a word parameter.
1638 WParam = tvb_get_letohs(tvb, offset);
1639 proto_tree_add_text(tree, tvb, offset, 2,
1640 "%s: Value is %u (0x%04X), type is wrong (W)",
1641 (*items->hf_index == -1) ?
1643 proto_registrar_get_name(*items->hf_index),
1648 offset = (*items->func)(tvb, offset, 0, pinfo,
1649 tree, convert, *items->hf_index);
1656 * A 32-bit doubleword value.
1657 * XXX - handle the count?
1659 desc = get_count(desc, &count);
1660 if (items->func == NULL) {
1662 * We've run out of items in the table;
1663 * fall back on the default.
1665 offset = add_dword_param(tvb, offset, 0, pinfo,
1667 } else if (items->type != PARAM_DWORD) {
1669 * Descriptor character is 'D', but this
1670 * isn't a doubleword parameter.
1672 LParam = tvb_get_letohl(tvb, offset);
1673 proto_tree_add_text(tree, tvb, offset, 2,
1674 "%s: Value is %u (0x%08X), type is wrong (D)",
1675 (*items->hf_index == -1) ?
1676 "Doubleword Param" :
1677 proto_registrar_get_name(*items->hf_index),
1682 offset = (*items->func)(tvb, offset, 0, pinfo,
1683 tree, convert, *items->hf_index);
1690 * A byte or multi-byte value.
1692 desc = get_count(desc, &count);
1693 if (items->func == NULL) {
1695 * We've run out of items in the table;
1696 * fall back on the default.
1698 offset = add_byte_param(tvb, offset, count,
1699 pinfo, tree, convert, -1);
1700 } else if (items->type != PARAM_BYTES) {
1702 * Descriptor character is 'B', but this
1703 * isn't a byte/bytes parameter.
1705 proto_tree_add_text(tree, tvb, offset, count,
1706 "%s: Value is %s, type is wrong (B)",
1707 (*items->hf_index == -1) ?
1709 proto_registrar_get_name(*items->hf_index),
1710 tvb_bytes_to_str(tvb, offset, count));
1714 offset = (*items->func)(tvb, offset, count,
1715 pinfo, tree, convert, *items->hf_index);
1724 if (items->func == NULL) {
1726 * We've run out of items in the table;
1727 * fall back on the default.
1729 add_null_pointer_param(tvb, offset, 0,
1730 pinfo, tree, convert, -1);
1733 * If "*items->hf_index" is -1, this is
1734 * a reserved must-be-null field; don't
1735 * clutter the protocol tree by putting
1738 if (*items->hf_index != -1) {
1739 add_null_pointer_param(tvb,
1740 offset, 0, pinfo, tree, convert,
1749 * A pointer to a null-terminated ASCII string.
1751 if (items->func == NULL) {
1753 * We've run out of items in the table;
1754 * fall back on the default.
1756 offset = add_pointer_param(tvb, offset, 0,
1757 pinfo, tree, convert, -1);
1758 } else if (items->type != PARAM_STRINGZ) {
1760 * Descriptor character is 'z', but this
1761 * isn't a string parameter.
1763 string = get_pointer_value(tvb, offset,
1764 convert, &cptr, &string_len);
1766 proto_tree_add_text(tree, tvb, cptr, string_len,
1767 "%s: Value is %s, type is wrong (z)",
1768 (*items->hf_index == -1) ?
1770 proto_registrar_get_name(*items->hf_index),
1774 offset = (*items->func)(tvb, offset, 0,
1775 pinfo, tree, convert, *items->hf_index);
1782 * 16-bit auxiliary data structure count.
1785 WParam = tvb_get_letohs(tvb, offset);
1786 proto_tree_add_text(tree, tvb, offset, 2,
1788 "Auxiliary data structure count",
1791 if (aux_count_p != NULL)
1792 *aux_count_p = WParam; /* Save this for later retrieval */
1802 static const value_string commands[] = {
1803 {LANMAN_NETSHAREENUM, "NetShareEnum"},
1804 {LANMAN_NETSHAREGETINFO, "NetShareGetInfo"},
1805 {LANMAN_NETSERVERGETINFO, "NetServerGetInfo"},
1806 {LANMAN_NETGROUPGETUSERS, "NetGroupGetUsers"},
1807 {LANMAN_NETUSERGETINFO, "NetUserGetInfo"},
1808 {LANMAN_NETUSERGETGROUPS, "NetUserGetGroups"},
1809 {LANMAN_NETWKSTAGETINFO, "NetWkstaGetInfo"},
1810 {LANMAN_DOSPRINTQENUM, "DOSPrintQEnum"},
1811 {LANMAN_DOSPRINTQGETINFO, "DOSPrintQGetInfo"},
1812 {LANMAN_WPRINTQUEUEPAUSE, "WPrintQueuePause"},
1813 {LANMAN_WPRINTQUEUERESUME, "WPrintQueueResume"},
1814 {LANMAN_WPRINTJOBENUMERATE, "WPrintJobEnumerate"},
1815 {LANMAN_WPRINTJOBGETINFO, "WPrintJobGetInfo"},
1816 {LANMAN_RDOSPRINTJOBDEL, "RDOSPrintJobDel"},
1817 {LANMAN_RDOSPRINTJOBPAUSE, "RDOSPrintJobPause"},
1818 {LANMAN_RDOSPRINTJOBRESUME, "RDOSPrintJobResume"},
1819 {LANMAN_WPRINTDESTENUM, "WPrintDestEnum"},
1820 {LANMAN_WPRINTDESTGETINFO, "WPrintDestGetInfo"},
1821 {LANMAN_NETREMOTETOD, "NetRemoteTOD"},
1822 {LANMAN_WPRINTQUEUEPURGE, "WPrintQueuePurge"},
1823 {LANMAN_NETSERVERENUM2, "NetServerEnum2"},
1824 {LANMAN_WACCESSGETUSERPERMS, "WAccessGetUserPerms"},
1825 {LANMAN_SETUSERPASSWORD, "SetUserPassword"},
1826 {LANMAN_NETWKSTAUSERLOGON, "NetWkstaUserLogon"},
1827 {LANMAN_NETWKSTAUSERLOGOFF, "NetWkstaUserLogoff"},
1828 {LANMAN_PRINTJOBINFO, "PrintJobInfo"},
1829 {LANMAN_WPRINTDRIVERENUM, "WPrintDriverEnum"},
1830 {LANMAN_WPRINTQPROCENUM, "WPrintQProcEnum"},
1831 {LANMAN_WPRINTPORTENUM, "WPrintPortEnum"},
1832 {LANMAN_SAMOEMCHANGEPASSWORD, "SamOEMChangePassword"},
1837 dissect_response_data(tvbuff_t *tvb, packet_info *pinfo, int convert,
1838 proto_tree *tree, struct smb_info *smb_info,
1839 const struct lanman_desc *lanman, gboolean has_ent_count,
1842 smb_transact_info_t *trp = smb_info->sip->extra_info;
1843 const item_list_t *resp_data_list;
1844 int offset, start_offset;
1845 const item_t *resp_data;
1846 proto_item *data_item;
1847 proto_tree *data_tree;
1848 proto_item *entry_item;
1849 proto_tree *entry_tree;
1854 * Find the item table for the matching request's detail level.
1856 for (resp_data_list = lanman->resp_data_list;
1857 resp_data_list->level != -1; resp_data_list++) {
1858 if (resp_data_list->level == trp->info_level)
1861 resp_data = resp_data_list->item_list;
1864 if (lanman->resp_data_item != NULL) {
1866 * Create a protocol tree item for the data.
1868 data_item = (*lanman->resp_data_item)(tvb,
1869 pinfo, tree, offset);
1870 data_tree = proto_item_add_subtree(data_item,
1871 *lanman->ett_resp_data);
1874 * Just leave it at the top level.
1880 if (trp->data_descrip == NULL) {
1882 * This could happen if we only dissected
1883 * part of the request to which this is a
1884 * reply, e.g. if the request was split
1885 * across TCP segments and we weren't doing
1886 * TCP desegmentation, or if we had a snapshot
1887 * length that was too short.
1889 * We can't dissect the data; just show it
1892 proto_tree_add_text(tree, tvb, offset,
1893 tvb_length_remaining(tvb, offset),
1894 "Data (no descriptor available)");
1895 offset += tvb_length_remaining(tvb, offset);
1898 * If we have an entry count, show all the entries,
1899 * with each one having a protocol tree item.
1901 * Otherwise, we just show one returned item, with
1902 * no protocol tree item.
1906 for (i = 0; i < ent_count; i++) {
1907 start_offset = offset;
1908 if (has_ent_count) {
1910 * Create a protocol tree item for the
1914 (*lanman->resp_data_element_item)
1915 (tvb, pinfo, data_tree, offset);
1916 entry_tree = proto_item_add_subtree(
1918 *lanman->ett_resp_data_element_item);
1921 * Just leave it at the current
1925 entry_tree = data_tree;
1928 offset = dissect_transact_data(tvb, offset,
1929 convert, pinfo, entry_tree,
1930 trp->data_descrip, resp_data, &aux_count);
1932 /* auxiliary data */
1933 if (trp->aux_data_descrip != NULL) {
1934 for (j = 0; j < aux_count; j++) {
1935 offset = dissect_transact_data(
1936 tvb, offset, convert,
1939 lanman->resp_aux_data, NULL);
1943 if (entry_item != NULL) {
1945 * Set the length of the protocol tree
1946 * item for the entry.
1948 proto_item_set_len(entry_item,
1949 offset - start_offset);
1954 if (data_item != NULL) {
1956 * Set the length of the protocol tree item
1959 proto_item_set_len(data_item, offset);
1964 dissect_pipe_lanman(tvbuff_t *pd_tvb, tvbuff_t *p_tvb, tvbuff_t *d_tvb,
1965 packet_info *pinfo, proto_tree *parent_tree)
1967 smb_info_t *smb_info = pinfo->private_data;
1968 smb_transact_info_t *trp = smb_info->sip->extra_info;
1969 int offset = 0, start_offset;
1973 const struct lanman_desc *lanman;
1974 proto_item *item = NULL;
1975 proto_tree *tree = NULL;
1976 guint descriptor_len;
1977 const gchar *param_descrip, *data_descrip, *aux_data_descrip = NULL;
1979 gboolean has_ent_count;
1980 guint16 ent_count, aux_count;
1982 proto_item *data_item;
1983 proto_tree *data_tree;
1984 proto_item *entry_item;
1985 proto_tree *entry_tree;
1987 if (!proto_is_protocol_enabled(proto_smb_lanman))
1989 pinfo->current_proto = "LANMAN";
1991 if (check_col(pinfo->fd, COL_PROTOCOL)) {
1992 col_set_str(pinfo->fd, COL_PROTOCOL, "LANMAN");
1996 item = proto_tree_add_item(parent_tree, proto_smb_lanman,
1997 pd_tvb, 0, tvb_length(pd_tvb), FALSE);
1998 tree = proto_item_add_subtree(item, ett_lanman);
2001 if (smb_info->request) { /* this is a request */
2003 cmd = tvb_get_letohs(p_tvb, offset);
2004 if (check_col(pinfo->fd, COL_INFO)) {
2005 col_add_fstr(pinfo->fd, COL_INFO, "%s Request", val_to_str(cmd, commands, "Unknown Command:0x%02x"));
2007 proto_tree_add_uint(tree, hf_function_code, p_tvb, offset, 2,
2012 * If we haven't already done so, save the function code in
2013 * the structure we were handed, so that it's available to
2014 * the code parsing the reply, and initialize the detail
2015 * level to -1, meaning "unknown".
2017 if (!pinfo->fd->flags.visited) {
2018 trp->lanman_cmd = cmd;
2019 trp->info_level = -1;
2020 trp->param_descrip=NULL;
2021 trp->data_descrip=NULL;
2022 trp->aux_data_descrip=NULL;
2025 /* parameter descriptor */
2026 descriptor_len = tvb_strsize(p_tvb, offset);
2027 proto_tree_add_item(tree, hf_param_desc, p_tvb, offset,
2028 descriptor_len, TRUE);
2029 param_descrip = tvb_get_ptr(p_tvb, offset, descriptor_len);
2030 if (!pinfo->fd->flags.visited) {
2032 * Save the parameter descriptor for future use.
2034 g_assert(trp->param_descrip == NULL);
2035 trp->param_descrip = g_strdup(param_descrip);
2037 offset += descriptor_len;
2039 /* return descriptor */
2040 descriptor_len = tvb_strsize(p_tvb, offset);
2041 proto_tree_add_item(tree, hf_return_desc, p_tvb, offset,
2042 descriptor_len, TRUE);
2043 data_descrip = tvb_get_ptr(p_tvb, offset, descriptor_len);
2044 if (!pinfo->fd->flags.visited) {
2046 * Save the return descriptor for future use.
2048 g_assert(trp->data_descrip == NULL);
2049 trp->data_descrip = g_strdup(data_descrip);
2051 offset += descriptor_len;
2053 lanman = find_lanman(cmd);
2055 /* request parameters */
2056 start_offset = offset;
2057 offset = dissect_request_parameters(p_tvb, offset, pinfo, tree,
2058 param_descrip, lanman->req, &has_data);
2060 /* auxiliary data descriptor */
2061 if (tvb_reported_length_remaining(p_tvb, offset) > 0){
2063 * There are more parameters left, so the next
2064 * item is the auxiliary data descriptor.
2066 descriptor_len = tvb_strsize(p_tvb, offset);
2067 proto_tree_add_item(tree, hf_return_desc, p_tvb, offset,
2068 descriptor_len, TRUE);
2069 aux_data_descrip = tvb_get_ptr(p_tvb, offset, descriptor_len);
2070 if (!pinfo->fd->flags.visited) {
2072 * Save the auxiliary data descriptor for
2075 g_assert(trp->aux_data_descrip == NULL);
2076 trp->aux_data_descrip =
2077 g_strdup(aux_data_descrip);
2079 offset += descriptor_len;
2082 /* reset offset, we now start dissecting the data area */
2084 if (has_data && d_tvb && tvb_reported_length(d_tvb) != 0) {
2086 * There's a send buffer item in the descriptor
2087 * string, and the data count in the transaction
2088 * is non-zero, so there's data to dissect.
2091 if (lanman->req_data_item != NULL) {
2093 * Create a protocol tree item for the data.
2095 data_item = (*lanman->req_data_item)(d_tvb,
2096 pinfo, tree, offset);
2097 data_tree = proto_item_add_subtree(data_item,
2098 *lanman->ett_req_data);
2101 * Just leave it at the top level.
2108 offset = dissect_transact_data(d_tvb, offset, -1,
2109 pinfo, data_tree, data_descrip, lanman->req_data,
2110 &aux_count); /* XXX - what about strings? */
2112 /* auxiliary data */
2113 if (aux_data_descrip != NULL) {
2114 for (i = 0; i < aux_count; i++) {
2115 offset = dissect_transact_data(d_tvb,
2116 offset, -1, pinfo, data_tree,
2118 lanman->req_aux_data, NULL);
2122 if (data_item != NULL) {
2124 * Set the length of the protocol tree item
2127 proto_item_set_len(data_item, offset);
2132 * This is a response.
2133 * Have we seen the request to which it's a response?
2136 return FALSE; /* no - can't dissect it */
2138 /* ok we have seen this one before */
2140 /* if it looks like an interim response, update COL_INFO and return */
2141 if( ( (p_tvb==NULL) || (tvb_reported_length(p_tvb)==0) )
2142 && ( (d_tvb==NULL) || (tvb_reported_length(d_tvb)==0) ) ){
2144 if (check_col(pinfo->fd, COL_INFO)) {
2145 col_add_fstr(pinfo->fd, COL_INFO, "%s Interim Response",
2146 val_to_str(trp->lanman_cmd, commands, "Unknown Command (0x%02x)"));
2148 proto_tree_add_uint(tree, hf_function_code, p_tvb, 0, 0, trp->lanman_cmd);
2153 if (check_col(pinfo->fd, COL_INFO)) {
2154 col_add_fstr(pinfo->fd, COL_INFO, "%s Response",
2155 val_to_str(trp->lanman_cmd, commands, "Unknown Command (0x%02x)"));
2157 proto_tree_add_uint(tree, hf_function_code, p_tvb, 0, 0,
2160 lanman = find_lanman(trp->lanman_cmd);
2162 /* response parameters */
2165 status = tvb_get_letohs(p_tvb, offset);
2166 proto_tree_add_uint(tree, hf_status, p_tvb, offset, 2, status);
2170 convert = tvb_get_letohs(p_tvb, offset);
2171 proto_tree_add_uint(tree, hf_convert, p_tvb, offset, 2, convert);
2174 /* rest of the parameters */
2175 offset = dissect_response_parameters(p_tvb, offset, pinfo, tree,
2176 trp->param_descrip, lanman->resp, &has_data,
2177 &has_ent_count, &ent_count);
2180 /* reset offset, we now start dissecting the data area */
2183 if (has_data && d_tvb && tvb_reported_length(d_tvb) > 0) {
2185 * There's a receive buffer item in the descriptor
2186 * string, and the data count in the transaction
2187 * is non-zero, so there's data to dissect.
2189 dissect_response_data(d_tvb, pinfo, convert, tree,
2190 smb_info, lanman, has_ent_count, ent_count);
2198 proto_register_pipe_lanman(void)
2200 static hf_register_info hf[] = {
2201 { &hf_function_code,
2202 { "Function Code", "lanman.function_code", FT_UINT16, BASE_DEC,
2203 VALS(commands), 0, "LANMAN Function Code/Command", HFILL }},
2206 { "Parameter Descriptor", "lanman.param_desc", FT_STRING, BASE_NONE,
2207 NULL, 0, "LANMAN Parameter Descriptor", HFILL }},
2210 { "Return Descriptor", "lanman.ret_desc", FT_STRING, BASE_NONE,
2211 NULL, 0, "LANMAN Return Descriptor", HFILL }},
2213 { &hf_aux_data_desc,
2214 { "Auxiliary Data Descriptor", "lanman.aux_data_desc", FT_STRING, BASE_NONE,
2215 NULL, 0, "LANMAN Auxiliary Data Descriptor", HFILL }},
2218 { "Detail Level", "lanman.level", FT_UINT16, BASE_DEC,
2219 NULL, 0, "LANMAN Detail Level", HFILL }},
2222 { "Receive Buffer Length", "lanman.recv_buf_len", FT_UINT16, BASE_DEC,
2223 NULL, 0, "LANMAN Receive Buffer Length", HFILL }},
2226 { "Send Buffer Length", "lanman.send_buf_len", FT_UINT16, BASE_DEC,
2227 NULL, 0, "LANMAN Send Buffer Length", HFILL }},
2229 { &hf_continuation_from,
2230 { "Continuation from message in frame", "lanman.continuation_from", FT_UINT32, BASE_DEC,
2231 NULL, 0, "This is a LANMAN continuation from the message in the frame in question", HFILL }},
2234 { "Status", "lanman.status", FT_UINT16, BASE_DEC,
2235 VALS(status_vals), 0, "LANMAN Return status", HFILL }},
2238 { "Convert", "lanman.convert", FT_UINT16, BASE_DEC,
2239 NULL, 0, "LANMAN Convert", HFILL }},
2242 { "Entry Count", "lanman.entry_count", FT_UINT16, BASE_DEC,
2243 NULL, 0, "LANMAN Number of Entries", HFILL }},
2246 { "Available Entries", "lanman.available_count", FT_UINT16, BASE_DEC,
2247 NULL, 0, "LANMAN Number of Available Entries", HFILL }},
2250 { "Share Name", "lanman.share.name", FT_STRING, BASE_NONE,
2251 NULL, 0, "LANMAN Name of Share", HFILL }},
2254 { "Share Type", "lanman.share.type", FT_UINT16, BASE_DEC,
2255 VALS(share_type_vals), 0, "LANMAN Type of Share", HFILL }},
2257 { &hf_share_comment,
2258 { "Share Comment", "lanman.share.comment", FT_STRING, BASE_NONE,
2259 NULL, 0, "LANMAN Share Comment", HFILL }},
2261 { &hf_share_permissions,
2262 { "Share Permissions", "lanman.share.permissions", FT_UINT16, BASE_DEC,
2263 NULL, 0, "LANMAN Permissions on share", HFILL }},
2265 { &hf_share_max_uses,
2266 { "Share Max Uses", "lanman.share.max_uses", FT_UINT16, BASE_DEC,
2267 NULL, 0, "LANMAN Max connections allowed to share", HFILL }},
2269 { &hf_share_current_uses,
2270 { "Share Current Uses", "lanman.share.current_uses", FT_UINT16, BASE_DEC,
2271 NULL, 0, "LANMAN Current connections to share", HFILL }},
2274 { "Share Path", "lanman.share.path", FT_STRING, BASE_NONE,
2275 NULL, 0, "LANMAN Share Path", HFILL }},
2277 { &hf_share_password,
2278 { "Share Password", "lanman.share.password", FT_STRING, BASE_NONE,
2279 NULL, 0, "LANMAN Share Password", HFILL }},
2282 { "Server Name", "lanman.server.name", FT_STRING, BASE_NONE,
2283 NULL, 0, "LANMAN Name of Server", HFILL }},
2286 { "Major Version", "lanman.server.major", FT_UINT8, BASE_DEC,
2287 NULL, 0, "LANMAN Server Major Version", HFILL }},
2290 { "Minor Version", "lanman.server.minor", FT_UINT8, BASE_DEC,
2291 NULL, 0, "LANMAN Server Minor Version", HFILL }},
2293 { &hf_server_comment,
2294 { "Server Comment", "lanman.server.comment", FT_STRING, BASE_NONE,
2295 NULL, 0, "LANMAN Server Comment", HFILL }},
2298 { "Available Bytes", "lanman.available_bytes", FT_UINT16, BASE_DEC,
2299 NULL, 0, "LANMAN Number of Available Bytes", HFILL }},
2302 { "Current Date/Time", "lanman.current_time", FT_ABSOLUTE_TIME, BASE_NONE,
2303 NULL, 0, "LANMAN Current date and time, in seconds since 00:00:00, January 1, 1970", HFILL }},
2306 { "Milliseconds", "lanman.msecs", FT_UINT32, BASE_DEC,
2307 NULL, 0, "LANMAN Milliseconds since arbitrary time in the past (typically boot time)", HFILL }},
2310 { "Hour", "lanman.hour", FT_UINT8, BASE_DEC,
2311 NULL, 0, "LANMAN Current hour", HFILL }},
2314 { "Minute", "lanman.minute", FT_UINT8, BASE_DEC,
2315 NULL, 0, "LANMAN Current minute", HFILL }},
2318 { "Second", "lanman.second", FT_UINT8, BASE_DEC,
2319 NULL, 0, "LANMAN Current second", HFILL }},
2322 { "Hundredths of a second", "lanman.hundredths", FT_UINT8, BASE_DEC,
2323 NULL, 0, "LANMAN Current hundredths of a second", HFILL }},
2326 { "Time Zone Offset", "lanman.tzoffset", FT_INT16, BASE_DEC,
2327 NULL, 0, "LANMAN Offset of time zone from GMT, in minutes", HFILL }},
2330 { "Time Interval", "lanman.timeinterval", FT_UINT16, BASE_DEC,
2331 NULL, 0, "LANMAN .0001 second units per clock tick", HFILL }},
2334 { "Day", "lanman.day", FT_UINT8, BASE_DEC,
2335 NULL, 0, "LANMAN Current day", HFILL }},
2338 { "Month", "lanman.month", FT_UINT8, BASE_DEC,
2339 NULL, 0, "LANMAN Current month", HFILL }},
2342 { "Year", "lanman.year", FT_UINT16, BASE_DEC,
2343 NULL, 0, "LANMAN Current year", HFILL }},
2346 { "Weekday", "lanman.weekday", FT_UINT8, BASE_DEC,
2347 VALS(weekday_vals), 0, "LANMAN Current day of the week", HFILL }},
2349 { &hf_enumeration_domain,
2350 { "Enumeration Domain", "lanman.enumeration_domain", FT_STRING, BASE_NONE,
2351 NULL, 0, "LANMAN Domain in which to enumerate servers", HFILL }},
2353 { &hf_computer_name,
2354 { "Computer Name", "lanman.computer_name", FT_STRING, BASE_NONE,
2355 NULL, 0, "LANMAN Computer Name", HFILL }},
2358 { "User Name", "lanman.user_name", FT_STRING, BASE_NONE,
2359 NULL, 0, "LANMAN User Name", HFILL }},
2361 { &hf_workstation_domain,
2362 { "Workstation Domain", "lanman.workstation_domain", FT_STRING, BASE_NONE,
2363 NULL, 0, "LANMAN Workstation Domain", HFILL }},
2365 { &hf_workstation_major,
2366 { "Workstation Major Version", "lanman.workstation_major", FT_UINT8, BASE_DEC,
2367 NULL, 0, "LANMAN Workstation Major Version", HFILL }},
2369 { &hf_workstation_minor,
2370 { "Workstation Minor Version", "lanman.workstation_minor", FT_UINT8, BASE_DEC,
2371 NULL, 0, "LANMAN Workstation Minor Version", HFILL }},
2374 { "Logon Domain", "lanman.logon_domain", FT_STRING, BASE_NONE,
2375 NULL, 0, "LANMAN Logon Domain", HFILL }},
2377 { &hf_other_domains,
2378 { "Other Domains", "lanman.other_domains", FT_STRING, BASE_NONE,
2379 NULL, 0, "LANMAN Other Domains", HFILL }},
2382 { "Password", "lanman.password", FT_STRING, BASE_NONE,
2383 NULL, 0, "LANMAN Password", HFILL }},
2385 { &hf_workstation_name,
2386 { "Workstation Name", "lanman.workstation_name", FT_STRING, BASE_NONE,
2387 NULL, 0, "LANMAN Workstation Name", HFILL }},
2390 { "Length of UStruct", "lanman.ustruct_size", FT_UINT16, BASE_DEC,
2391 NULL, 0, "LANMAN UStruct Length", HFILL }},
2394 { "Logon Code", "lanman.logon_code", FT_UINT16, BASE_DEC,
2395 VALS(status_vals), 0, "LANMAN Logon Code", HFILL }},
2397 { &hf_privilege_level,
2398 { "Privilege Level", "lanman.privilege_level", FT_UINT16, BASE_DEC,
2399 VALS(privilege_vals), 0, "LANMAN Privilege Level", HFILL }},
2401 { &hf_operator_privileges,
2402 { "Operator Privileges", "lanman.operator_privileges", FT_UINT32, BASE_DEC,
2403 VALS(op_privilege_vals), 0, "LANMAN Operator Privileges", HFILL }},
2406 { "Number of Logons", "lanman.num_logons", FT_UINT16, BASE_DEC,
2407 NULL, 0, "LANMAN Number of Logons", HFILL }},
2410 { "Bad Password Count", "lanman.bad_pw_count", FT_UINT16, BASE_DEC,
2411 NULL, 0, "LANMAN Number of incorrect passwords entered since last successful login", HFILL }},
2414 { "Last Logon Date/Time", "lanman.last_logon", FT_ABSOLUTE_TIME, BASE_NONE,
2415 NULL, 0, "LANMAN Date and time of last logon", HFILL }},
2418 { "Last Logoff Date/Time", "lanman.last_logoff", FT_ABSOLUTE_TIME, BASE_NONE,
2419 NULL, 0, "LANMAN Date and time of last logoff", HFILL }},
2422 { "Logoff Date/Time", "lanman.logoff_time", FT_ABSOLUTE_TIME, BASE_NONE,
2423 NULL, 0, "LANMAN Date and time when user should log off", HFILL }},
2426 { "Kickoff Date/Time", "lanman.kickoff_time", FT_ABSOLUTE_TIME, BASE_NONE,
2427 NULL, 0, "LANMAN Date and time when user will be logged off", HFILL }},
2430 { "Password Age", "lanman.password_age", FT_RELATIVE_TIME, BASE_NONE,
2431 NULL, 0, "LANMAN Time since user last changed his/her password", HFILL }},
2433 { &hf_password_can_change,
2434 { "Password Can Change", "lanman.password_can_change", FT_ABSOLUTE_TIME, BASE_NONE,
2435 NULL, 0, "LANMAN Date and time when user can change their password", HFILL }},
2437 { &hf_password_must_change,
2438 { "Password Must Change", "lanman.password_must_change", FT_ABSOLUTE_TIME, BASE_NONE,
2439 NULL, 0, "LANMAN Date and time when user must change their password", HFILL }},
2442 { "Script Path", "lanman.script_path", FT_STRING, BASE_NONE,
2443 NULL, 0, "LANMAN Pathname of user's logon script", HFILL }},
2446 { "Logoff Code", "lanman.logoff_code", FT_UINT16, BASE_DEC,
2447 VALS(status_vals), 0, "LANMAN Logoff Code", HFILL }},
2450 { "Duration of Session", "lanman.duration", FT_RELATIVE_TIME, BASE_NONE,
2451 NULL, 0, "LANMAN Number of seconds the user was logged on", HFILL }},
2454 { "User Comment", "lanman.user_comment", FT_STRING, BASE_NONE,
2455 NULL, 0, "LANMAN User Comment", HFILL }},
2458 { "Full Name", "lanman.full_name", FT_STRING, BASE_NONE,
2459 NULL, 0, "LANMAN Full Name", HFILL }},
2462 { "Home Directory", "lanman.homedir", FT_STRING, BASE_NONE,
2463 NULL, 0, "LANMAN Home Directory", HFILL }},
2466 { "Parameters", "lanman.parameters", FT_STRING, BASE_NONE,
2467 NULL, 0, "LANMAN Parameters", HFILL }},
2470 { "Logon Server", "lanman.logon_server", FT_STRING, BASE_NONE,
2471 NULL, 0, "LANMAN Logon Server", HFILL }},
2473 /* XXX - we should have a value_string table for this */
2475 { "Country Code", "lanman.country_code", FT_UINT16, BASE_DEC,
2476 NULL, 0, "LANMAN Country Code", HFILL }},
2479 { "Workstations", "lanman.workstations", FT_STRING, BASE_NONE,
2480 NULL, 0, "LANMAN Workstations", HFILL }},
2483 { "Max Storage", "lanman.max_storage", FT_UINT32, BASE_DEC,
2484 NULL, 0, "LANMAN Max Storage", HFILL }},
2486 { &hf_units_per_week,
2487 { "Units Per Week", "lanman.units_per_week", FT_UINT16, BASE_DEC,
2488 NULL, 0, "LANMAN Units Per Week", HFILL }},
2491 { "Logon Hours", "lanman.logon_hours", FT_BYTES, BASE_NONE,
2492 NULL, 0, "LANMAN Logon Hours", HFILL }},
2494 /* XXX - we should have a value_string table for this */
2496 { "Code Page", "lanman.code_page", FT_UINT16, BASE_DEC,
2497 NULL, 0, "LANMAN Code Page", HFILL }},
2500 { "New Password", "lanman.new_password", FT_BYTES, BASE_HEX,
2501 NULL, 0, "LANMAN New Password (encrypted)", HFILL }},
2504 { "Old Password", "lanman.old_password", FT_BYTES, BASE_HEX,
2505 NULL, 0, "LANMAN Old Password (encrypted)", HFILL }},
2508 { "Reserved", "lanman.reserved", FT_UINT32, BASE_HEX,
2509 NULL, 0, "LANMAN Reserved", HFILL }},
2512 static gint *ett[] = {
2514 &ett_lanman_servers,
2520 proto_smb_lanman = proto_register_protocol(
2521 "Microsoft Windows Lanman Remote API Protocol", "LANMAN", "lanman");
2522 proto_register_field_array(proto_smb_lanman, hf, array_length(hf));
2523 proto_register_subtree_array(ett, array_length(ett));
2526 static heur_dissector_list_t msrpc_heur_subdissector_list;
2529 dissect_pipe_msrpc(tvbuff_t *d_tvb, packet_info *pinfo, proto_tree *parent_tree,
2532 dcerpc_private_info dcerpc_priv;
2533 smb_info_t *smb_priv = (smb_info_t *)pinfo->private_data;
2536 dcerpc_priv.transport_type = DCERPC_TRANSPORT_SMB;
2537 dcerpc_priv.data.smb.fid = fid;
2539 pinfo->private_data = &dcerpc_priv;
2541 result = dissector_try_heuristic(msrpc_heur_subdissector_list, d_tvb,
2542 pinfo, parent_tree);
2544 pinfo->private_data = smb_priv;
2547 dissect_data(d_tvb, 0, pinfo, parent_tree);
2553 proto_register_pipe_msrpc(void)
2555 register_heur_dissector_list("msrpc", &msrpc_heur_subdissector_list);
2558 #define CALL_NAMED_PIPE 0x54
2559 #define WAIT_NAMED_PIPE 0x53
2560 #define PEEK_NAMED_PIPE 0x23
2561 #define Q_NM_P_HAND_STATE 0x21
2562 #define SET_NM_P_HAND_STATE 0x01
2563 #define Q_NM_PIPE_INFO 0x22
2564 #define TRANSACT_NM_PIPE 0x26
2565 #define RAW_READ_NM_PIPE 0x11
2566 #define RAW_WRITE_NM_PIPE 0x31
2568 static const value_string functions[] = {
2569 {CALL_NAMED_PIPE, "CallNamedPipe"},
2570 {WAIT_NAMED_PIPE, "WaitNamedPipe"},
2571 {PEEK_NAMED_PIPE, "PeekNamedPipe"},
2572 {Q_NM_P_HAND_STATE, "QNmPHandState"},
2573 {SET_NM_P_HAND_STATE, "SetNmPHandState"},
2574 {Q_NM_PIPE_INFO, "QNmPipeInfo"},
2575 {TRANSACT_NM_PIPE, "TransactNmPipe"},
2576 {RAW_READ_NM_PIPE, "RawReadNmPipe"},
2577 {RAW_WRITE_NM_PIPE, "RawWriteNmPipe"},
2581 static const value_string pipe_status[] = {
2582 {1, "Disconnected by server"},
2584 {3, "Connection to server is OK"},
2585 {4, "Server end of pipe is closed"},
2589 #define PIPE_LANMAN 1
2590 #define PIPE_MSRPC 2
2592 /* decode the SMB pipe protocol
2594 pipe is the name of the pipe, e.g. LANMAN
2595 smb_info->trans_subcmd is set to the symbolic constant matching the mailslot name
2598 smb_info->trans_subcmd gives us which pipe this response is for
2601 dissect_pipe_smb(tvbuff_t *sp_tvb, tvbuff_t *s_tvb, tvbuff_t *pd_tvb,
2602 tvbuff_t *p_tvb, tvbuff_t *d_tvb, const char *pipe,
2603 packet_info *pinfo, proto_tree *tree)
2605 smb_info_t *smb_info;
2606 smb_transact_info_t *tri;
2607 proto_item *pipe_item = NULL;
2608 proto_tree *pipe_tree = NULL;
2615 if (!proto_is_protocol_enabled(proto_smb_pipe))
2617 pinfo->current_proto = "SMB Pipe";
2619 smb_info = pinfo->private_data;
2624 if (check_col(pinfo->fd, COL_PROTOCOL)) {
2625 col_set_str(pinfo->fd, COL_PROTOCOL, "SMB Pipe");
2627 if (check_col(pinfo->fd, COL_INFO)) {
2628 col_set_str(pinfo->fd, COL_INFO,
2629 smb_info->request ? "Request" : "Response");
2632 if (smb_info->sip != NULL)
2633 tri = smb_info->sip->extra_info;
2638 * Set up a subtree for the pipe data, if there is any.
2640 if (s_tvb != NULL || tvb_length(sp_tvb) != 0 ||
2641 (tri != NULL && tri->function != -1)) {
2643 pipe_item = proto_tree_add_item(tree, proto_smb_pipe,
2644 sp_tvb, 0, tvb_length(sp_tvb), FALSE);
2645 pipe_tree = proto_item_add_subtree(pipe_item, ett_smb_pipe);
2651 * Do we have any setup words at all?
2653 if (s_tvb != NULL && tvb_length(s_tvb) != 0) {
2655 * Yes. The first of them is the function.
2657 function = tvb_get_letohs(s_tvb, offset);
2658 proto_tree_add_uint(pipe_tree, hf_pipe_function, s_tvb,
2659 offset, 2, function);
2661 if (check_col(pinfo->fd, COL_INFO)) {
2662 col_add_fstr(pinfo->fd, COL_INFO, "%s %s",
2663 val_to_str(function, functions, "Unknown function (0x%04x)"),
2664 smb_info->request ? "Request" : "Response");
2667 tri->function = function;
2670 * The second of them depends on the function.
2674 case CALL_NAMED_PIPE:
2675 case WAIT_NAMED_PIPE:
2679 proto_tree_add_item(pipe_tree, hf_pipe_priority, s_tvb,
2683 case PEEK_NAMED_PIPE:
2684 case Q_NM_P_HAND_STATE:
2685 case SET_NM_P_HAND_STATE:
2686 case Q_NM_PIPE_INFO:
2687 case TRANSACT_NM_PIPE:
2688 case RAW_READ_NM_PIPE:
2689 case RAW_WRITE_NM_PIPE:
2693 fid = tvb_get_letohs(s_tvb, 2);
2694 add_fid(s_tvb, pinfo, pipe_tree, offset, 2, fid);
2701 * It's something unknown.
2702 * XXX - put it into the tree?
2709 * This is either a pipe transaction with no setup
2710 * information or a response.
2712 * In the former case, there is no function or FID.
2714 * In the latter case, we could get that information from
2715 * the matching request, if we saw it. (XXX - do that.)
2717 if (tri != NULL && tri->function != -1) {
2718 function = tri->function;
2719 proto_tree_add_uint(pipe_tree, hf_pipe_function, sp_tvb,
2721 if (check_col(pinfo->fd, COL_INFO)) {
2722 col_add_fstr(pinfo->fd, COL_INFO, "%s %s",
2723 val_to_str(function, functions, "Unknown function (0x%04x)"),
2724 smb_info->request ? "Request" : "Response");
2728 add_fid(sp_tvb, pinfo, pipe_tree, 0, 0, fid);
2736 * XXX - put the byte count and the pipe name into the tree as well;
2737 * that requires us to fetch a possibly-Unicode string.
2740 if(smb_info->request){
2741 if(strncmp(pipe,"LANMAN",6) == 0){
2742 tri->trans_subcmd=PIPE_LANMAN;
2744 /* assume it is MSRPC*/
2745 tri->trans_subcmd=PIPE_MSRPC;
2751 * We don't know what type of pipe transaction this
2752 * was, so indicate that we didn't dissect it.
2759 case CALL_NAMED_PIPE:
2760 case TRANSACT_NM_PIPE:
2761 switch(tri->trans_subcmd){
2764 return dissect_pipe_lanman(pd_tvb, p_tvb, d_tvb, pinfo,
2770 * Only dissect this if we know the FID.
2773 return dissect_pipe_msrpc(d_tvb, pinfo, tree,
2782 * We don't know the function; we dissect only LANMAN
2783 * pipe messages, not RPC pipe messages, in that case.
2785 switch(tri->trans_subcmd){
2787 return dissect_pipe_lanman(pd_tvb, p_tvb, d_tvb, pinfo,
2793 case WAIT_NAMED_PIPE:
2796 case PEEK_NAMED_PIPE:
2798 * Request contains no parameters or data.
2800 if (!smb_info->request) {
2802 proto_tree_add_item(pipe_tree, hf_pipe_peek_available,
2803 p_tvb, offset, 2, TRUE);
2805 proto_tree_add_item(pipe_tree, hf_pipe_peek_remaining,
2806 p_tvb, offset, 2, TRUE);
2808 proto_tree_add_item(pipe_tree, hf_pipe_peek_status,
2809 p_tvb, offset, 2, TRUE);
2814 case Q_NM_P_HAND_STATE:
2816 * Request contains no parameters or data.
2818 if (!smb_info->request) {
2819 offset = dissect_ipc_state(p_tvb, pinfo, pipe_tree, 0,
2824 case SET_NM_P_HAND_STATE:
2826 * Response contains no parameters or data.
2828 if (smb_info->request) {
2829 offset = dissect_ipc_state(p_tvb, pinfo, pipe_tree, 0,
2834 case Q_NM_PIPE_INFO:
2836 if (smb_info->request) {
2838 * Request contains an information level.
2840 info_level = tvb_get_letohs(p_tvb, offset);
2841 proto_tree_add_uint(pipe_tree, hf_pipe_getinfo_info_level,
2842 p_tvb, offset, 2, info_level);
2844 tri->info_level = info_level;
2846 guint8 pipe_namelen;
2848 switch (tri->info_level) {
2851 proto_tree_add_item(pipe_tree,
2852 hf_pipe_getinfo_output_buffer_size,
2853 d_tvb, offset, 2, TRUE);
2855 proto_tree_add_item(pipe_tree,
2856 hf_pipe_getinfo_input_buffer_size,
2857 d_tvb, offset, 2, TRUE);
2859 proto_tree_add_item(pipe_tree,
2860 hf_pipe_getinfo_maximum_instances,
2861 d_tvb, offset, 1, TRUE);
2863 proto_tree_add_item(pipe_tree,
2864 hf_pipe_getinfo_current_instances,
2865 d_tvb, offset, 1, TRUE);
2867 pipe_namelen = tvb_get_guint8(d_tvb, offset);
2868 proto_tree_add_uint(pipe_tree,
2869 hf_pipe_getinfo_pipe_name_length,
2870 d_tvb, offset, 1, pipe_namelen);
2872 /* XXX - can this be Unicode? */
2873 proto_tree_add_item(pipe_tree,
2874 hf_pipe_getinfo_pipe_name,
2875 d_tvb, offset, pipe_namelen, TRUE);
2881 case RAW_READ_NM_PIPE:
2883 * Request contains no parameters or data.
2885 if (!smb_info->request) {
2886 offset = dissect_file_data(d_tvb, pinfo, pipe_tree, 0,
2887 tvb_reported_length(d_tvb),
2888 tvb_reported_length(d_tvb));
2892 case RAW_WRITE_NM_PIPE:
2894 if (smb_info->request) {
2895 offset = dissect_file_data(d_tvb, pinfo, pipe_tree,
2896 offset, tvb_reported_length(d_tvb),
2897 tvb_reported_length(d_tvb));
2899 proto_tree_add_item(pipe_tree,
2900 hf_pipe_write_raw_bytes_written,
2901 p_tvb, offset, 2, TRUE);
2910 proto_register_smb_pipe(void)
2912 static hf_register_info hf[] = {
2913 { &hf_pipe_function,
2914 { "Function", "pipe.function", FT_UINT16, BASE_HEX,
2915 VALS(functions), 0, "SMB Pipe Function Code", HFILL }},
2916 { &hf_pipe_priority,
2917 { "Priority", "pipe.priority", FT_UINT16, BASE_DEC,
2918 NULL, 0, "SMB Pipe Priority", HFILL }},
2919 { &hf_pipe_peek_available,
2920 { "Available Bytes", "pipe.peek.available_bytes", FT_UINT16, BASE_DEC,
2921 NULL, 0, "Total number of bytes available to be read from the pipe", HFILL }},
2922 { &hf_pipe_peek_remaining,
2923 { "Bytes Remaining", "pipe.peek.remaining_bytes", FT_UINT16, BASE_DEC,
2924 NULL, 0, "Total number of bytes remaining in the message at the head of the pipe", HFILL }},
2925 { &hf_pipe_peek_status,
2926 { "Pipe Status", "pipe.peek.status", FT_UINT16, BASE_DEC,
2927 VALS(pipe_status), 0, "Pipe status", HFILL }},
2928 { &hf_pipe_getinfo_info_level,
2929 { "Information Level", "pipe.getinfo.info_level", FT_UINT16, BASE_DEC,
2930 NULL, 0, "Information level of information to return", HFILL }},
2931 { &hf_pipe_getinfo_output_buffer_size,
2932 { "Output Buffer Size", "pipe.getinfo.output_buffer_size", FT_UINT16, BASE_DEC,
2933 NULL, 0, "Actual size of buffer for outgoing (server) I/O", HFILL }},
2934 { &hf_pipe_getinfo_input_buffer_size,
2935 { "Input Buffer Size", "pipe.getinfo.input_buffer_size", FT_UINT16, BASE_DEC,
2936 NULL, 0, "Actual size of buffer for incoming (client) I/O", HFILL }},
2937 { &hf_pipe_getinfo_maximum_instances,
2938 { "Maximum Instances", "pipe.getinfo.maximum_instances", FT_UINT8, BASE_DEC,
2939 NULL, 0, "Maximum allowed number of instances", HFILL }},
2940 { &hf_pipe_getinfo_current_instances,
2941 { "Current Instances", "pipe.getinfo.current_instances", FT_UINT8, BASE_DEC,
2942 NULL, 0, "Current number of instances", HFILL }},
2943 { &hf_pipe_getinfo_pipe_name_length,
2944 { "Pipe Name Length", "pipe.getinfo.pipe_name_length", FT_UINT8, BASE_DEC,
2945 NULL, 0, "Length of pipe name", HFILL }},
2946 { &hf_pipe_getinfo_pipe_name,
2947 { "Pipe Name", "pipe.getinfo.pipe_name", FT_STRING, BASE_NONE,
2948 NULL, 0, "Name of pipe", HFILL }},
2949 { &hf_pipe_write_raw_bytes_written,
2950 { "Bytes Written", "pipe.write_raw.bytes_written", FT_UINT16, BASE_DEC,
2951 NULL, 0, "Number of bytes written to the pipe", HFILL }},
2953 static gint *ett[] = {
2957 proto_smb_pipe = proto_register_protocol(
2958 "SMB Pipe Protocol", "SMB Pipe", "pipe");
2960 proto_register_field_array(proto_smb_pipe, hf, array_length(hf));
2961 proto_register_subtree_array(ett, array_length(ett));