DISARM THE B.O.M.B.!

bash, vim and dc (343)

I'm sitting at a bash prompt which has been configured by the Evil Genius, and of course he has VISUAL=vim in the default environment. Using the default bash binding for edit-and-execute-command (C-x C-e) bash invokes $VISUAL and will execute its buffer contents on exit (ZZ). I type in the following sequence (Note: kbd-mode are commands issued in normal mode and control sequences):

  1. C-xC-e

  2. acat<<<45C-c4C-aaa

    Now the vim buffer contains cat<<<49a. Continuing ...

  3. 45C-c3C-aaa

  4. 54C-c41C-aaa

  5. 55C-c13C-aaa

    Now the vim buffer contains cat<<<49a48a95a68a. Continuing ...

  6. 51C-c31C-aaa

  7. 55C-c24C-aaa

  8. 44C-c43C-aaa

  9. 42C-c41C-aaa

  10. 42C-c41C-aaa

  11. 54C-c11C-aaa

  12. 55C-c25C-aaa>s

    Now the vim buffer contains cat<<<49a48a95a68a82a79a87a83a83a65a80a>s

    Get out of insert mode, save and exit

  13. C-cZZ

    The s file now contains a dc script that generates the desired string on the stack, now we need to add print commands.

  14. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

    Repeat the above command 9 times.

  15. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  16. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  17. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  18. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  19. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  20. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  21. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  22. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  23. C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

  24. C-xC-eacat<<< f >>s

    Execute the dc script:

  25. C-xC-eadc sC-cZZ

Output:

PASSWORD_01

Contents of the s file:

49a48a95a68a82a79a87a83a83a65a80a
P
P
P
P
P
P
P
P
P
P
f

Ruby, 57 + 10 (*) = 67

$*<<4*4*5<<214%135<<44%25*5<<1%1
$><<"%cASSW%cRD%c%d1"%$*

This answer uses * and % to build the ASCII values of the missing characters (and 0 as Fixnum) and pushes them into $* (ARGV). This array is then used in combination with a format string to generate the correct password, which is printed with $><< ($> is stdout).

Ruby, 62 + 10 (.) = 72, no linebreak

$>.<< "%cASSW%cRD%c%d1".% %w%%<<311%231<<214%135<<321%113<<1%1

Roughly the same principle as the above version, except that here the array is built from an empty array literal (%w%%). Some fiddling with . is needed to get the desired operator precedence.


CJam - 24 + 10 (() = 34

"Q"c("ASSW"1$("aRD"(((T1

No additional key - 39

211 131%c"ASSW"211 132%c"RD"321 113%cT1

Try it at http://cjam.aditsu.net/