about summary refs log tree commit diff
path: root/custom_mutators
diff options
context:
space:
mode:
authoryangzao <yangzaocn@outlook.com>2023-11-24 11:06:06 -0700
committeryangzao <yangzaocn@outlook.com>2023-11-24 11:06:06 -0700
commit770e868d04c0f52a1c57e5471e459dd24a002748 (patch)
tree3a7e42ea3385ce941839caa759b8c2da03356b83 /custom_mutators
parentd6cefdc1936fc0c312670469502d8ba9208530a3 (diff)
downloadafl++-770e868d04c0f52a1c57e5471e459dd24a002748.tar.gz
add custom_post_run.c
Diffstat (limited to 'custom_mutators')
-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..073aac96
--- /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_send.so -I../../include custom_send.c /////////////////////to_be_edited
+// cd ../..
+// afl-cc -o test-instr test-instr.c
+// AFL_CUSTOM_MUTATOR_LIBRARY=custom_mutators/examples/custom_send.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, uint8_t *buf, size_t buf_size) {
+
+  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