2019-04-04 01:23:07 +03:00
#!/usr/bin/env python
2019-10-31 06:28:28 +03:00
from waflib import Build
2019-04-04 01:23:07 +03:00
bld.SAMBA_SUBSYSTEM('fuzzing',
2019-12-04 11:23:06 +03:00
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
2019-04-04 01:23:07 +03:00
)
2019-04-04 02:03:58 +03:00
bld.SAMBA_BINARY('fuzz_tiniparser',
source='fuzz_tiniparser.c',
2019-12-04 11:23:06 +03:00
deps='fuzzing tiniparser talloc afl-fuzz-main',
2019-11-01 07:18:24 +03:00
fuzzer=True)
2019-04-04 02:10:11 +03:00
bld.SAMBA_BINARY('fuzz_oLschema2ldif',
source='fuzz_oLschema2ldif.c',
2019-12-04 11:23:06 +03:00
deps='fuzzing oLschema2ldif-lib afl-fuzz-main',
2019-11-01 07:18:24 +03:00
fuzzer=True)
2019-04-05 01:50:09 +03:00
bld.SAMBA_BINARY('fuzz_reg_parse',
source='fuzz_reg_parse.c',
2019-12-04 11:23:06 +03:00
deps='fuzzing samba3-util smbconf REGFIO afl-fuzz-main',
2019-11-01 07:18:24 +03:00
fuzzer=True)
2019-04-04 03:26:26 +03:00
bld.SAMBA_BINARY('fuzz_regfio',
source='fuzz_regfio.c',
2019-12-04 11:23:06 +03:00
deps='fuzzing samba3-util smbconf REGFIO afl-fuzz-main',
2019-11-01 07:18:24 +03:00
fuzzer=True)
2019-04-10 01:36:03 +03:00
bld.SAMBA_BINARY('fuzz_lzxpress',
source='fuzz_lzxpress.c',
2019-12-04 11:23:06 +03:00
deps='fuzzing LZXPRESS afl-fuzz-main',
2019-11-01 07:18:24 +03:00
fuzzer=True)
2019-04-10 02:20:36 +03:00
bld.SAMBA_BINARY('fuzz_ldap_decode',
source='fuzz_ldap_decode.c',
2019-12-04 11:23:06 +03:00
deps='fuzzing cli-ldap afl-fuzz-main',
2019-11-01 07:18:24 +03:00
fuzzer=True)
2019-04-12 01:46:49 +03:00
bld.SAMBA_BINARY('fuzz_ldb_parse_tree',
source='fuzz_ldb_parse_tree.c',
2019-12-04 11:23:06 +03:00
deps='fuzzing ldb afl-fuzz-main',
2019-11-01 07:18:24 +03:00
fuzzer=True)
2019-10-31 06:28:28 +03:00
2019-11-30 10:23:18 +03:00
# 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):
2019-10-31 06:28:28 +03:00
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')
2019-11-30 10:23:18 +03:00
cflags = "-D FUZZ_PIPE_TABLE=ndr_table_%s" % interface
2019-12-11 03:03:43 +03:00
if fuzz_type:
name += "_%s" % (fuzz_type)
cflags += " -D FUZZ_TYPE=%s " % (fuzz_type)
2019-11-30 10:23:18 +03:00
if fuzz_type and fuzz_function:
2019-12-11 03:03:43 +03:00
name += "_%d" % (fuzz_function)
cflags += " -D FUZZ_FUNCTION=%d" % (fuzz_function)
2019-11-30 10:23:18 +03:00
fuzz_named_src = os.path.join(fuzz_reldir,
'%s.c' % (name))
2019-10-31 06:28:28 +03:00
# 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}')
2019-11-29 02:07:34 +03:00
if auto_deps:
2019-12-04 11:23:06 +03:00
deps = "afl-fuzz-main talloc ndr NDR_%s" % interface.upper()
2019-11-29 02:07:34 +03:00
else:
2019-12-04 11:23:06 +03:00
deps = "afl-fuzz-main ndr-table NDR_DCERPC"
2019-11-29 02:07:34 +03:00
2019-10-31 06:28:28 +03:00
bld.SAMBA_BINARY(name, source=fuzz_named_src,
2019-11-30 10:23:18 +03:00
cflags = cflags,
2019-11-29 02:07:34 +03:00
deps = deps,
2019-10-31 06:28:28 +03:00
fuzzer=True)
Build.BuildContext.SAMBA_NDR_FUZZ = SAMBA_NDR_FUZZ
# fuzz_ndr_X is generated from the list if IDL fed to PIDL
# however there are exceptions to the normal pattern
bld.SAMBA_NDR_FUZZ('IOXIDResolver') # oxidresolver.idl
bld.SAMBA_NDR_FUZZ('IRemoteActivation') # remact.idl
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')
# WMI tables
bld.SAMBA_NDR_FUZZ('IWbemClassObject')
bld.SAMBA_NDR_FUZZ('IWbemServices')
bld.SAMBA_NDR_FUZZ('IEnumWbemClassObject')
bld.SAMBA_NDR_FUZZ('IWbemContext')
bld.SAMBA_NDR_FUZZ('IWbemLevel1Login')
bld.SAMBA_NDR_FUZZ('IWbemWCOSmartEnum')
bld.SAMBA_NDR_FUZZ('IWbemFetchSmartEnum')
bld.SAMBA_NDR_FUZZ('IWbemCallResult')
bld.SAMBA_NDR_FUZZ('IWbemObjectSink')
# DCOM tables
bld.SAMBA_NDR_FUZZ('dcom_Unknown')
bld.SAMBA_NDR_FUZZ('IUnknown')
bld.SAMBA_NDR_FUZZ('IClassFactory')
bld.SAMBA_NDR_FUZZ('IRemUnknown')
bld.SAMBA_NDR_FUZZ('IClassActivator')
bld.SAMBA_NDR_FUZZ('ISCMLocalActivator')
bld.SAMBA_NDR_FUZZ('IMachineLocalActivator')
bld.SAMBA_NDR_FUZZ('ILocalObjectExporter')
bld.SAMBA_NDR_FUZZ('ISystemActivator')
bld.SAMBA_NDR_FUZZ('IRemUnknown2')
bld.SAMBA_NDR_FUZZ('IDispatch')
bld.SAMBA_NDR_FUZZ('IMarshal')
bld.SAMBA_NDR_FUZZ('ICoffeeMachine')
bld.SAMBA_NDR_FUZZ('IStream')
2019-11-30 10:23:18 +03:00
# Specific struct or function on the interface
bld.SAMBA_NDR_FUZZ('spoolss',
auto_deps=True,
fuzz_type="TYPE_IN",
fuzz_function=65)