• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
chmod -x chmod
 

chmod -x chmod

on

  • 157,551 views

Video at http://www.youtube.com/watch?v=DTWZqh64RcQ. ...

Video at http://www.youtube.com/watch?v=DTWZqh64RcQ.

You're in a Data Center, with absolutely no contact with the outside world, with a machine that you must not restart, and someone performed a `chmod -x chmod`.

This is a problem we used in interviews during 2009, and this presentation is a list of some of the possible solutions that my co-workers at SAPO have suggested.

Statistics

Views

Total Views
157,551
Views on SlideShare
149,706
Embed Views
7,845

Actions

Likes
70
Downloads
414
Comments
15

79 Embeds 7,845

http://www.ende-der-vernunft.org 1547
http://blog.matthew.org.pl 923
http://blog.kwasd.ru 846
http://www.redditmedia.com 817
http://www.shortcut.ru 637
http://krypted.com 504
http://shriphani.com 437
http://www.macdac.ru 392
http://www.joanabotto.com 325
http://elkosmas.gr 238
http://www.musiques-incongrues.net 227
https://twitter.com 153
http://www.blog.manhag.org 126
http://www.etanonline.fr 117
http://www.younic.de 85
http://www.plurk.com 72
http://pcampitiello.blogspot.it 57
http://paper.li 54
http://pcampitiello.blogspot.com 44
http://www.robintel.ro 25
http://interactivestemlearningprogramsk-12.blogspot.com 22
https://gitter.im 20
http://www.mefeedia.com 18
http://static.slidesharecdn.com 12
http://iam-chen.com 12
http://a0.twimg.com 10
http://twitter.com 9
http://pcampitiello.blogspot.com.br 9
http://webcache.googleusercontent.com 7
http://manhag.org 6
https://www.plurk.com 6
http://cetys.blackboard.com 6
https://elkosmas.gr 6
http://tumblr.ramimassoud.com 4
http://j-reference.blogspot.com 4
http://www.linkedin.com 4
http://beta.shortcut.ru 3
http://translate.googleusercontent.com 3
http://us-w1.rockmelt.com 3
http://pcampitiello.blogspot.co.uk 3
http://feeds2.feedburner.com 3
http://feeds.feedburner.com 3
http://www.netvibes.com 2
http://interactivestemlearningprogramsk-12.blogspot.co.uk 2
http://pcampitiello.blogspot.ch 2
http://www.manhag.org 2
http://pcampitiello.blogspot.fr 2
http://xss.yandex.net 2
http://unixfreunde.de 2
http://classztoop.blogspot.com 2
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

110 of 15 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • interest
    Are you sure you want to
    Your message goes here
    Processing…
  • http://ubuntuforums.org/showthread.php?p=11893791#post11893791
    Are you sure you want to
    Your message goes here
    Processing…
  • mmm... chmod from c system call will not work?
    Are you sure you want to
    Your message goes here
    Processing…
  • mark
    Are you sure you want to
    Your message goes here
    Processing…
  • exec chmod +x chmod
    Are you sure you want to
    Your message goes here
    Processing…

110 of 15 previous next

Post Comment
Edit your comment

    chmod -x chmod chmod -x chmod Presentation Transcript

    • chmod -x chmod José Castro <cog@cpan.org> August 2010
    • During 2009 we posed this problem to several of our candidates
    • You’re in a Data Center
    • With absolutely no contact with the outside world
    • There’s a machine you must not reboot
    • And someone had the brilliant idea of performing a `chmod -x chmod`
    • Solve the problem
    • The following is a list of possible solutions proposed by my co-workers
    • If the package is in cache, reinstall it
    • On Debian: sudo apt-get install --reinstall coreutils
    • Use a language that implements chmod
    • Perl perl -e ‘chmod 0755, “chmod”’
    • Python python -c "import os;os.chmod('/bin/chmod', 0777)"
    • d un teste Node.js require("fs").chmodSync("/bin/chmod", 0755);
    • Use existing executables or create your own
    • $ cat - > chmod.c
    • $ cat - > chmod.c int main () { } ^D
    • $ cat - > chmod.c int main () { } ^D $ cc chmod.c
    • $ cat - > chmod.c int main () { } ^D $ cc chmod.c $ cat /bin/chmod > a.out
    • $ cp cat new_chmod $ cat chmod > new_chmod
    • $ cat - > restore_chmod.c
    • $ cat - > restore_chmod.c #include <sys/types.h> #include <sys/stat.h> int main () { chmod( "/bin/chmod", 0000777 ); } ^D
    • $ cat - > restore_chmod.c #include <sys/types.h> #include <sys/stat.h> int main () { chmod( "/bin/chmod", 0000777 ); } ^D $ cc restore_chmod.c
    • $ cat - > restore_chmod.c #include <sys/types.h> #include <sys/stat.h> int main () { chmod( "/bin/chmod", 0000777 ); } ^D $ cc restore_chmod.c $ ./a.out
    • launch BusyBox (it has a chmod inside)
    • GNU tar
    • $ tar --mode 0777 -cf chmod.tar /bin/chmod $ tar xvf chmod.tar
    • tar --mode 555 -cvf - chmod | tar xvf -
    • d un teste $ tar -cvf chmod.tar chmod edit the archive and alter the permissions
    • “You said I couldn’t go to the internet...
    • “You said I couldn’t go to the internet... but you said nothing about the other machines on the data center...”
    • Open a socket to another machine and do a: $ tar --preserve-permissions -cf chmod.tar chmod
    • Open a socket to another machine and do a: $ tar --preserve-permissions -cf chmod.tar chmod Get this tar to your machine and: $ tar xvf chmod.tar
    • cpio
    • cpio lets you copy files to and from archives
    • bytes 19 to 24 are the file mode (http://4bxf.sl.pt)
    • echo chmod | cpio -o | perl -pe 's/^(.{21}).../${1}755/' | cpio -i -u
    • Hardcore
    • alias chmod='/lib/ld-2.11.1.so ./chmod'
    • d un teste • attrib or ls -@ • force the inode into cache • check kcore for the VFS structures • use sed to alter the execution bit without the kernel realizing it • run chmod +x chmod
    • Text editors sometimes need to overwrite a file
    • Thus, some of them have something resembling chmod
    • Emacs
    • Ctrl+x b > *scratch* (set-file-modes "/bin/chmod" (string-to-number "0755" 8)) Ctrl+j
    • There seem to be countless solutions
    • But one of the best answers I’ve seen...
    • Was from a guy who replied to my “Solve the problem” with...
    • “What problem? Isn’t the machine still running?”
    • The End (for now)