Actually it's not so amazing. The program does not render the characters based on code, it actually loads its own source code from a cpp file and renders it as an image. You probably could run this program but give it a different cpp file and it would generate another image...
Am I right that the image doesn't actually contain the code, as in encode it, but rather has a blurred, stylized version of the code? It's not some kind of quine or whatever the of the code to create the image counts as. (Edit: I'm on mobile so just saw a thumbnail, I realized now that it does have all the code in it)
The really cool thing I noticed about this website was the different sizes of the image. The aim is to make a 2^24 pixel image that uses each color on the rgb color space once. That's 48 MB notionally, and some of the images are 20 or 30 MB, but then others are < 1 MB that have a repeating pattern.
Obviously it's possible to encode the image that contains its code in a few kb corresponding to the 100ish lines of code in the image, but the actual size is 42 MB, unsurprisingly the png encoding or whatever it is didn't find the shortcut
"Am I right that the image doesn't actually contain the code, as in encode it, but rather has a blurred, stylized version of the code?"
AIUI that's correct. The code is in the picture, not in the binary representation of the image. The code generates a particular encoding of the picture, but the code is visible in the image regardless of that (and even if you have a printed version of the image).
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.
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).
Mayne a quine in postscript gnuplot or some other graphical language would be equivalent. I found the link below for postscript but I'm on my phone so I can't readily test it
It would be exactly a quine, you'd just ram the generated source code through the image generation algorithm rather than printing to stdout. So yes, the existence of quines means that it must be possible. It'd probably be about twice as long, though, based on the typical shape of C/C++ quines.
How do you go about finding or searching for functions/code that generates a representation when you graph/run it? Was this done by hand or was there some search involved?