Misc - MultiDigilingual
Hard
Last updated
Hard
Last updated
It's a known secret that each faction speaks different languages, however few can speak all of them. KORP has long wanted to send a spy in the factions to keep an eye on them. Through their extensive network, they have found different talented factionless to test. The first to show their multidigilingual skills will get a place in them, and be their secret agent amongst the factions. Can you show them your worth?
What we need to do is basically write a 6-language polyglot that passes all the 6 compiler/interpreters.
A quick google search brings us to this 5-language polyglot on GitHub.
Unfortunately this polyglot only prints a string and doesn't read any file but it is still a good starting point.
I quickly implemented file reads for Perl, Ruby and Python. It was quite straightforward because they're all individually treated as comments by other languages.
Remember how the initial polyglot didn't come with PHP? I now have to add a PHP "file read and print" into this polyglot.
My first attempt is to put the PHP one liner at the top but this turns out to cause the C compiler to hang. But I eventually figured that I just have to place the code on the next line so that it is enclosed by the C multi-lined comment /*
and */
.
Next up C.
My first attempt was the above but the double quotes surrounding flag.txt
and r
causes the Ruby check to fail.
To bypass double quotes, I'll have to initialise the string character by character as above.
Unfortunately, the =
sign causes the Perl check to fail. I almost gave up at this point but I remembered that I could do a direct casting.
If it works for C it should work for C++ right?? Turns out no.
After some research, I figured that I just need to cast it to const char
in C++. Here's the final polyglot:
Flag: HTB{7he_ComMOn_5yM8OL5_Of_l4n9U49E5_C4n_LE4d_7O_m4ny_PolY9lO7_WoNdeR5}