![伪装成 sudoers 文件中的另一个用户?](https://linux22.com/image/30115/%E4%BC%AA%E8%A3%85%E6%88%90%20sudoers%20%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84%E5%8F%A6%E4%B8%80%E4%B8%AA%E7%94%A8%E6%88%B7%EF%BC%9F.png)
我的/etc/sudoers
文件有以下条目:-
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
agupta ALL= /sbin/,/usr/sbin/,/bin/,/bin/cat /etc/sudoers
ADMINS ALL= !/usr/bin/su, !SHELLS
alice ALL =(%Children) /sbin/, /usr/sbin/, /bin/
爱丽丝是儿童组的成员;请在下面找到爱丽丝的详细信息:-
[alice@localhost ~]$ id alice
uid=1005(alice) gid=1004(Children) groups=1004(Children)
当我尝试运行此命令时,/bin/cat /etc/sudoers
出现以下错误:-
[alice@localhost ~]$ sudo cat /etc/sudoers
Sorry, user alice is not allowed to execute '/bin/cat /etc/sudoers' as root on localhost.localdomain.
在 /var/log/secure 中,我可以看到填充了以下条目:-
Mar 21 06:40:40 localhost sudo: alice : command not allowed ; TTY=pts/0 ; PWD=/home/alice ; USER=root ; COMMAND=/bin/cat /etc/sudoers
对此有何建议?
编辑1
通过从文件中删除模拟来修改文件,即
alice ALL = /sbin/, /usr/sbin/, /bin/
我能够运行该命令sudo cat /etc/sudoers
。我想尝试伪装:但我无法让它在我的系统上运行
编辑2
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
agupta,myself ALL=(wheel) ALL
jane ALL=(%parents) ALL
我运行的命令:-
[jane@localhost ~]$ sudo -u paul cat /etc/sudoers
[sudo] password for jane:
cat: /etc/sudoers: Permission denied
登录 /etc/log/secure:-
Mar 15 15:26:24 localhost sudo: jane : TTY=pts/2 ; PWD=/home/jane ; USER=paul ; COMMAND=/bin/cat /etc/sudoers
团体成员家长:-
[root@localhost ~]# id jane
uid=505(jane) gid=504(parents) groups=504(parents)
[root@localhost ~]# id paul
uid=504(paul) gid=504(parents) groups=504(parents)
难道,我还在犯愚蠢的错误吗?
答案1
要使用 sudo 的模拟功能(默认为 root 用户),您需要使用 -u 选项,如下所示:
sudo -u agupta ls ~agupta
此外,如果 agupta 位于 Children 组中,则需要在 sudo 下运行 sudo:
sudo -u agupta sudo cat /etc/sudoers