about summary refs log tree commit diff
path: root/custom_mutators/examples/custom_post_run.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2023-12-05 17:56:06 +0100
committerGitHub <noreply@github.com>2023-12-05 17:56:06 +0100
commit12505861564c5a3b91220adbb944032a261d6fa4 (patch)
tree6e66ac8cbdd8237009c24b6f6b51d5f48913ce54 /custom_mutators/examples/custom_post_run.c
parent61e27c6b54f7641a168b6acc6ecffb1754c10918 (diff)
parent638273e4f80ba89ada8a4428a6211ee6b59d964a (diff)
downloadafl++-12505861564c5a3b91220adbb944032a261d6fa4.tar.gz
Merge pull request #1923 from AFLplusplus/dev
push to stable
Diffstat (limited to 'custom_mutators/examples/custom_post_run.c')
-rw-r--r--custom_mutators/examples/custom_post_run.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/custom_mutators/examples/custom_post_run.c b/custom_mutators/examples/custom_post_run.c
new file mode 100644
index 00000000..828216ea
--- /dev/null
+++ b/custom_mutators/examples/custom_post_run.c
@@ -0,0 +1,53 @@
+//
+// This is an example on how to use afl_custom_post_run
+// It executes custom code each time after AFL++ executes the target
+//
+// cc -O3 -fPIC -shared -g -o custom_post_run.so -I../../include custom_post_run.c
+// cd ../..
+// afl-cc -o test-instr test-instr.c
+// AFL_CUSTOM_MUTATOR_LIBRARY=custom_mutators/examples/custom_post_run.so \
+//   afl-fuzz -i in -o out -- ./test-instr -f /tmp/foo
+//
+
+
+#include "afl-fuzz.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+typedef struct my_mutator {
+
+  afl_state_t *afl;
+
+} my_mutator_t;
+
+my_mutator_t *afl_custom_init(afl_state_t *afl, unsigned int seed) {
+
+  my_mutator_t *data = calloc(1, sizeof(my_mutator_t));
+  if (!data) {
+
+    perror("afl_custom_init alloc");
+    return NULL;
+
+  }
+
+  data->afl = afl;
+
+  return data;
+
+}
+
+void afl_custom_post_run(my_mutator_t *data) {
+
+  printf("hello from afl_custom_post_run\n");
+  return;
+}
+
+
+void afl_custom_deinit(my_mutator_t *data) {
+
+  free(data);
+
+}
\ No newline at end of file