exec.c 572 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 <stdlib.h>
  4. #include <stdio.h>
  5. #include <errno.h>
  6. #include <unistd.h>
  7. int main (int argc, const char ** argv, const char ** envp)
  8. {
  9. int newfd = dup(1), outfd = dup(1);
  10. char fd_argv[4];
  11. snprintf(fd_argv, 4, "%d", newfd);
  12. char * const new_argv[] = { "./exec_victim", fd_argv, NULL };
  13. setenv("IN_EXECVE", "1", 1);
  14. execv(new_argv[0], new_argv);
  15. return 0;
  16. }