这里是代码:
(根:)
# mkdir /test # cp /bin/bash /test/sbash # chmod a+s /test/sbash
(USER1 🙂
$ cd /test $ ./sbash $ mkdir trycreate mkdir: cannot create directory `trycreate': Permission denied
而setuid位设置的bash脚本也不起作用。
顺便说一句,我的setuid Perl脚本的作品:
test.pl 🙁 setuid位设置,owner = root)
#!/usr/bin/perl mkdir('/test/tryperlcreate') or die 'failed';
用user1执行test.pl会创buildroot所拥有的目录。
用-p尝试执行./sbash。
sh:~# cp /bin/bash /bin/ape sh:~# chmod +s /bin/ape sh:~**$** /bin/ape -p ape-3.2#
你不能让脚本SUID。 幸好。
您可能对这里的SUID包装程序感兴趣,但是: http : //isptools.sourceforge.net/suid-wrap.html
我还要补充一下,请确保你确实需要这样做,然后再做。 SUID二进制文件可能会成为系统中的一个巨大漏洞。
我可以重新发布已经做了什么,但这是一个伟大的阅读。
基本上setuid shell脚本默认不工作
这是devise,在Ubuntu以及许多其他现代* nix系统。 虽然setuid总是潜在的安全漏洞,但在处理shell脚本时更是如此。
(经典的问题是,通过修改IFS环境variables让某人被愚蠢的东西蒙混过关。
正如其他人所说,这是devise。
尝试使用sudo而不是setuid脚本。