mirror of
https://github.com/bdnugget/kcgi.git
synced 2026-11-07 05:47:27 +00:00
Upgrade AFL infrastructure to use dictionaries and per-content-type.
This commit is contained in:
1 parent
838d004d46
commit
7dc7b18415
24 files changed
+262
-16
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
CFLAGS += -g -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings -DHAVE_CONFIG_H
|
||||
# Comment if you don't need statically linked.
|
||||
STATIC = -static
|
||||
#STATIC = -static
|
||||
PREFIX = /usr/local
|
||||
DATADIR = $(PREFIX)/share/kcgi
|
||||
VERSIONS = version_0_4_2.xml \
|
||||
@@ -88,7 +88,9 @@ SRCS = compat-memmem.c \
|
||||
wrappers.c \
|
||||
$(MANS) \
|
||||
$(TESTS)
|
||||
AFL = afl/afl-test
|
||||
AFL = afl/afl-multipart \
|
||||
afl/afl-plain \
|
||||
afl/afl-urlencoded
|
||||
REGRESS = regress/test-abort-validator \
|
||||
regress/test-file-get \
|
||||
regress/test-ping \
|
||||
@@ -98,7 +100,9 @@ REGRESS_OBJS = regress/regress.o \
|
||||
regress/test-file-get.o \
|
||||
regress/test-ping.o \
|
||||
regress/test-upload.o
|
||||
AFL_SRCS = afl/afl-test.c
|
||||
AFL_SRCS = afl/afl-multipart.c \
|
||||
afl/afl-plain.c \
|
||||
afl/afl-urlencoded.c
|
||||
REGRESS_SRCS = regress/regress.c \
|
||||
regress/regress.h \
|
||||
regress/test-abort-validator.c \
|
||||
@@ -132,8 +136,14 @@ regress/test-upload: regress/test-upload.c regress/regress.o libkcgiregress.a li
|
||||
regress/regress.o: regress/regress.c
|
||||
$(CC) $(CFLAGS) `curl-config --cflags` -o $@ -c regress/regress.c
|
||||
|
||||
afl/afl-test: afl/afl-test.c libkcgi.a
|
||||
$(CC) $(CFLAGS) -o $@ afl/afl-test.c libkcgi.a -lz
|
||||
afl/afl-multipart: afl/afl-multipart.c libkcgi.a
|
||||
$(CC) $(CFLAGS) -o $@ afl/afl-multipart.c libkcgi.a -lz
|
||||
|
||||
afl/afl-plain: afl/afl-plain.c libkcgi.a
|
||||
$(CC) $(CFLAGS) -o $@ afl/afl-plain.c libkcgi.a -lz
|
||||
|
||||
afl/afl-urlencoded: afl/afl-urlencoded.c libkcgi.a
|
||||
$(CC) $(CFLAGS) -o $@ afl/afl-urlencoded.c libkcgi.a -lz
|
||||
|
||||
libkcgi.a: $(LIBOBJS)
|
||||
$(AR) rs $@ $(LIBOBJS)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (c) 2015 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../kcgi.h"
|
||||
#include "../extern.h"
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int fdout, fdin;
|
||||
struct kworker work;
|
||||
struct stat st;
|
||||
char buf[1024];
|
||||
|
||||
if (2 != argc)
|
||||
return(EXIT_FAILURE);
|
||||
|
||||
if (-1 == (fdout = open(_PATH_DEVNULL, O_RDWR, 0))) {
|
||||
perror(_PATH_DEVNULL);
|
||||
return(EXIT_FAILURE);
|
||||
} else if (-1 == (fdin = open(argv[1], O_RDONLY, 0))) {
|
||||
perror(argv[1]);
|
||||
close(fdout);
|
||||
return(EXIT_FAILURE);
|
||||
} else if (-1 == fstat(fdin, &st)) {
|
||||
perror(argv[1]);
|
||||
close(fdout);
|
||||
close(fdin);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%llu",
|
||||
(unsigned long long)st.st_size);
|
||||
setenv("CONTENT_TYPE", "multipart/form-data; "
|
||||
"boundary=---------------------------9051914041544843365972754266", 1);
|
||||
setenv("REQUEST_METHOD", "post", 1);
|
||||
setenv("CONTENT_LENGTH", buf, 1);
|
||||
memset(&work, 0, sizeof(struct kworker));
|
||||
work.sock[KWORKER_WRITE] = fdout;
|
||||
work.sock[KWORKER_READ] = -1;
|
||||
work.input = fdin;
|
||||
khttp_input_child(&work, NULL, 0, kmimetypes, KMIME__MAX);
|
||||
close(fdin);
|
||||
close(fdout);
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (c) 2015 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../kcgi.h"
|
||||
#include "../extern.h"
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int fdout, fdin;
|
||||
struct kworker work;
|
||||
struct stat st;
|
||||
char buf[1024];
|
||||
|
||||
if (2 != argc)
|
||||
return(EXIT_FAILURE);
|
||||
|
||||
if (-1 == (fdout = open(_PATH_DEVNULL, O_RDWR, 0))) {
|
||||
perror(_PATH_DEVNULL);
|
||||
return(EXIT_FAILURE);
|
||||
} else if (-1 == (fdin = open(argv[1], O_RDONLY, 0))) {
|
||||
perror(argv[1]);
|
||||
close(fdout);
|
||||
return(EXIT_FAILURE);
|
||||
} else if (-1 == fstat(fdin, &st)) {
|
||||
perror(argv[1]);
|
||||
close(fdout);
|
||||
close(fdin);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%llu",
|
||||
(unsigned long long)st.st_size);
|
||||
setenv("CONTENT_TYPE", "text/plain", 1);
|
||||
setenv("REQUEST_METHOD", "post", 1);
|
||||
setenv("CONTENT_LENGTH", buf, 1);
|
||||
memset(&work, 0, sizeof(struct kworker));
|
||||
work.sock[KWORKER_WRITE] = fdout;
|
||||
work.sock[KWORKER_READ] = -1;
|
||||
work.input = fdin;
|
||||
khttp_input_child(&work, NULL,
|
||||
0, kmimetypes, KMIME__MAX);
|
||||
close(fdin);
|
||||
close(fdout);
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
* Copyright (c) 2015 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../kcgi.h"
|
||||
#include "../extern.h"
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int fdout, fdin;
|
||||
struct kworker work;
|
||||
struct stat st;
|
||||
char buf[1024];
|
||||
|
||||
if (2 != argc)
|
||||
return(EXIT_FAILURE);
|
||||
|
||||
if (-1 == (fdout = open(_PATH_DEVNULL, O_RDWR, 0))) {
|
||||
perror(_PATH_DEVNULL);
|
||||
return(EXIT_FAILURE);
|
||||
} else if (-1 == (fdin = open(argv[1], O_RDONLY, 0))) {
|
||||
perror(argv[1]);
|
||||
close(fdout);
|
||||
return(EXIT_FAILURE);
|
||||
} else if (-1 == fstat(fdin, &st)) {
|
||||
perror(argv[1]);
|
||||
close(fdout);
|
||||
close(fdin);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%llu",
|
||||
(unsigned long long)st.st_size);
|
||||
setenv("CONTENT_TYPE", "application/x-www-form-urlencoded", 1);
|
||||
setenv("REQUEST_METHOD", "post", 1);
|
||||
setenv("CONTENT_LENGTH", buf, 1);
|
||||
memset(&work, 0, sizeof(struct kworker));
|
||||
work.sock[KWORKER_WRITE] = fdout;
|
||||
work.sock[KWORKER_READ] = -1;
|
||||
work.input = fdin;
|
||||
khttp_input_child(&work, NULL,
|
||||
0, kmimetypes, KMIME__MAX);
|
||||
close(fdin);
|
||||
close(fdout);
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
boundary
|
||||
@@ -0,0 +1 @@
|
||||
Content-Disposition
|
||||
@@ -0,0 +1 @@
|
||||
Content-Transfer-Encoding
|
||||
@@ -0,0 +1 @@
|
||||
Content-Type
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
filename
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
-----------------------------9051914041544843365972754266
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
-----------------------------9051914041544843365972754266--
|
||||
@@ -0,0 +1 @@
|
||||
--BbC04y
|
||||
@@ -0,0 +1 @@
|
||||
--BbC04y--
|
||||
@@ -0,0 +1 @@
|
||||
multipart/mixed
|
||||
@@ -0,0 +1 @@
|
||||
name
|
||||
@@ -0,0 +1 @@
|
||||
text/plain
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
foo=bar
|
||||
baz=The first line.
|
||||
The second line.
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
-----------------------------9051914041544843365972754266
|
||||
Content-Disposition: form-data; name="submit-name"
|
||||
|
||||
Larry
|
||||
-----------------------------9051914041544843365972754266
|
||||
Content-Disposition: form-data; name="files"; filename="file1.txt"
|
||||
Content-Type: text/plain
|
||||
|
||||
... contents o
|
||||
-----------------------------9051914041544843365972754266--
|
||||
@@ -0,0 +1,2 @@
|
||||
foo=bar&baz=The+first+line.
|
||||
The+second+line.
|
||||
@@ -277,6 +277,14 @@ int main(void) {
|
||||
The binding local port is fixed, too; so if you plan on running the regression suite, you may need to
|
||||
tweak its access port.
|
||||
</p>
|
||||
<p>
|
||||
Another testing framework exists for use with the <a href="http://lcamtuf.coredump.cx/afl/">American
|
||||
fuzzy lop</a>.
|
||||
To use this, you'll need to compile the <code>make afl</code> target with your compiler of choice, e.g.,
|
||||
<code>make clean</code>, then <code>make afl CC=afl-gcc</code>.
|
||||
Then run the <code>afl-fuzz</code> tool on the <code>afl-test</code> binary using the test cases
|
||||
provided.
|
||||
</p>
|
||||
</section>
|
||||
</article>
|
||||
<footer>
|
||||
|
||||
+1
-1
@@ -8,6 +8,6 @@
|
||||
Allow <a href="kcgi_regress.3.html">kcgi_regress(3)</a> to handle query strings and forms for validation testing.
|
||||
Split apart <a href="khttp_parse.3.html">khttp_parse(3)</a>'s internal implementation in getting ready for FastCGI: namely,
|
||||
abstract the worker interface. (This won't be released for quite a while.)
|
||||
Pick out numerous buglets in the parser by using the <a href="http://lcamtuf.coredump.cx/afl/">American fuzzy loop</a>.
|
||||
Pick out numerous buglets in the parser by using the <a href="http://lcamtuf.coredump.cx/afl/">American fuzzy lop</a>.
|
||||
</aside>
|
||||
</article>
|
||||
Reference in new issue
Block a user