Insert Dylib -
vmmap <PID> | grep -i dylib Unexpected dylibs (non-system, not in original binary) are suspicious. #include <mach-o/dyld.h> for (uint32_t i=0; i < _dyld_image_count(); i++) const char *name = _dyld_get_image_name(i); // Check against whitelist
// mymalloc.c #include <stdio.h> void *malloc(size_t size) printf("malloc(%zu) intercepted\n", size); return NULL; // or call real malloc insert dylib
ps eww <PID> | tr ' ' '\n' | grep DYLD List loaded dylibs: vmmap <PID> | grep -i dylib Unexpected dylibs
void anti_injection_check() const char *env = getenv("DYLD_INSERT_LIBRARIES"); if (env && strlen(env) > 0) fprintf(stderr, "DYLD_INSERT_LIBRARIES detected: %s\n", env); exit(1); for (uint32_t i=0
DYLD_INSERT_LIBRARIES=./mymalloc.dylib ./testprog Attach to a running process and call dlopen() remotely. Requires thread creation and function call in target.
gcc -dynamiclib -o mymalloc.dylib mymalloc.c Inject:

