modify_reg changes the default values of a particular register. ---- 8< ---- 8< ---- // example.c #include #include #include void exit_if_password_incorrect(const char* const password) { if (strcmp("seasame", password) != 0) { puts("Password incorrect"); exit(1); } } void success() { puts("Success!"); } int main(int argc, char* argv[]) { if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } exit_if_password_incorrect(argv[1]); success(); return 0; } $ gcc -Wall -Werror -o example example.c $ ./example foo Password incorrect $ ../modify_reg ./example eip 00001fb0 < eip: 00001e74 > eip: 00001fb0 $ ./example foo Success! Segmentation fault ---- 8< ---- 8< ---- This example crashes with a seg fault in __dyld_misaligned_stack_error after the program exits because modifying the instruction pointer skips some initialization. This will be more useful either by either modifying more registers to setup a sane environment, or do some other code motification.