exec_victim.c 579 B

12345678910111213141516171819202122
  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. int main(int argc, char ** argv, const char ** envp)
  6. {
  7. FILE * out = stdout;
  8. if (argc > 1) {
  9. out = fdopen(argv[1][0], "a");
  10. if (!out) {
  11. perror("fdopen");
  12. exit(1);
  13. }
  14. }
  15. fprintf(out, "Hello World (%s)!\n", argv[0]);
  16. fprintf(out, "envp[\'IN_EXECVE\'] = %s\n", getenv("IN_EXECVE"));
  17. return 0;
  18. }