Skip to content

Instantly share code, notes, and snippets.

@depp
Created June 25, 2021 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save depp/87c7b2fa0c1b53443b4a1132d6e49dc3 to your computer and use it in GitHub Desktop.
Save depp/87c7b2fa0c1b53443b4a1132d6e49dc3 to your computer and use it in GitHub Desktop.
Injection Demo

Injection test

Run:

$ make
$ DYLD_INSERT_LIBRARIES=inject.dylib ./main

The output is:

injection init
main
#include <stdio.h>
__attribute__((constructor)) static void injection_init(void) {
fputs("injection init\n", stdout);
}
#include <stdio.h>
int main(int argc, char **argv) {
fputs("main\n", stdout);
}
all: inject.dylib main
inject.dylib: inject.c
cc -dynamiclib $^ -o $@
main: main.c
cc $^ -o $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment