11
\$\begingroup\$

This is the robbers' thread. The cops' thread is here.

Your challenge is to take an uncracked submission from the cops' thread and find, for what input or inputs, the program will print Hello, World! and a newline. Capitalization, spacing, and punctuation must be exact.

Please comment on the cop's submission when you've cracked their code.

\$\endgroup\$

35 Answers 35

1
2
1
\$\begingroup\$

TeX, by A Gold Man

Original source:

\read16to\x\message{Hello, World!}\bye

This already prints Hello, World!, but the newline is missing. The input is just placed in \x which is never used. In order to be able to modify the output, I guess we need to do some preparations (like, "lay a trap") before calling this code, so \x is actually expanded. It can be done when invoked like this (assuming the original source is in x.tex in the current directory):

tex '\def\vfill{\x}\input./x'

This first redefines \vfill (which is part of the expansion of \bye) to expand to our \x, so now we can provide some input printing the missing newline:

\newlinechar=`@\message{@}

This sets the character used for newlines in \message to @ and immediately uses it.


This whole thing modifies the environment the original program will run in, so if there are any objections to this method, I'll retract it.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Not what I had in mind, but very clever. The intended solution is way more evil. I'll consider myself cracked. \$\endgroup\$ – A Gold Man Aug 8 '17 at 20:23
  • \$\begingroup\$ Just for the record, I thought that you were going to \let \message to \relax, which would then typeset the hello world with a newline (implicitly). But this is way better. \$\endgroup\$ – A Gold Man Aug 9 '17 at 7:10
  • \$\begingroup\$ @AGoldMan There's an ongoing meta discussion about what form of input is allowed, I posted an answer for discussion there about your cop. If you're sure your intended solution works with any TeX implementation, I'd say feel free to consider my crack invalid and you're probably on a straight line to winning the cop part of this challenge (and I might score second as noone attempted to crack my C64 code so far, hehe) \$\endgroup\$ – Felix Palmen Aug 9 '17 at 7:17
1
\$\begingroup\$

Brainfuck by 2EZ 4RTZ

Correct input: Gdkkn+\x1fVnqkc \x09\xff, where \xHH indicates non-ASCII-printable hex character.

Explanation:

You just take the character codes of "Hello, World!\n" and subract one from each value. The last character \xff (255) causes the program to exit after you add one (since the 255+1 overflows to 0 and the loop exits).

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Darn, I had this crack but couldn't get it working on TIO ;-; +1 \$\endgroup\$ – MD XF Aug 8 '17 at 22:01
  • \$\begingroup\$ Yeah, TIO doesn't work, that's what had me tripped up all this time. \$\endgroup\$ – totallyhuman Aug 8 '17 at 22:01
  • \$\begingroup\$ Is this valid as the interpreter linked is specifically TIO? (on which 0xFF doesn't work from what I've tried) \$\endgroup\$ – dzaima Aug 8 '17 at 22:02
  • \$\begingroup\$ I wrote a BF interpreter for fun once, so I passed input from a C program where I could specify hex inputs : ) \$\endgroup\$ – rexroni Aug 8 '17 at 22:03
  • \$\begingroup\$ @dzaima lol TIO doesn't work. I just linked it since lazy. \$\endgroup\$ – Christopher Aug 8 '17 at 22:18
1
\$\begingroup\$

><> by Not a tree

This was an EPIC puzzle! I loved it!

Example solution:

TIHANICWHITEOCPSEARK

Wish I could upvote Not a tree's post three more times.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Does anybody know if it is possible to add a hidden answer that contains a block of code/preformatted text? \$\endgroup\$ – rexroni Aug 9 '17 at 16:37
  • \$\begingroup\$ Well done! Your solution isn't identical to mine, but it's functionally the same. I'm glad you enjoyed the puzzle! \$\endgroup\$ – Not a tree Aug 10 '17 at 0:12
  • \$\begingroup\$ And you can make a hidden codeblock (with difficulty) by surrounding it with <pre><code> ... </code></pre> instead of the usual four-spaces method, and using &#10; instead of newlines. \$\endgroup\$ – Not a tree Aug 10 '17 at 0:16
0
\$\begingroup\$

Perl 5, by Chris

Original code:

eval<>;END{print$x='x'}

Input:

our $x;package X;require Tie::Scalar;@ISA=qw(Tie::Scalar);sub TIESCALAR{my$v;return bless\$v,'X';}sub STORE{}sub FETCH{return "Hello, World!\n"}tie $x,'X';

I'm not sure this is the intended solution. It works by changing the behavior of $x using a tie. The tie here is very simple, ignoring any STORE access and returning our desired output for any FETCH.

Try it online!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Pretty much my intended solution, yes. \$\endgroup\$ – Chris Aug 8 '17 at 8:20
  • 1
    \$\begingroup\$ I thought this was not cracked (forgot to refresh the cop thread), so I found this (simple) solution : print"Hello, World!\n";close(STDOUT);. \$\endgroup\$ – LP154 Aug 8 '17 at 10:09
  • \$\begingroup\$ That's a nice trick! \$\endgroup\$ – Felix Palmen Aug 8 '17 at 10:19
0
\$\begingroup\$

JavaScript (ES6), Voile

Input:

!(v.call=()=>true)||"()=>`Hello, World!\n`"

Cop code:

const e=eval,p=''.split,c=''.slice,v=[].every,f=s=>(t=c.call(s),typeof s=='string'&&t.length<81&&v.call(p.call(t,`\n`),l=>l.length<3)&&e(t)(t))

Try it online

This overwrites the v.call() method to always return true, but that part of the input is falsified and discarded for the string part which passes the string type check and length check, and eval's to the desired output Hello, World!\n.

If Birjolaxew's crack is not accepted, maybe this one will.

| improve this answer | |
\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.