Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/syscall.h>
  4. #include <string.h>
  5. #include <stdint.h>
  6. #include <pthread.h>
  7.  
  8. #ifndef SYS_mmap
  9. #define SYS_mmap 9
  10. #endif
  11. #ifndef SYS_bpf
  12. #define SYS_bpf 321
  13. #endif
  14.  
  15. long r[6];
  16.  
  17. int main(int argc, char **argv)
  18. {
  19. printf("--beginning of program\n");
  20.  
  21. while(1) {
  22.  
  23. pid_t pid = fork();
  24.  
  25. if (pid == 0)
  26. {
  27. // child process
  28. memset(r, -1, sizeof(r));
  29. r[0] = syscall(SYS_mmap, 0x20000000ul, 0xf000ul, 0x3ul, 0x32ul,
  30. 0xfffffffffffffffful, 0x0ul);
  31. *(uint32_t*)0x20006eea = (uint32_t)0x6;
  32. *(uint32_t*)0x20006eee = (uint32_t)0x4;
  33. *(uint32_t*)0x20006ef2 = (uint32_t)0x54d1;
  34. *(uint32_t*)0x20006ef6 = (uint32_t)0xc93;
  35. r[5] = syscall(SYS_bpf, 0x0ul, 0x20006eeaul, 0x10ul, 0, 0, 0);
  36. return 0;
  37. }
  38. else if (pid > 0)
  39. {
  40. // parent process
  41. memset(r, -1, sizeof(r));
  42. r[0] = syscall(SYS_mmap, 0x20000000ul, 0xf000ul, 0x3ul, 0x32ul,
  43. 0xfffffffffffffffful, 0x0ul);
  44. *(uint32_t*)0x20006eea = (uint32_t)0x6;
  45. *(uint32_t*)0x20006eee = (uint32_t)0x4;
  46. *(uint32_t*)0x20006ef2 = (uint32_t)0x54d1;
  47. *(uint32_t*)0x20006ef6 = (uint32_t)0xc93;
  48. r[5] = syscall(SYS_bpf, 0x0ul, 0x20006eeaul, 0x10ul, 0, 0, 0);
  49. int returnStatus;
  50. waitpid(pid, &returnStatus, 0);
  51. printf("collected child\n");
  52.  
  53. }
  54. else
  55. {
  56. // fork failed
  57. printf("fork() failed!\n");
  58. return 1;
  59. }
  60. }
  61.  
  62. printf("--end of program--\n");
  63.  
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement