Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <sys/mman.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int fildes;
- void* address;
- char lsofcmd[1024];
- int pid;
- fildes = open("/etc/passwd", O_RDONLY);
- address = mmap((caddr_t)0, (size_t)1024, PROT_READ, MAP_PRIVATE, fildes, (off_t)0);
- pid=(int)getpid();
- sprintf(lsofcmd, "lsof -p %d", pid);
- system(lsofcmd);
- close(fildes);
- system(lsofcmd);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement