1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
#!/usr/bin/env python
from waflib import Build
bld.SAMBA_SUBSYSTEM('fuzzing',
source='fuzzing.c',
deps='talloc')
bld.SAMBA_SUBSYSTEM('afl-fuzz-main',
source='afl-fuzz-main.c',
deps='samba-util',
enabled=bld.env.enable_afl_fuzzer
)
bld.SAMBA_BINARY('fuzz_tiniparser',
source='fuzz_tiniparser.c',
deps='fuzzing tiniparser talloc afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_parse_lpq_entry',
source='fuzz_parse_lpq_entry.c',
deps='fuzzing afl-fuzz-main smbd_base PRINTING',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_oLschema2ldif',
source='fuzz_oLschema2ldif.c',
deps='fuzzing oLschema2ldif-lib afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_reg_parse',
source='fuzz_reg_parse.c',
deps='fuzzing samba3-util smbconf REGFIO afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_sddl_parse',
source='fuzz_sddl_parse.c',
deps='fuzzing samba-security afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_sess_crypt_blob',
source='fuzz_sess_crypt_blob.c',
deps='fuzzing samba-security LIBCLI_AUTH NDR_DSSETUP afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_conditional_ace_blob',
source='fuzz_conditional_ace_blob.c',
deps='fuzzing samba-security afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_nmblib_parse_packet',
source='fuzz_nmblib_parse_packet.c',
deps='fuzzing libsmb afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_sddl_access_check',
source='fuzz_sddl_access_check.c',
deps='fuzzing samba-security afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_sddl_access_check_ds',
cflags='-DFUZZ_SEC_ACCESS_CHECK_DS=1',
source='fuzz_sddl_access_check.c',
deps='fuzzing samba-security afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_regfio',
source='fuzz_regfio.c',
deps='fuzzing samba3-util smbconf REGFIO afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_lzxpress',
source='fuzz_lzxpress.c',
deps='fuzzing LZXPRESS afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_lzxpress_compress',
source='fuzz_lzxpress_compress.c',
deps='fuzzing LZXPRESS afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_lzxpress_round_trip',
source='fuzz_lzxpress_round_trip.c',
deps='fuzzing LZXPRESS afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_lzxpress_huffman_decompress',
source='fuzz_lzxpress_huffman_decompress.c',
deps='fuzzing LZXPRESS afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_lzxpress_huffman_compress',
source='fuzz_lzxpress_huffman_compress.c',
deps='fuzzing LZXPRESS afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_lzxpress_huffman_round_trip',
source='fuzz_lzxpress_huffman_round_trip.c',
deps='fuzzing LZXPRESS afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_ldap_decode',
source='fuzz_ldap_decode.c',
deps='fuzzing cli-ldap afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_ldb_parse_control',
source='fuzz_ldb_parse_control.c',
deps='fuzzing ldb afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_ldb_dn_explode',
source='fuzz_ldb_dn_explode.c',
deps='fuzzing ldb afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_ldb_ldif_read',
source='fuzz_ldb_ldif_read.c',
deps='fuzzing ldb afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_ldb_parse_binary_decode',
source='fuzz_ldb_parse_binary_decode.c',
deps='fuzzing ldb afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_ldb_parse_tree',
source='fuzz_ldb_parse_tree.c',
deps='fuzzing ldb afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_ldb_comparison_fold',
source='fuzz_ldb_comparison_fold.c',
deps='fuzzing ldb afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_dcerpc_parse_binding',
source='fuzz_dcerpc_parse_binding.c',
deps='fuzzing dcerpc afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_cli_credentials_parse_string',
source='fuzz_cli_credentials_parse_string.c',
deps='fuzzing samba-credentials afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_stable_sort',
source='fuzz_stable_sort.c',
deps='fuzzing stable_sort afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_stable_sort_r',
source='fuzz_stable_sort_r.c',
deps='fuzzing stable_sort afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_security_token_vs_descriptor',
source='fuzz_security_token_vs_descriptor.c',
deps='fuzzing samba-security afl-fuzz-main',
fuzzer=True)
bld.SAMBA_BINARY('fuzz_security_token_vs_descriptor_ds',
cflags='-DFUZZ_SEC_ACCESS_CHECK_DS=1',
source='fuzz_security_token_vs_descriptor.c',
deps='fuzzing samba-security afl-fuzz-main',
fuzzer=True)
# The fuzz_type and fuzz_function parameters make the built
# fuzzer take the same input as ndrdump and so the same that
# could be sent to the client or server as the stub data.
def SAMBA_NDR_FUZZ(bld, interface, auto_deps=False,
fuzz_type=None, fuzz_function=None):
name = "fuzz_ndr_%s" % (interface.lower())
fuzz_dir = os.path.join(bld.env.srcdir, 'lib/fuzzing')
fuzz_reldir = os.path.relpath(fuzz_dir, bld.path.abspath())
fuzz_src = os.path.join(fuzz_reldir, 'fuzz_ndr_X.c')
cflags = "-D FUZZ_PIPE_TABLE=ndr_table_%s" % interface
if fuzz_type:
name += "_%s" % (fuzz_type)
cflags += " -D FUZZ_TYPE=%s " % (fuzz_type)
if fuzz_type and fuzz_function:
name += "_%d" % (fuzz_function)
cflags += " -D FUZZ_FUNCTION=%d" % (fuzz_function)
fuzz_named_src = os.path.join(fuzz_reldir,
'%s.c' % (name))
# Work around an issue that WAF is invoked from up to 3 different
# directories so doesn't create a unique name for the multiple .o
# files like it would if called from just one place.
bld.SAMBA_GENERATOR(fuzz_named_src,
source=fuzz_src,
target=fuzz_named_src,
rule='cp ${SRC} ${TGT}')
if auto_deps:
deps = "afl-fuzz-main talloc ndr NDR_%s" % interface.upper()
else:
deps = "afl-fuzz-main ndr-table NDR_DCERPC"
bld.SAMBA_BINARY(name, source=fuzz_named_src,
cflags = cflags,
deps = deps,
fuzzer=True)
Build.BuildContext.SAMBA_NDR_FUZZ = SAMBA_NDR_FUZZ
# fuzz_ndr_X is generated from the list of IDL fed to PIDL
# however there are exceptions to the normal pattern
bld.SAMBA_NDR_FUZZ('iremotewinspool') # winspool.idl
bld.SAMBA_NDR_FUZZ('FileServerVssAgent') # fsvrp.idl
bld.SAMBA_NDR_FUZZ('lsarpc') # lsa.idl
bld.SAMBA_NDR_FUZZ('netdfs') # dfs.idl
bld.SAMBA_NDR_FUZZ('nfs4acl_interface') # nfs4acl.idl
bld.SAMBA_NDR_FUZZ('rpcecho') # echo.idl
# quota.idl
bld.SAMBA_NDR_FUZZ('file_quota')
bld.SAMBA_NDR_FUZZ('smb2_query_quota')
bld.SAMBA_NDR_FUZZ('smb1_nt_transact_query_quota')
# ioctl.idl
bld.SAMBA_NDR_FUZZ('copychunk')
bld.SAMBA_NDR_FUZZ('compression')
bld.SAMBA_NDR_FUZZ('netinterface')
bld.SAMBA_NDR_FUZZ('sparse')
bld.SAMBA_NDR_FUZZ('resiliency')
bld.SAMBA_NDR_FUZZ('trim')
# Specific struct or function on the interface
bld.SAMBA_NDR_FUZZ('spoolss',
auto_deps=True,
fuzz_type="TYPE_IN",
fuzz_function=65)
|