Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-smb2.h
1/* packet-smb2.h
2 * Defines for SMB2 packet dissection
3 *
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <[email protected]>
6 * Copyright 1998, 1999 Gerald Combs
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11#ifndef __PACKET_SMB2_H__
12#define __PACKET_SMB2_H__
13
14#include "packet-dcerpc.h"
15#include "packet-smb.h"
16#include "packet-ntlmssp.h"
17
18/* SMB2 command codes. With MSVC and a
19 * libwireshark.dll, we need a special declaration.
20 */
21WS_DLL_PUBLIC value_string_ext smb2_cmd_vals_ext;
22
23/* Structure to keep track of information specific to a single
24 * SMB2 transaction. Here we store things we need to remember between
25 * a specific request and a specific response.
26 *
27 * There is no guarantee we will have this structure available for all
28 * SMB2 packets so a dissector must check this pointer for NULL
29 * before dereferencing it.
30 *
31 * private data is set to NULL when the structure is created. It is used
32 * for communications between the Request and the Response packets.
33 */
34
35/* extra info needed by export object smb */
36typedef struct _smb2_eo_file_info_t {
37 uint32_t attr_mask;
38 int64_t end_of_file;
40
41typedef struct _smb2_fid_info_t {
42 uint64_t fid_persistent;
43 uint64_t fid_volatile;
44 uint64_t sesid; /* *host* byte order - not necessarily little-endian! */
45 uint32_t tid;
46 /* only used for key lookup in equal func, must be zero when inserting */
47 uint32_t frame_key;
48 /* first and last frame nums this FID is valid */
49 uint32_t frame_beg;
50 uint32_t frame_end;
51 /* file name used to open this FID */
52 char *name;
53 gboolean is_dir;
54 gboolean delete_on_close;
55 uint32_t desired_access;
56 uint32_t granted_access;
58
59typedef enum {
60 SMB2_EI_NONE, /* Unassigned / NULL */
61 SMB2_EI_TREENAME, /* tid tracking char * */
62 SMB2_EI_FILENAME, /* fid tracking char * */
63 SMB2_EI_FINDPATTERN /* find tracking char * */
64} smb2_extra_info_t;
65typedef struct _smb2_saved_info_t {
66 uint8_t smb2_class;
67 uint8_t infolevel;
68 uint64_t msg_id;
69 uint32_t frame_req, frame_res;
70 nstime_t req_time;
71 nstime_t resp_time;
72 uint8_t *preauth_hash_req, *preauth_hash_res;
73 smb2_fid_info_t *file;
74 e_ctx_hnd policy_hnd; /* for eo_smb tracking */
75 smb_eo_t *eo_info_t; /* for storing eo_smb infos */
76 uint64_t file_offset; /* needed file_offset for eo_smb */
77 uint32_t bytes_moved; /* needed for eo_smb */
78 void *extra_info;
79 smb2_extra_info_t extra_info_type;
80 uint32_t fid_hash;
81 uint16_t num_matched;
82 proto_item *hnd_item;
83 e_guid_t uuid_fid;
84 uint32_t frame_beg; /* The create frame. */
85 uint32_t frame_end; /* The close frame. */
86 const uint8_t *filename;
88
89typedef struct _smb2_tid_info_t {
90 uint32_t tid;
91 uint32_t connect_frame;
92 uint32_t disconnect_frame;
93 uint8_t share_type;
94 char *name;
96
97#define SMB2_PREAUTH_HASH_SIZE 64
98#define AES_KEY_SIZE 16
99
100typedef struct _smb2_sesid_info_t {
101 uint64_t sesid; /* *host* byte order - not necessarily little-endian! */
102 uint32_t auth_frame;
103 char *acct_name;
104 char *domain_name;
105 char *host_name;
106 uint16_t server_port;
107 uint32_t session_key_frame;
108 unsigned session_key_len;
109 uint8_t session_key[NTLMSSP_KEY_LEN*2];
110 uint8_t signing_key[NTLMSSP_KEY_LEN];
111 uint8_t client_decryption_key16[AES_KEY_SIZE];
112 uint8_t server_decryption_key16[AES_KEY_SIZE];
113 uint8_t client_decryption_key32[AES_KEY_SIZE*2];
114 uint8_t server_decryption_key32[AES_KEY_SIZE*2];
115
116 wmem_map_t *tids;
117 wmem_map_t *fids;
118 /* table to store some infos for smb export object */
119 wmem_map_t *files;
120
121 uint8_t preauth_hash[SMB2_PREAUTH_HASH_SIZE];
123
124/* Structure to keep track of conversations and the hash tables.
125 * There is one such structure for each conversation.
126 */
127typedef struct _smb2_conv_info_t {
128 /* these two tables are used to match requests with responses */
129 GHashTable *unmatched;
130 GHashTable *matched;
131 uint16_t dialect;
132 uint16_t sign_alg;
133 uint16_t enc_alg;
134
135 /* preauth hash before session setup */
136 uint8_t *preauth_hash_current;
137 uint8_t preauth_hash_con[SMB2_PREAUTH_HASH_SIZE];
138 uint8_t preauth_hash_ses[SMB2_PREAUTH_HASH_SIZE];
140
141
142/* This structure contains information from the SMB2 header
143 * as well as pointers to the conversation and the transaction specific
144 * structures.
145 */
146#define SMB2_FLAGS_RESPONSE 0x00000001
147#define SMB2_FLAGS_ASYNC_CMD 0x00000002
148#define SMB2_FLAGS_CHAINED 0x00000004
149#define SMB2_FLAGS_SIGNATURE 0x00000008
150#define SMB2_FLAGS_PRIORITY_MASK 0x00000070
151#define SMB2_FLAGS_DFS_OP 0x10000000
152#define SMB2_FLAGS_REPLAY_OPERATION 0x20000000
153
154#define SMB2_FLAGS_PRIORITY1 0x00000010
155#define SMB2_FLAGS_PRIORITY2 0x00000020
156#define SMB2_FLAGS_PRIORITY3 0x00000030
157#define SMB2_FLAGS_PRIORITY4 0x00000040
158#define SMB2_FLAGS_PRIORITY5 0x00000050
159#define SMB2_FLAGS_PRIORITY6 0x00000060
160#define SMB2_FLAGS_PRIORITY7 0x00000070
161
162/* SMB2 FLAG MASKS */
163#define SMB2_FLAGS_ATTR_ENCRYPTED 0x00004000
164#define SMB2_FLAGS_ATTR_INDEXED 0x00002000
165#define SMB2_FLAGS_ATTR_OFFLINE 0x00001000
166#define SMB2_FLAGS_ATTR_COMPRESSED 0x00000800
167#define SMB2_FLAGS_ATTR_REPARSEPOINT 0x00000400
168#define SMB2_FLAGS_ATTR_SPARSE 0x00000200
169#define SMB2_FLAGS_ATTR_TEMPORARY 0x00000100
170#define SMB2_FLAGS_ATTR_NORMAL 0x00000080
171#define SMB2_FLAGS_ATTR_DEVICE 0x00000040
172#define SMB2_FLAGS_ATTR_ARCHIVE 0x00000020
173#define SMB2_FLAGS_ATTR_DIRECTORY 0x00000010
174#define SMB2_FLAGS_ATTR_VOLUMEID 0x00000008
175#define SMB2_FLAGS_ATTR_SYSTEM 0x00000004
176#define SMB2_FLAGS_ATTR_HIDDEN 0x00000002
177#define SMB2_FLAGS_ATTR_READONLY 0x00000001
178
179/* SMB2 FILE TYPES ASSIGNED TO EXPORT OBJECTS */
180#define SMB2_FID_TYPE_UNKNOWN 0
181#define SMB2_FID_TYPE_FILE 1
182#define SMB2_FID_TYPE_DIR 2
183#define SMB2_FID_TYPE_PIPE 3
184#define SMB2_FID_TYPE_OTHER 4
185
186/* SMB2 COMMAND CODES */
187#define SMB2_COM_NEGOTIATE_PROTOCOL 0x00
188#define SMB2_COM_SESSION_SETUP 0x01
189#define SMB2_COM_SESSION_LOGOFF 0x02
190#define SMB2_COM_TREE_CONNECT 0x03
191#define SMB2_COM_TREE_DISCONNECT 0x04
192#define SMB2_COM_CREATE 0x05
193#define SMB2_COM_CLOSE 0x06
194#define SMB2_COM_FLUSH 0x07
195#define SMB2_COM_READ 0x08
196#define SMB2_COM_WRITE 0x09
197#define SMB2_COM_LOCK 0x0A
198#define SMB2_COM_IOCTL 0x0B
199#define SMB2_COM_CANCEL 0x0C
200#define SMB2_COM_KEEPALIVE 0x0D
201#define SMB2_COM_FIND 0x0E
202#define SMB2_COM_NOTIFY 0x0F
203#define SMB2_COM_GETINFO 0x10
204#define SMB2_COM_SETINFO 0x11
205#define SMB2_COM_BREAK 0x12
206
207typedef struct _smb2_info_t {
208 uint16_t opcode;
209 uint32_t ioctl_function;
210 uint32_t status;
211 uint32_t tid;
212 uint64_t sesid; /* *host* byte order - not necessarily little-endian! */
213 uint64_t msg_id;
214 uint32_t flags;
215 smb2_eo_file_info_t *eo_file_info; /* eo_smb extra info */
216 smb2_conv_info_t *conv;
217 smb2_saved_info_t *saved;
218 smb2_tid_info_t *tree;
219 smb2_sesid_info_t *session;
220 smb2_fid_info_t *file;
221 proto_tree *top_tree;
223
224/* for transform content information */
225
227 uint8_t nonce[16];
228 uint32_t size;
229 uint16_t flags;
230 uint64_t sesid; /* *host* byte order - not necessarily little-endian! */
231 smb2_conv_info_t *conv;
232 smb2_sesid_info_t *session;
234
236 unsigned orig_size;
237 unsigned alg;
238 unsigned comp_offset;
239 smb2_conv_info_t *conv;
240 smb2_sesid_info_t *session;
242
243
244int dissect_smb2_FILE_OBJECTID_BUFFER(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset);
245int dissect_smb2_ioctl_function(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, uint32_t *ioctl_function);
246void dissect_smb2_ioctl_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *top_tree, uint32_t ioctl_function, bool data_in, void *private_data);
247
248#endif
249
250/*
251 * Editor modelines - https://www.wireshark.org/tools/modelines.html
252 *
253 * Local variables:
254 * c-basic-offset: 8
255 * tab-width: 8
256 * indent-tabs-mode: t
257 * End:
258 *
259 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
260 * :indentSize=8:tabSize=8:noTabs=false:
261 */
Definition packet-dcerpc.h:54
Definition guid-utils.h:23
Definition packet_info.h:43
Definition proto.h:907
Definition packet-smb2.h:235
Definition packet-smb2.h:127
Definition packet-smb2.h:36
Definition packet-smb2.h:41
Definition packet-smb2.h:207
Definition packet-smb2.h:65
Definition packet-smb2.h:100
Definition packet-smb2.h:89
Definition packet-smb2.h:226
Definition packet-smb.h:112
Extended metadata for a value_string array.
Definition value_string.h:325
Definition wmem_map.c:60
Definition nstime.h:26
Definition tvbuff-int.h:36