ECSC 2019 - qrcode

description: QR Codes everywhere!

category: misc - 102


The challenge is giving us a command to interact with the service: nc 3001.

# nc 3001
Programming challenge
I will send you a PNG image compressed by zlib encoded in base64 that contains 64 encoded numbers.
The expected answer is the sum of all the numbers (in decimal).
You have 2 seconds.
Are you ready? [Y/N]
What is you answer?
Time is up!

Okay, we have to make a sum, let’s see the base64: ecsc_qrcode_b64.png

There is 64 qrcodes and represent an encoded number.

So we have to retrieve the image, cut it in 64 squares decode each qrcode and sums them.

I found a cool lib on github and this is the python implementation to resolve the challenge:

from __future__ import division
import zlib
from pwn import *
import image_slicer
from pyzbar.pyzbar import decode

libed = ""
res = 0
f = open('output', 'wb')

r = remote('', 3001)



while 1:
	tmp = r.recvline().strip()
	if "What" in tmp:
	libed += tmp

str_object2 = zlib.decompress(libed.decode('base64'))


tiles = image_slicer.slice('output', 64, save=False) # "Save=False" -> so it is not written to filesystem andd we save some time

for tile in tiles:
	data = decode(tile.image)
	res += int(str(data)[15:25])


while 1:
	print r.recvline()

And the output:

# python 
[+] Opening connection to on port 3001: Done
 Congrats! Here is your flag: ECSC{e076963c132ec49bce13d47ea864324326d4cefa}

Then the flag is ECSC{e076963c132ec49bce13d47ea864324326d4cefa}