SHARE
TWEET

Untitled

a guest Apr 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <unistd.h>
  2. #include <string.h>
  3.  
  4. int
  5. main(int argc, char *argv[])
  6. {
  7.     int fd[2];
  8.  
  9.     char *s = "ls -1 \"/usr/bin\" | while IFS= read -r fp\ndo\ncat <<- EOF\n\t$fp\nEOF\ndone;";
  10.     //char *s = "ls -1";
  11.  
  12.  
  13.     pipe(fd);
  14.  
  15.     switch(fork()) {
  16.         case 0:
  17.             close(fd[1]);
  18.             dup2(fd[0], 0);
  19.             execl("/bin/sh", "sh", NULL);
  20.             close(fd[0]);
  21.         break;
  22.         default:
  23.             close(fd[0]);
  24.             write(fd[1], s, strlen(s) + 1);
  25.             close(fd[1]);
  26.         break;
  27.     }
  28.  
  29.     return 0;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top