4 ms·
The simplest way I could figure out was: cp sh chmod.new cp chmod chmod.new
by aes 16y ago
The simplest way I could figure out was:
cp sh chmod.new
cp chmod chmod.new
- iclelland 16y agoMy first thought was pretty similar: cp /bin/sh chmod.new cat /bin/chmod > chmod.new mv chmod.new /bin/chmod
- mrb 16y agoIMO the simplest way is: $ /lib/ld-linux-x86-64.so.2 /bin/chmod +x /bin/chmod ELF files run by manually launching the dynamic loader don't require the executable bit.
- CUViper 16y agoI agree that this is easiest, and I'm surprised that the article calls it "hardcore" (slides 38-39). But it does bring to mind a more devious challenge: Someone ran "chmod -x ld.so"...
- xtacy 16y agoWhat about: find / -type f -perm +x | xargs chmod -x EDIT: chmod has to be the last program to be chmodded, in the above list.. :-)
- tange 16y agoYour use of xargs can lead to nasty surprises because of the separator problem http://en.wikipedia.org/wiki/Xargs#The_separator_problem http://en.wikipedia.org/wiki/Xargs#The_separator_problem GNU Parallel http://www.gnu.org/software/parallel/ http://www.gnu.org/software/parallel/ does not have that problem. Watch the intro video for GNU Parallel: http://www.youtube.com/watch?v=OpaiGYxkSuQ http://www.youtube.com/watch?v=OpaiGYxkSuQ
- ralph 16y agoGNU Parallel isn't needed to avoid this, using find's -print0 and xargs's -0 would suffice. The advert is unwarranted.
- deleted 16y ago[deleted]
- pvg 16y agoThe parent seems simpler. More importantly, it works on just about any Unix.
- RexRollman 16y agoCouldn't you just set an appropriate umask and then make a copy of chmod?
- pvg 16y agoI don't think umask setting affects the executable bits of files, just directories. You can try by entering something like umask 0; touch foo; ls -l foo
- CUViper 16y agoIt does affect files, but umask only subtracts permission bits. So if the program creating the file doesn't try to set it executable, then umask will never change that.
- gaius 16y agoMy first thought was, just re-implement it in C, then I remembered than we do have a bunch of boxes without a compiler on.