Check-in [05a7ef3fae]
Overview
Comment:Added AFL test script
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 05a7ef3faeab86e29c4f0584659de974d4e77e4d
User & Date: rkeene on 2020-03-31 18:46:11
Other Links: manifest | tags
Context
2020-03-31
18:50
Ensure wiki update happens on the correct directory check-in: f901bb8bfd user: rkeene tags: trunk
18:46
Added AFL test script check-in: 05a7ef3fae user: rkeene tags: trunk
14:30
Integrated remove-c11-atomics changes check-in: 7ee2e833d2 user: rkeene tags: trunk
Changes

Added build/test-afl version [fd2b240781].



































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#! /usr/bin/env bash

PATH="/opt/appfs/rkeene.org/afl/platform/latest/bin:${PATH:-/dev/null/null}"
export PATH

set -e

sourcedir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

workdir=''
inputdir=''
outputdir=''
function cleanup() {
	cd /
	if [ -n "${outputdir}" -a -d "${outputdir}" ]; then
		cp -rp "${outputdir}" "${sourcedir}/build/afl-$(uname -n | cut -f 1 -d .)-$(stat -c %Y "${outputdir}")"
	fi

	if [ -n "${workdir}" ]; then
		rm -rf "${workdir}"
		workdir=''
	fi
}
trap cleanup EXIT

workdir="$(mktemp -d)"
inputdir="${workdir}/input"
outputdir="${workdir}/output"
mkdir "${workdir}/src"

cp -r "${sourcedir}"/* "${workdir}/src/"

(
	set -e

	cd "${workdir}"
	mkdir "${inputdir}" "${outputdir}"

	echo $'GET /etc/passwd HTTP/1.1\x0d\x0aHost: example.com\x0d\x0a\x0d\x0a' > input/test-1

	cd 'src'
	make distclean
	make CC=afl-gcc FILED_EXTRA_CFLAGS=-DFILED_TEST_AFL=1

	#export AFL_SKIP_CPUFREQ=1
	afl-fuzz -i "${inputdir}" -o "${outputdir}" -- ./filed
)

exit 0

Modified filed.c from [7252b16239] to [eba3a486d8].

56
57
58
59
60
61
62

63
64
65
66
67
68
69
#define BIND_ADDR "::"
#define CACHE_SIZE 8209
#define LOG_FILE "-"

/* Fuzzing Test Code */
#ifdef FILED_TEST_AFL
#define FILED_DONT_LOG 1

#define pthread_create(a, x, y, z) afl_pthread_create(a, x, y, z)
#define bind(x, y, z) afl_bind(x, y, z)
#define socket(x, y, z) 8193
#define listen(x, y) 0
#define accept(x, y, z) afl_accept(x, y, z)
#define close(x) { if (strcmp(#x, "random_fd") == 0) { close(x); } else { exit(0); } }
#define fclose(x) exit(0)







>







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#define BIND_ADDR "::"
#define CACHE_SIZE 8209
#define LOG_FILE "-"

/* Fuzzing Test Code */
#ifdef FILED_TEST_AFL
#define FILED_DONT_LOG 1
#define FILED_DONT_TIMEOUT 1
#define pthread_create(a, x, y, z) afl_pthread_create(a, x, y, z)
#define bind(x, y, z) afl_bind(x, y, z)
#define socket(x, y, z) 8193
#define listen(x, y) 0
#define accept(x, y, z) afl_accept(x, y, z)
#define close(x) { if (strcmp(#x, "random_fd") == 0) { close(x); } else { exit(0); } }
#define fclose(x) exit(0)