mercoledì 22 agosto 2018

Beginners Quest (Google CTF) - 2° OCR is cool

Hi, hi, hi, hi, helladsladlsadsadasfewdgwrdf


Used tools:
  • eog (image viewer)
  • convert (for scaling up the image)
  • tesseract (OCR: extract text from an image)
  • caesar (decrypt Caesar cipher)
The state of the art is


Now we can choose one of three possible ways. For a reason that I don't know but that is hidden inside my fkin mind, I choose the path on top-side... Why? Because I can (cit. Katarina).

Let's go for the second challenge. So do we are sure to go for top-side path? No? Ok, I go for it anyway :-Q


Just one note: I love ancient Rome and Caesar (as him, other characters of our history) so he never died but he lives in my heart *_*

The reference to Caesar could be linked to the Caesar cipher (https://en.wikipedia.org/wiki/Caesar_cipher). Download the attachment, check the file type, rename it and extract the content:
  • file 7ad5a7d71a7ac5f5056bb95dd326603e77a38f25a76a1fb7f7e6461e7d27b6a3
It is a zip file.
  • mv 7ad5a7d71a7ac5f5056bb95dd326603e77a38f25a76a1fb7f7e6461e7d27b6a3 OCR.zip
  • unzip OCR.zip
The content is composed of one .png file called "OCR_is_cool.png". We can get more information about the file by typing:
  • file OCR_is_cool.png
We get that it is a png image with 1919 x 1079 resolution size.
If we open this file, by:
  • eog OCR_is_cool.png
we see the content of an email but with strange and nonsense statements.
If we give a better look, we read a text "VMY{nonsense text} that seems to have the same pattern of CTF{......} that we need. Remembering Caesar cipher, it probably is an easy encryption challenge.

The Caesar cipher is based on the shifting of the "plainletter" to the third letter before it (look the Wiki link above), so the Caesar cipher corresponds to the ROT3 operation where 3 is the number of times we shift to left. Of course we can change the input value of ROTn operation.

We can choose to scale up the image to allow the OCR tool (that we will use) to better recognize the letters:
  • convert OCR_is_cool.png -scale 300% OCR_is_cool_scaled.png
In our case, we need to extract the text by the image (OCR obviously). To do this, a particular tool can be useful, called Tesseract. You can install it by:
  • sudo apt-get install tesseract-ocr
Then:
  • tesseract OCR_is_cool_scaled.png output
  • cat output.txt
We extracted the text from the image file. If tesseract gives some warning, try to resample the original image otherwise tesseract extracts wrong characters from the image.
If tesseract does not work properly, then write manually inside a text file the VMY{...} part, we will use this file for decrypting the solution key
.
Now, we can use some tool that decrypts the Caesar cipher. This tool is called caesar or rot13 and we can install it by typing:
  • sudo apt-get install bsdgames
Now you can execute the Caesar cipher decrypter by calling:
  • cat output.txt | /usr/games/caesar [N]
where [N] is an integer number you insert as parameter. We can try different numbers until we read on the output the word "CTF". You can type:
  • for i in {0..26}; do echo $i ######################;cat output.txt | caesar $i ; done | less
The right input parameter is 7 that will show the plaintext and, so, the solution key.


If you want to be SPOILED for the solution key, just click below

Nessun commento:

Posta un commento