Polyglot is a way of programming such that the same source code can run on more than one compilers simultaneously. Sometimes people make it more difficult by requiring the code to behave exactly the same on each programming language.
HITCON CTF 2014 last weekend has a similar challenge where we needed to write a Python2/Python3/Ruby/C/Haskell polyglot code that does the same thing as bash command
I couldn’t solve the problem during the competition and later on was quite amazed of how simple the solutions were. Below is the solution from the player t0mcr00se:
Another one from Ricky Zhou :
It’s fairly easy to modify t0mcr00se’s code to a “Hello World” polyglot just for fun: