exec.c 578 B

1234567891011121314151617181920
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <errno.h>
  7. #include <sys/types.h>
  8. #include <sys/wait.h>
  9. #include <unistd.h>
  10. int main (int argc, const char ** argv, const char ** envp)
  11. {
  12. char fds[2] = { dup(1), 0 };
  13. int outfd = dup(1);
  14. char * new_argv[] = { "./exec_victim", fds, NULL };
  15. setenv("IN_EXECVE", "1", 1);
  16. execv(new_argv[0], new_argv);
  17. return 0;
  18. }