chmod -x chmod
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

chmod -x chmod

on

  • 162,621 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
162,621
Views on SlideShare
154,178
Embed Views
8,443

Actions

Likes
79
Downloads
441
Comments
15

81 Embeds 8,443

http://www.ende-der-vernunft.org 1556
http://blog.matthew.org.pl 930
http://blog.kwasd.ru 848
http://www.redditmedia.com 817
http://www.shortcut.ru 638
http://krypted.com 505
http://shriphani.com 437
http://www.macdac.ru 392
http://www.scoop.it 361
http://www.joanabotto.com 327
https://twitter.com 326
http://elkosmas.gr 238
http://www.musiques-incongrues.net 229
http://www.blog.manhag.org 126
http://www.etanonline.fr 117
http://www.younic.de 86
http://www.plurk.com 72
http://pcampitiello.blogspot.it 58
http://paper.li 54
https://gitter.im 52
http://pcampitiello.blogspot.com 44
http://www.robintel.ro 25
http://interactivestemlearningprogramsk-12.blogspot.com 22
http://www.mefeedia.com 18
http://iam-chen.com 12
http://static.slidesharecdn.com 12
http://a0.twimg.com 10
http://twitter.com 9
http://pcampitiello.blogspot.com.br 9
http://webcache.googleusercontent.com 8
https://elkosmas.gr 7
https://www.plurk.com 6
http://manhag.org 6
http://cetys.blackboard.com 6
http://pcampitiello.blogspot.co.uk 5
http://j-reference.blogspot.com 4
http://translate.googleusercontent.com 4
http://www.linkedin.com 4
http://tumblr.ramimassoud.com 4
http://feeds.feedburner.com 3
http://feeds2.feedburner.com 3
http://us-w1.rockmelt.com 3
http://beta.shortcut.ru 3
http://interactivestemlearningprogramsk-12.blogspot.co.uk 2
http://pcampitiello.blogspot.fr 2
http://pcampitiello.blogspot.ch 2
http://www.manhag.org 2
http://unixfreunde.de 2
http://xss.yandex.net 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

15 of 15 Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

chmod -x chmod Presentation Transcript

  • 1. chmod -x chmod José Castro <cog@cpan.org> August 2010
  • 2. During 2009 we posed this problem to several of our candidates
  • 3. You’re in a Data Center
  • 4. With absolutely no contact with the outside world
  • 5. There’s a machine you must not reboot
  • 6. And someone had the brilliant idea of performing a `chmod -x chmod`
  • 7. Solve the problem
  • 8. The following is a list of possible solutions proposed by my co-workers
  • 9. If the package is in cache, reinstall it
  • 10. On Debian: sudo apt-get install --reinstall coreutils
  • 11. Use a language that implements chmod
  • 12. Perl perl -e ‘chmod 0755, “chmod”’
  • 13. Python python -c "import os;os.chmod('/bin/chmod', 0777)"
  • 14. d un teste Node.js require("fs").chmodSync("/bin/chmod", 0755);
  • 15. Use existing executables or create your own
  • 16. $ cat - > chmod.c
  • 17. $ cat - > chmod.c int main () { } ^D
  • 18. $ cat - > chmod.c int main () { } ^D $ cc chmod.c
  • 19. $ cat - > chmod.c int main () { } ^D $ cc chmod.c $ cat /bin/chmod > a.out
  • 20. $ cp cat new_chmod $ cat chmod > new_chmod
  • 21. $ cat - > restore_chmod.c
  • 22. $ cat - > restore_chmod.c #include <sys/types.h> #include <sys/stat.h> int main () { chmod( "/bin/chmod", 0000777 ); } ^D
  • 23. $ cat - > restore_chmod.c #include <sys/types.h> #include <sys/stat.h> int main () { chmod( "/bin/chmod", 0000777 ); } ^D $ cc restore_chmod.c
  • 24. $ 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
  • 25. launch BusyBox (it has a chmod inside)
  • 26. GNU tar
  • 27. $ tar --mode 0777 -cf chmod.tar /bin/chmod $ tar xvf chmod.tar
  • 28. tar --mode 555 -cvf - chmod | tar xvf -
  • 29. d un teste $ tar -cvf chmod.tar chmod edit the archive and alter the permissions
  • 30. “You said I couldn’t go to the internet...
  • 31. “You said I couldn’t go to the internet... but you said nothing about the other machines on the data center...”
  • 32. Open a socket to another machine and do a: $ tar --preserve-permissions -cf chmod.tar chmod
  • 33. 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
  • 34. cpio
  • 35. cpio lets you copy files to and from archives
  • 36. bytes 19 to 24 are the file mode (http://4bxf.sl.pt)
  • 37. echo chmod | cpio -o | perl -pe 's/^(.{21}).../${1}755/' | cpio -i -u
  • 38. Hardcore
  • 39. alias chmod='/lib/ld-2.11.1.so ./chmod'
  • 40. 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
  • 41. Text editors sometimes need to overwrite a file
  • 42. Thus, some of them have something resembling chmod
  • 43. Emacs
  • 44. Ctrl+x b > *scratch* (set-file-modes "/bin/chmod" (string-to-number "0755" 8)) Ctrl+j
  • 45. There seem to be countless solutions
  • 46. But one of the best answers I’ve seen...
  • 47. Was from a guy who replied to my “Solve the problem” with...
  • 48. “What problem? Isn’t the machine still running?”
  • 49. The End (for now)