# Misc - Broken Pieces

## Description

Oh no! I broke this framed image. Unless you can magically put it together, I’m in big trouble. Flag format: CTF{...}

## Downloads

{% file src="<https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2FZSKv33fWsZeN6dzPCjEf%2Fpieces.zip?alt=media&token=bad71dc7-1048-44a2-ac32-8c1f3f866e9a>" %}

## Solution

The official category is **OSINT** but I think its really more of a **Misc** challenge so I am going to label it as a **Misc** challenge.

In this challenge, we are given 400 images and each of them is of the size 15x15. The challenge objective is straight-forward but not many people would know how to write a script to combine the images. Writing the script is trivial in python thanks to the [Pillow](https://github.com/python-pillow/Pillow) library. The final script is as such:

```python
from PIL import Image

# Since there are no dimensions specified and we are given 400 images,
# we assume it is a 20 by 20 square matrix. Hence, 15*20, 15*20.
src = Image.new('RGB', (300, 300))

for j in range(1,21):
    for i in range(1,21):
        dst = Image.open("pieces/" + str(i).zfill(2) + str(j).zfill(2) + ".jpg")
        column = 1 if j == 1 else (j-1)*15
        row = 1 if i == 1 else (i-1)*15
        src.paste(dst, (column, row))
        
src.save('out.png')
```

The final image generated is a QR code image:

![](https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2Fejo2uPgFjaqis5KgOEqH%2Fimage.png?alt=media\&token=2e7383e7-49c2-41c2-82d7-002d83401086)

Decoding using my favourite [online QR code reader](https://zxing.org/w/decode.jspx), we get the flag.

![](https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2FL1oiuwvXOWKTOJ2qNuo3%2Fimage.png?alt=media\&token=d8bc6628-4ece-4fdc-a780-95dd687ac121)

Flag: `CTF{th@nk2_f0r_h3lping}`
