mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-08 16:21:32 +00:00
Changes to add missing exclusion of ranges (#943)
Co-authored-by: Your Name <you@example.com>
This commit is contained in:
parent
f677be5e86
commit
e5083fbf25
@ -7,5 +7,7 @@ void ranges_init(void);
|
|||||||
|
|
||||||
gboolean range_is_excluded(gpointer address);
|
gboolean range_is_excluded(gpointer address);
|
||||||
|
|
||||||
|
void ranges_exclude();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -568,6 +568,8 @@ void ranges_init(void) {
|
|||||||
/* *NEVER* stalk the stalker, only bad things will ever come of this! */
|
/* *NEVER* stalk the stalker, only bad things will ever come of this! */
|
||||||
ranges_exclude_self();
|
ranges_exclude_self();
|
||||||
|
|
||||||
|
ranges_exclude();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean range_is_excluded(gpointer address) {
|
gboolean range_is_excluded(gpointer address) {
|
||||||
|
71
frida_mode/test/deferred/GNUmakefile
Normal file
71
frida_mode/test/deferred/GNUmakefile
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
PWD:=$(shell pwd)/
|
||||||
|
ROOT:=$(shell realpath $(PWD)../../..)/
|
||||||
|
BUILD_DIR:=$(PWD)build/
|
||||||
|
TESTINSTR_DATA_DIR:=$(BUILD_DIR)in/
|
||||||
|
TESTINSTR_DATA_FILE:=$(TESTINSTR_DATA_DIR)in
|
||||||
|
|
||||||
|
TESTINSTBIN:=$(BUILD_DIR)testinstr
|
||||||
|
TESTINSTSRC:=$(PWD)testinstr.c
|
||||||
|
|
||||||
|
QEMU_OUT:=$(BUILD_DIR)qemu-out
|
||||||
|
FRIDA_OUT:=$(BUILD_DIR)frida-out
|
||||||
|
|
||||||
|
GET_SYMBOL_ADDR:=$(ROOT)frida_mode/test/png/persistent/get_symbol_addr.py
|
||||||
|
|
||||||
|
ifndef ARCH
|
||||||
|
|
||||||
|
ARCH=$(shell uname -m)
|
||||||
|
ifeq "$(ARCH)" "aarch64"
|
||||||
|
ARCH:=arm64
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(ARCH)" "i686"
|
||||||
|
ARCH:=x86
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ARCH=$(shell uname -m)
|
||||||
|
ifeq "$(ARCH)" "aarch64"
|
||||||
|
AFL_ENTRYPOINT=$(shell $(GET_SYMBOL_ADDR) -f $(TESTINSTBIN) -s run -b 0x0000aaaaaaaaa000)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(ARCH)" "x86_64"
|
||||||
|
AFL_ENTRYPOINT=$(shell $(GET_SYMBOL_ADDR) -f $(TESTINSTBIN) -s run -b 0x0000555555554000)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(ARCH)" "x86"
|
||||||
|
AFL_ENTRYPOINT=$(shell $(GET_SYMBOL_ADDR) -f $(TESTINSTBIN) -s run -b 0x56555000)
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: all clean qemu frida
|
||||||
|
|
||||||
|
all: $(TESTINSTBIN)
|
||||||
|
make -C $(ROOT)frida_mode/
|
||||||
|
|
||||||
|
32:
|
||||||
|
CFLAGS="-m32" LDFLAGS="-m32" ARCH="x86" make all
|
||||||
|
|
||||||
|
$(BUILD_DIR):
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
$(TESTINSTR_DATA_DIR): | $(BUILD_DIR)
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
$(TESTINSTR_DATA_FILE): | $(TESTINSTR_DATA_DIR)
|
||||||
|
echo -n "000" > $@
|
||||||
|
|
||||||
|
$(TESTINSTBIN): $(TESTINSTSRC) | $(BUILD_DIR)
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
|
frida: $(TESTINSTBIN) $(TESTINSTR_DATA_FILE)
|
||||||
|
AFL_ENTRYPOINT=$(AFL_ENTRYPOINT) \
|
||||||
|
$(ROOT)afl-fuzz \
|
||||||
|
-D \
|
||||||
|
-O \
|
||||||
|
-i $(TESTINSTR_DATA_DIR) \
|
||||||
|
-o $(FRIDA_OUT) \
|
||||||
|
-- \
|
||||||
|
$(TESTINSTBIN) @@
|
13
frida_mode/test/deferred/Makefile
Normal file
13
frida_mode/test/deferred/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
all:
|
||||||
|
@echo trying to use GNU make...
|
||||||
|
@gmake all || echo please install GNUmake
|
||||||
|
|
||||||
|
32:
|
||||||
|
@echo trying to use GNU make...
|
||||||
|
@gmake 32 || echo please install GNUmake
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@gmake clean
|
||||||
|
|
||||||
|
frida:
|
||||||
|
@gmake frida
|
125
frida_mode/test/deferred/testinstr.c
Normal file
125
frida_mode/test/deferred/testinstr.c
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
american fuzzy lop++ - a trivial program to test the build
|
||||||
|
--------------------------------------------------------
|
||||||
|
Originally written by Michal Zalewski
|
||||||
|
Copyright 2014 Google Inc. All rights reserved.
|
||||||
|
Copyright 2019-2020 AFLplusplus Project. All rights reserved.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at:
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define TESTINSTR_SECTION
|
||||||
|
#else
|
||||||
|
#define TESTINSTR_SECTION __attribute__((section(".testinstr")))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void testinstr(char *buf, int len) {
|
||||||
|
|
||||||
|
if (len < 1) return;
|
||||||
|
buf[len] = 0;
|
||||||
|
|
||||||
|
// we support three input cases
|
||||||
|
if (buf[0] == '0')
|
||||||
|
printf("Looks like a zero to me!\n");
|
||||||
|
else if (buf[0] == '1')
|
||||||
|
printf("Pretty sure that is a one!\n");
|
||||||
|
else
|
||||||
|
printf("Neither one or zero? How quaint!\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int run(char *file) {
|
||||||
|
|
||||||
|
int fd = -1;
|
||||||
|
off_t len;
|
||||||
|
char * buf = NULL;
|
||||||
|
size_t n_read;
|
||||||
|
int result = -1;
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
dprintf(STDERR_FILENO, "Running: %s\n", file);
|
||||||
|
|
||||||
|
fd = open(file, O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
|
||||||
|
perror("open");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
len = lseek(fd, 0, SEEK_END);
|
||||||
|
if (len < 0) {
|
||||||
|
|
||||||
|
perror("lseek (SEEK_END)");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lseek(fd, 0, SEEK_SET) != 0) {
|
||||||
|
|
||||||
|
perror("lseek (SEEK_SET)");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = malloc(len);
|
||||||
|
if (buf == NULL) {
|
||||||
|
|
||||||
|
perror("malloc");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
n_read = read(fd, buf, len);
|
||||||
|
if (n_read != len) {
|
||||||
|
|
||||||
|
perror("read");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dprintf(STDERR_FILENO, "Running: %s: (%zd bytes)\n", file, n_read);
|
||||||
|
|
||||||
|
testinstr(buf, len);
|
||||||
|
dprintf(STDERR_FILENO, "Done: %s: (%zd bytes)\n", file, n_read);
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
} while (false);
|
||||||
|
|
||||||
|
if (buf != NULL) { free(buf); }
|
||||||
|
|
||||||
|
if (fd != -1) { close(fd); }
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void slow() {
|
||||||
|
|
||||||
|
usleep(100000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TESTINSTR_SECTION int do_run(char * file) {
|
||||||
|
return run(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
if (argc != 2) { return 1; }
|
||||||
|
slow();
|
||||||
|
return do_run(argv[1]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user