Description
Someone sent me a file with white and black rectangles. I don’t know how to read it. Can you help me?Attachment: misc60.zip
Exploit Since the =
padding in the README.txt
, I try to use base64 decode and get something like
██████████████████████████████████████████████ ██ ██ ██ ██ ██ ██ ██ ██████████ ██████████ ██ ██████████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██████████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██████████ ████ ██ ██ ██████████ ██ ██ ██ ██ ██ ██ ██ ████████████████████████ ██████████████████ ████ ████ ██ ████ ██ ████ ██ ██ ██ ██ ██ ████████ ██ ████████ ██ ██ ██ ██████ ████████ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████████████████████ ██ ██ ██ ██ ██ ████ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ██████████ ████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ██████████ ██ ██ ████ ██ ██ ████ ██ ██████ ████████ ██ ██ ██████████████████████████████████████████████
It is clear that they are QR code. However, I can’t scan the QR code in the text format even I adjust the line hight and change the color into black and white. Therefore, I write a script to get the message. I use PIL
to create the QR code image and scan it by zbarlight
. (Actually, during the competition, I simply show the QR code and scan by my mobile.) The message is Flagis:IW{QR_C0DES_RUL3}
.
decode.py download 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 from base64 import b64decodefrom PIL import Imagefrom zbarlight import scan_codesdef create_qrcode (qr) : img = Image.new('1' , (23 , 23 ), 'white' ) qr = qr.split('\n' ) for i in range(1 , 22 ): for j in range(2 , 44 , 2 ): if qr[i][j] == ' ' : img.putpixel((i, j/2 ), 0 ) return imgwith open('README.txt' ) as f: lines = f.read().split('\n' )[:-1 ] b64code = '' message = '' for l in lines: b64code += l if len(l) < 76 : qr_text = b64decode(b64code).decode('utf8' ) qrcode = create_qrcode(qr_text) message += scan_codes('qrcode' , qrcode)[0 ] b64code = '' print message
Flag: IW{QR_C0DES_RUL3}