Misc - Weird Friend

Easy | 95 solves | 87 points

Description

My weird friend did it again! I gave him my list of questions and asked him for a quick response. He took things literally and this is what he gave me!? Can you make any sense of it?

Downloads

Solution

We are given a text file that contains a binary string.

I did not know how to approach this at first. There are 841 binary digits which was weird because it is not divisible by 8 so converting it to ASCII would not make sense. Towards the end of the CTF, the admin was hinting to focus on the word "quick response" which I did not immediately get but after some google searches, I realised that quick response is the acronym for QR. Now 841 binary digits make perfect sense because it is a square number (29x29=841).

During the CTF, I wrote a python script to form the QR code using the binary string.

from PIL import Image
import textwrap

binstring = "1111111001110110010000111111110000010000110100110101000001101110100111001110010010111011011101010110100000000101110110111010101010001101001011101100000100110001011000010000011111111010101010101010111111100000000010010000000100000000110001110110110101000000110000010010000100011000101011010111000110110110011110010111100101001010011001100000010110111001111101101011101101110011111010100001011111001011111000011101101100011110101101000000010000100000000101111010110001000010100101100110000110000101111010101010111101101110001101101011111001110100001100110011001010100101001111001000100100101110110001011111111000000000010110001001110001001111111110101010010110101011100100000101010100000011000110111011101001010011000111111000010111010010110111110110101001101110100110000111000001111101000001010010010000110101110111111110101111100101000000100"

# Print bits in 29x29 square
print(textwrap.fill(binstring,width=29))

# Make an image from the bits
outimg = Image.new( 'RGB', (29,29), "black") 
pixels_out = outimg.load() 

count=0 
for bit in binstring:    
    i=count%29
    j=count/29
    if bit == '0':
        pixels_out[(i,j)]=(255,255,255)
    count += 1
        
outimg = outimg.resize((100,100))
outimg.save("qrout.png","png")

Scanning the output QR code image will then give us the flag.

Flag: TFCCTF{why_ar3_QR_C0d3s_s0-complicated!?o00o0f}

Bonus

After the CTF, someone revealed that there is a website that can generate the QR code from the binary string. Link: https://bahamas10.github.io/binary-to-qrcode/

Should have totally googled more before starting any python scripting :|

Last updated