EmojiWAT

Description

problem description

Solution

Not too often does a CTF challenge have its own promo. This was not the case of EmojiWat:

Twitter promo

The opening URL presents a text editor, with a run button, and some "code". The code can be executed, and it indeed prints "Hello World!". The strange part is that the "code" is mostly Emoji.

hello world

The interface presented a list of a few other examples of code.

At first, we thought the Emoji were just some aliases or macros and we tried to guess what was the underlying language. For example:

But it turned out to be weirder than that: some people actually created a real language called "Emojicode, an open-source, full-blown programming language consisting of emojis". Just when you thought Whitespace, Chef and Velato were the strangest programming languages...

From there, it should have been straight forward, looking for some Emojicode sample that implements a simple HTTP GET request to http://emojiwat-flag, as stated in the challenge description. So we get the sample from the official documentation for Package sockets, and just change the URL:

πŸ“¦ sockets 🏠

🏁 πŸ‡
  🍺 πŸ†•πŸ“ž πŸ”€emojiwat-flagπŸ”€ 80❗️ ➑️ socket
  πŸ’¬ socket πŸ“‡ πŸ”€GET / HTTP/1.1❌r❌nHost: emojiwat-flag❌r❌n❌r❌nπŸ”€β—οΈβ—οΈ

  🍺 πŸ‘‚ socket 140❗️ ➑️ data
  πŸ˜€ 🍺 πŸ”‘ data❗️❗️
πŸ‰

But it returns an error that explains in plain English:

Call can raise sπŸš§πŸ”Έβ†• but error is not handled.

Back to the Emoji documentation about errors, we learn that:

In case a method, initializer or closure may fail, it should be declared as error-prone.

Luckily, an easy solution is also described:

🍺 Not Handling Errors

As with optionals, you can use 🍺 to make a call to an error-prone function and disregard the possibility of an error arising. If an error, however, is raised during execution the program will panic.

So we can easily fix our code by adding 🍺 before the line using the socket (and fix the size to read):

  πŸ“¦ sockets 🏠

  🏁 πŸ‡
    🍺  πŸ†•πŸ“ž πŸ”€emojiwat-flagπŸ”€ 80❗️ ➑️ socket
    🍺 πŸ’¬ socket πŸ“‡ πŸ”€GET / HTTP/1.1❌r❌nHost: emojiwat-flag❌r❌n❌r❌nπŸ”€β—οΈβ—οΈ

    🍺 πŸ‘‚ socket 250❗️ ➑️ data
    πŸ˜€ 🍺 πŸ”‘ data❗️❗️
  πŸ‰

and we get the flag:

BSidesTLV2020{(^_^)YOU[o_o]DID(^.^)IT($.$)}

As Tomer (one of the challenge's author) would say: 🍺 is always the answer to everything.

N.B.: 🚨 As described in the documentation, this solution should not be used in your Emojicode production code πŸ˜€

Unless you are absolutely sure that a call will never raise an error, using 🍺 is a bad idea.