Tags: crypto 

Rating:

# [YauzaCTF - 2019] Crypto challenge: **enJoy!**

## Task
![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/enjoychall.png)

## Solution
The challenge gives us a ***.rtf*** (Rich Text Format) file. I don't know much about this file type. First open this file with Word Editor, it looks like this:
![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/enjoyrtf.png)

This [site](https://www.linuxquestions.org/questions/linux-newbie-8/opening-rtf-files-350295/) suggests convert to HTML file and view with browser.
So I did, and I got a Base64 encoded text (**Note:** the encoded text has been shortened for readable):

![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/firstbase64.png)

Decode the above text with [Base64 decoder](https://www.base64decode.org/), I got the second Base64 encoded text (**Note:** the encoded text has been shortened for readable):

![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/secondbas64.png)

Decode again, now I got a string of hexadecimal (**Note:** the text has been shortened for readable):

![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/hex.png)

Using [Hex to Text converter](http://www.convertstring.com/vi/EncodeDecode/HexDecode), I got a substitution ciphertext:

![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/subscipher.png)

Using [Substitution solver](https://www.guballa.de/substitution-solver) to decrypt it:

![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/plaintext.png)

So, **Tupper's self-referential formula** right? This formular visually represents itself when graphed at a specific location in the (x, y) plane. From [here](https://shreevatsa.wordpress.com/2011/04/12/how-does-tuppers-self-referential-formula-work/), we got the formula:

![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/formula.png)

Maybe the very long number which represented in binary string we have received from the plaintext is the given number N for the formula. Then I found this [site](http://keelyhill.github.io/tuppers-formula/) which will draw the graph according to given N using Tupper's self-referential formula.
Using the given binary string, here is the flag:

![enJoyChallenge](https://gitlab.com/145giakhang/playing-ctf/raw/master/CTF-events/2019/YauzaCTF/Crypto/Enjoy/images/flag.png)

Original writeup (https://gitlab.com/145giakhang/playing-ctf/tree/30682f8fd2ec1408a8ba6cf23cda1755da3561d1/CTF-events/2019/YauzaCTF/Crypto/Enjoy).
dc143cApril 14, 2019, 11:58 p.m.

base64 is encoding not encryption.... js


xhoixApril 15, 2019, 8:02 a.m.

Edited...