17 lines · cpp
1#include <unistd.h>2 3int main(int argc, const char *argv[], const char *envp[]) {4 if (argc == 2) {5 // If we have two arguments the first is the path to this executable,6 // the second is the path to the linux dynamic loader that we should7 // exec with. We want to re-run this problem under the dynamic loader8 // and make sure we can hit the breakpoint in the "else".9 const char *interpreter = argv[1];10 const char *this_program = argv[0];11 const char *exec_argv[3] = {interpreter, this_program, nullptr};12 execve(interpreter, (char *const *)exec_argv, (char *const *)envp);13 }14 // Break here15 return 0;16}17