Hacker News new | ask | show | jobs
by argvargc 1604 days ago
So, the quine-stion we're all asking now - is there a valid image, that also happens to be a valid executable, that when run, outputs the image?

And/or what about an interpret or compile step in there?

3 comments

I created something very similar. It is a PNG and bootable x86 MBR polyglot. When executed, it rewrites the PNG's image data, to convey the program's output.

https://twitter.com/OverTheWireCTF/status/146574242275182182...

Someone who solved the challenge did a writeup:

https://joe.lothan.net/ctfs/2021-advent-otw/00-warmup/

Wow, such an impressive CTF! Did the author solve it in the exact way you intended? I'm curious what the real answer to problem 8 was, now!
To be honest there is no singular intended solution, I deliberately designed it so that there were multiple approaches that could make sense (especially in combination). Intended solutions include but are not limited to:

- Guessing by hand.

- Bruteforce by programatically feeding input into QEMU (as in that writeup).

- Bruteforce by only emulating the "important" code, via something like Unicorn.

- Bruteforce by reimplementing the algorithm in another language (There are some tricks you can use to make it go fast - maybe I should write those up...)

- Reducing the search space by grepping for likely keywords.

- Bruteforce of remaining bytes of the RC4 key (also as in that writeup).

If a Game Boy ROM counts as an executable, it's been done: https://github.com/pinobatch/little-things-gb/tree/master/gb...
> is there a valid image, that also happens to be a valid executable, that when run, outputs the image?

Yes, this exists:

https://codegolf.stackexchange.com/a/23255