OpenVAS Scanner 23.23.1
smb.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Greenbone AG
2 * SPDX-FileCopyrightText: 2002 Martin Pool
3 * SPDX-FileCopyrightText: 2001-2002 Simo Sorce
4 * SPDX-FileCopyrightText: 1998-2000 Paul Ashton
5 * SPDX-FileCopyrightText: 1996-2002 John H Terpstra
6 * SPDX-FileCopyrightText: 1996-2000 Luke Kenneth Casson Leighton
7 * SPDX-FileCopyrightText: 1992-2000 Andrew Tridgell
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
22
23#ifndef NASL_SMB_H
24#define NASL_SMB_H
25
26#include "charset.h"
27
28#include <ctype.h>
29#include <errno.h>
30#include <stdint.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34
35#define SMB_PORT1 445
36#define SMB_PORT2 139
37#define SMB_PORTS "445 139"
38
39/* offsets into message for common items */
40#define smb_com 8
41#define smb_rcls 9
42#define smb_reh 10
43#define smb_err 11
44#define smb_flg 13
45#define smb_flg2 14
46#define smb_pidhigh 16
47#define smb_ss_field 18
48#define smb_tid 28
49#define smb_pid 30
50#define smb_uid 32
51#define smb_mid 34
52#define smb_wct 36
53#define smb_vwv 37
54#define smb_vwv0 37
55#define smb_vwv1 39
56#define smb_vwv2 41
57#define smb_vwv3 43
58#define smb_vwv4 45
59#define smb_vwv5 47
60#define smb_vwv6 49
61#define smb_vwv7 51
62#define smb_vwv8 53
63#define smb_vwv9 55
64#define smb_vwv10 57
65#define smb_vwv11 59
66#define smb_vwv12 61
67#define smb_vwv13 63
68#define smb_vwv14 65
69#define smb_vwv15 67
70#define smb_vwv16 69
71#define smb_vwv17 71
72
73/* generic iconv conversion structure */
74typedef struct _smb_iconv_t
75{
76 size_t (*direct) (void *cd, const char **inbuf, size_t *inbytesleft,
77 char **outbuf, size_t *outbytesleft);
78 size_t (*pull) (void *cd, const char **inbuf, size_t *inbytesleft,
79 char **outbuf, size_t *outbytesleft);
80 size_t (*push) (void *cd, const char **inbuf, size_t *inbytesleft,
81 char **outbuf, size_t *outbytesleft);
85
86/* string manipulation flags - see clistr.c and srvstr.c */
87#define STR_TERMINATE 1
88#define STR_UPPER 2
89#define STR_ASCII 4
90#define STR_UNICODE 8
91#define STR_NOALIGN 16
92#define STR_TERMINATE_ASCII 128
93
94/* Sercurity mode bits. */
95#define NEGOTIATE_SECURITY_USER_LEVEL 0x01
96#define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
97#define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
98#define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
99
100/* NT Flags2 bits - cifs6.txt section 3.1.2 */
101
102#define FLAGS2_LONG_PATH_COMPONENTS 0x0001
103#define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
104#define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
105#define FLAGS2_UNKNOWN_BIT4 0x0010
106#define FLAGS2_IS_LONG_NAME 0x0040
107#define FLAGS2_EXTENDED_SECURITY 0x0800
108#define FLAGS2_DFS_PATHNAMES 0x1000
109#define FLAGS2_READ_PERMIT_EXECUTE 0x2000
110#define FLAGS2_32_BIT_ERROR_CODES 0x4000
111#define FLAGS2_UNICODE_STRINGS 0x8000
112
113#define FLAGS2_WIN2K_SIGNATURE 0xC852 /* Hack alert ! For now... JRA. */
114
115/* TCONX Flag (smb_vwv2). */
116#define TCONX_FLAG_EXTENDED_RESPONSE 0x8
117
118/* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
119
120#define CAP_RAW_MODE 0x0001
121#define CAP_MPX_MODE 0x0002
122#define CAP_UNICODE 0x0004
123#define CAP_LARGE_FILES 0x0008
124#define CAP_NT_SMBS 0x0010
125#define CAP_RPC_REMOTE_APIS 0x0020
126#define CAP_STATUS32 0x0040
127#define CAP_LEVEL_II_OPLOCKS 0x0080
128#define CAP_LOCK_AND_READ 0x0100
129#define CAP_NT_FIND 0x0200
130#define CAP_DFS 0x1000
131#define CAP_W2K_SMBS 0x2000
132#define CAP_LARGE_READX 0x4000
133#define CAP_LARGE_WRITEX 0x8000
134#define CAP_UNIX \
135 0x800000 /* Capabilities for UNIX extensions. Created by HP. \
136 */
137#define CAP_EXTENDED_SECURITY 0x80000000
138
139/* protocol types. It assumes that higher protocols include lower protocols
149};
150
151#ifdef WORDS_BIGENDIAN
152#define UCS2_SHIFT 8
153#else
154#define UCS2_SHIFT 0
155#endif
156
157/* turn a 7 bit character into a ucs2 character */
158#define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
159
160/* return an ascii version of a ucs2 character */
161#define UCS2_TO_CHAR(c) (((c) >> UCS2_SHIFT) & 0xff)
162
163/* Copy into a smb_ucs2_tt from a possibly unaligned buffer. Return the copied
164 * smb_ucs2_tt */
165#define COPY_UCS2_CHAR(dest, src) \
166 (((unsigned char *) (dest))[0] = ((unsigned char *) (src))[0], \
167 ((unsigned char *) (dest))[1] = ((unsigned char *) (src))[1], (dest))
168
169/* 64 bit time (100 nanosec) 1601 - cifs6.txt, section 3.5, page 30, 4 byte
170 * aligned */
171typedef uint64_t NTTIME;
173#define SMB_MALLOC_P(type) (type *) malloc (sizeof (type))
175#define SMB_REALLOC(p, s) \
176 Realloc ((p), (s), True) /* Always frees p on error or s == 0 */
177#ifndef SMB_MALLOC
178#define SMB_MALLOC(s) malloc (s)
179#endif
181#define SMB_STRDUP(s) strdup (s)
182#define SMB_STRNDUP(s, n) strndup (s, n)
184#define smb_len(buf) \
185 (PVAL (buf, 3) | (PVAL (buf, 2) << 8) | ((PVAL (buf, 1) & 1) << 16))
186
187#ifndef MIN
188#define MIN(a, b) ((a) < (b) ? (a) : (b))
189#endif
190/*---------------------------------------------------------------------------------*/
191
192#endif /* NASL_SMB_H */
Unix SMB/CIFS implementation. charset defines.
protocol_types
Definition smb.h:141
@ PROTOCOL_LANMAN2
Definition smb.h:146
@ PROTOCOL_COREPLUS
Definition smb.h:144
@ PROTOCOL_CORE
Definition smb.h:143
@ PROTOCOL_LANMAN1
Definition smb.h:145
@ PROTOCOL_NT1
Definition smb.h:147
@ PROTOCOL_NONE
Definition smb.h:142
struct _smb_iconv_t * smb_iconv_t
uint64_t NTTIME
Definition smb.h:170
Definition smb.h:75
char * from_name
Definition smb.h:83
void * cd_direct
Definition smb.h:82
size_t(* push)(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition smb.h:80
size_t(* pull)(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition smb.h:78
size_t(* direct)(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition smb.h:76
char * to_name
Definition smb.h:83
void * cd_pull
Definition smb.h:82
void * cd_push
Definition smb.h:82