about summary refs log tree commit diff
path: root/frida_mode/src/entry.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-11-03 21:55:21 +0100
committerGitHub <noreply@github.com>2021-11-03 21:55:21 +0100
commitf5535e348d37460daa4c6ea43063b451aa83d9cc (patch)
tree2339a99aa53f604cbe77b0dc88882f29ec9a6bf6 /frida_mode/src/entry.c
parent25c947cd5ae93cb865081f9259255b4fdb3ca3ba (diff)
parent9278f27d749bcf0852ba2629caa319375c9a60e4 (diff)
downloadafl++-f5535e348d37460daa4c6ea43063b451aa83d9cc.tar.gz
Merge pull request #1142 from AFLplusplus/dev
Dev
Diffstat (limited to 'frida_mode/src/entry.c')
-rw-r--r--frida_mode/src/entry.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/frida_mode/src/entry.c b/frida_mode/src/entry.c
index 186ddd3a..c51e202f 100644
--- a/frida_mode/src/entry.c
+++ b/frida_mode/src/entry.c
@@ -1,5 +1,9 @@
 #include <dlfcn.h>
 
+#if defined(__linux__) && !defined(__ANDROID__)
+  #include <sys/prctl.h>
+#endif
+
 #include "frida-gumjs.h"
 
 #include "debug.h"
@@ -16,6 +20,7 @@
 extern void __afl_manual_init();
 
 guint64  entry_point = 0;
+gboolean traceable = FALSE;
 gboolean entry_compiled = FALSE;
 gboolean entry_run = FALSE;
 
@@ -26,21 +31,48 @@ static void entry_launch(void) {
 
   /* Child here */
   entry_run = TRUE;
+  entry_on_fork();
   instrument_on_fork();
   seccomp_on_fork();
   stats_on_fork();
 
 }
 
+#if defined(__linux__) && !defined(__ANDROID__)
+void entry_on_fork(void) {
+
+  if (traceable) {
+
+    if (prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY) < 0) {
+
+      FATAL("Failed to PR_SET_PTRACER");
+
+    }
+
+  }
+
+}
+
+#else
+void entry_on_fork(void) {
+
+  if (traceable) { WARNF("AFL_FRIDA_TRACEABLE unsupported"); }
+
+}
+
+#endif
+
 void entry_config(void) {
 
   entry_point = util_read_address("AFL_ENTRYPOINT");
+  if (getenv("AFL_FRIDA_TRACEABLE") != NULL) { traceable = TRUE; }
 
 }
 
 void entry_init(void) {
 
   OKF("entry_point: 0x%016" G_GINT64_MODIFIER "X", entry_point);
+  OKF("dumpable: [%c]", traceable ? 'X' : ' ');
 
   if (dlopen(NULL, RTLD_NOW) == NULL) { FATAL("Failed to dlopen: %d", errno); }