frida mode display command line on mac

This commit is contained in:
David CARLIER 2021-10-23 20:09:36 +01:00
parent 06b23c7dcb
commit f68b9f5110

View File

@ -6,6 +6,7 @@
#ifdef __APPLE__
#include <mach/mach.h>
#include <mach-o/dyld_images.h>
#include <crt_externs.h>
#else
#include <sys/wait.h>
#include <sys/personality.h>
@ -90,6 +91,7 @@ static void embedded_init(void) {
static void afl_print_cmdline(void) {
#if defined(__linux__)
char * buffer = g_malloc0(PROC_MAX);
gchar *fname = g_strdup_printf("/proc/%d/cmdline", getppid());
int fd = open(fname, O_RDONLY);
@ -123,6 +125,17 @@ static void afl_print_cmdline(void) {
close(fd);
g_free(fname);
g_free(buffer);
#elif defined(__APPLE__)
int idx;
char **argv = *_NSGetArgv();
int nargv = *_NSGetArgc();
for (idx = 0; idx < nargv; idx ++) {
OKF("AFL - COMMANDLINE: argv[%d] = %s", idx, argv[idx]);
}
#endif
}