ECSC 2019 - qrcode
13 May 2019description: QR Codes everywhere!
category: misc - 102
The challenge is giving us a command to interact with the service: nc challenges.ecsc-teamfrance.fr 3001
.
# nc challenges.ecsc-teamfrance.fr 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]
>>Y
eJztvQtUU2faNtyZjjqv1XbmTa2CojNj24wwajEihxD4Wlu11oIWdoBAoDVNIgFBDCFACLRa28Fy
[...]
5hsxrwtfe/fM/wRHoMqu
What is you answer?
>>
Time is up!
Okay, we have to make a sum, let’s see the base64:
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('challenges.ecsc-teamfrance.fr', 3001)
r.recvuntil('>>')
r.send('Y\n')
while 1:
tmp = r.recvline().strip()
if "What" in tmp:
break
libed += tmp
str_object2 = zlib.decompress(libed.decode('base64'))
f.write(str_object2)
f.close()
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])
r.send(str(res)+"\n")
r.recvuntil('>>')
while 1:
print r.recvline()
And the output:
# python script.py
[+] Opening connection to challenges.ecsc-teamfrance.fr on port 3001: Done
Congrats! Here is your flag: ECSC{e076963c132ec49bce13d47ea864324326d4cefa}
Then the flag is ECSC{e076963c132ec49bce13d47ea864324326d4cefa}