Guest User

Untitled

a guest
Jul 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <sys/ptrace.h>
  6.  
  7. int
  8. main(int argc, char *argv[]) {
  9.  
  10. pid_t pid;
  11.  
  12. pid = (int)strtol(argv[1], 0, 10);
  13.  
  14. printf("Attaching to PID %d\n", pid);
  15. if (ptrace(PT_ATTACH, pid, 0,0) < 0) {
  16. perror("ptrace");
  17. exit(EXIT_FAILURE);
  18. }
  19.  
  20. printf("Detaching from PID %d\n", pid);
  21. if (ptrace(PT_DETACH, pid, 0,0) < 0) {
  22. perror("ptrace");
  23. exit(EXIT_FAILURE);
  24. }
  25.  
  26.  
  27. return 0;
  28. }
Add Comment
Please, Sign In to add comment