Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <string.h>
- int
- main(int argc, char *argv[])
- {
- int fd[2];
- char *s = "ls -1 \"/usr/bin\" | while IFS= read -r fp\ndo\ncat <<- EOF\n\t$fp\nEOF\ndone;";
- //char *s = "ls -1";
- pipe(fd);
- switch(fork()) {
- case 0:
- close(fd[1]);
- dup2(fd[0], 0);
- execl("/bin/sh", "sh", NULL);
- close(fd[0]);
- break;
- default:
- close(fd[0]);
- write(fd[1], s, strlen(s) + 1);
- close(fd[1]);
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement