HackademINT

Club de cybersécurité de Telecom SudParis


MISC.QRCODE

Auteur : Bdenneu

----------------------------------

Enoncé

QR Codes everywhere!

nc challenges.ecsc-teamfrance.fr 3001

But

Le but est de récupérer le base64 d’une image, l’ouvrir, lire 64 qrcodes de nombres et d’en renvoyer la somme.

Qrcode

Le script

import base64
import pwn
from pyzbar.pyzbar import decode
import re
import zlib

try:
    import Image
except ImportError:
    from PIL import Image

r = pwn.remote("challenges.ecsc-teamfrance.fr", 3001)
r.recv()
r.sendline('Y')
image = b"".join(r.recvuntil("What")[:-4].split(b"\n")[:-1])
image = base64.b64decode(image)
image = zlib.decompress(image)
with open("qrextracted.png","wb") as f:
	f.write(image)
im = Image.open("qrextracted.png")

def get_qr_code(image,x,y,w,h):
	return image.crop((x,y,x+w,y+h))

qrcodes = []
w,h = im.size[0]//8,im.size[1]//8
somme = 0
for i in range(8):
	for j in range(8):
		somme += int(decode(get_qr_code(im,i*w,j*h,w,h))[0].data)
r.sendline(str(somme))
print(r.recv())
print(r.recv())

Le flag

ECSC{e076963c132ec49bce13d47ea864324326d4cefa}