about summary refs log tree commit diff
path: root/instrumentation/afl-compiler-rt.o.c
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2023-12-27 13:53:11 +0100
committervanhauser-thc <vh@thc.org>2023-12-27 13:53:11 +0100
commit1fc1b32db261b27cf14f0d1d7f77a06854b7376c (patch)
tree1b5e241dc505bb251a2603e5072d0a22df0bdf1d /instrumentation/afl-compiler-rt.o.c
parentb01ef97569060bb9f7451d1c2c301b5e774b8358 (diff)
downloadafl++-1fc1b32db261b27cf14f0d1d7f77a06854b7376c.tar.gz
initial simple injection detection support
Diffstat (limited to 'instrumentation/afl-compiler-rt.o.c')
-rw-r--r--instrumentation/afl-compiler-rt.o.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c
index def59b6b..50bafb9e 100644
--- a/instrumentation/afl-compiler-rt.o.c
+++ b/instrumentation/afl-compiler-rt.o.c
@@ -92,6 +92,8 @@ extern ssize_t _kern_write(int fd, off_t pos, const void *buffer,
                            size_t bufferSize);
 #endif  // HAIKU
 
+char *strcasestr(const char *haystack, const char *needle);
+
 static u8  __afl_area_initial[MAP_INITIAL_SIZE];
 static u8 *__afl_area_ptr_dummy = __afl_area_initial;
 static u8 *__afl_area_ptr_backup = __afl_area_initial;
@@ -2670,5 +2672,51 @@ void __afl_set_persistent_mode(u8 mode) {
 
 }
 
+void __afl_injection_sql(u8 *buf) {
+
+  if (likely(buf)) {
+
+    if (unlikely(strcasestr((char *)buf, "1'\" OR \"1\"=\"1") ||
+                 strcasestr((char *)buf, "1\"' OR '1'='1"))) {
+
+      fprintf(stderr, "ALERT: Detected SQL injection in query: %s\n", buf);
+      abort();
+
+    }
+
+  }
+
+}
+
+void __afl_injection_ldap(u8 *buf) {
+
+  if (likely(buf)) {
+
+    if (unlikely(strcasestr((char *)buf, "*)(FUZZ=*))(|"))) {
+
+      fprintf(stderr, "ALERT: Detected LDAP injection in query: %s\n", buf);
+      abort();
+
+    }
+
+  }
+
+}
+
+void __afl_injection_xss(u8 *buf) {
+
+  if (likely(buf)) {
+
+    if (unlikely(strcasestr((char *)buf, "\";FUZZ;\""))) {
+
+      fprintf(stderr, "ALERT: Detected XSS injection in content: %s\n", buf);
+      abort();
+
+    }
+
+  }
+
+}
+
 #undef write_error