sudo 是一种权限管理机制,管理员可以授权于一些普通用户去执行一些 root 执行的操作,而不需要知道 root 的密码。
首先通过信息收集,查看是否存在sudo配置不当的可能。如果存在,寻找低权限sudo用户的密码,进而提权。
实验环境还是一样的 我们紧接着做
我们首先要退出root用户
我们进入 web1用户
我们以sudo
来查看
cat /etc/shadow(只有root才能查看的文件)
我们来查看密码
查找bash 权限
sudo cat /etc/passwd | grep bash
切换用户
我们发现 没有密码 就可以使用cat 以root权限
原理神魔呢
/etc/sudoers
我们加入 sudo cat /etc/sudoers
首先设置 chmod +w cat /etc/sudoers 使用vi对其编辑 保存即
# User privilegespecification rootALL=(ALL:ALL)ALL
moonsec ALL=(root) NOPASSWD:/bin/cat
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL)ALL
# See sudoers(5) for more information on "#include" directives:
NOPASSWD 不需要密码 使用cat命令 并且具有特权权限。