Rating: 5.0
Inside of each 7z file there were two images and another 7z file.
The two images differed by only 1 pixel and were sometimes rotated/flipped. We had to use the different pixel to generate the password to the 7z file.
```
from PIL import Image
import sys
import subprocess
import os
def extract(file, pwd, outdir):
o = subprocess.call(
['7z', 'x', '-y', '-p' + pwd, '-o' + outdir, file])
return o
def tryy(l, x, y, p1, p2):
r1, g1, b1 = p1
r2, g2, b2 = p2
xy = str(x) + str(y)
rgb1 = '{:0{}X}'.format(r1, 2) + '{:0{}X}'.format(g1, 2) + '{:0{}X}'.format(b1, 2)
rgb2 = '{:0{}X}'.format(r2, 2) + '{:0{}X}'.format(g2, 2) + '{:0{}X}'.format(b2, 2)
password = xy + rgb1 + rgb2
print(password)
fn = f"level{l}/level_{l+1}.7z"
code = extract(fn, password, f"level{l+1}")
if code == 0:
os.remove(fn)
return code == 0
def find_pixel(im1, im2, f=lambda x, y: (x, y)):
pp = None
width, height = im1.size
for y in range(height):
for x in range(width):
x2, y2 = f(x, y)
p1 = im1.getpixel((x, y))
try:
p2 = im2.getpixel((x2, y2))
except:
return None
if p1 != p2:
if pp:
return None
pp = x, y, p1, p2
return pp
def do(l):
im1 = Image.open(f'level{l}/level_{l}.png')
im2 = Image.open(f'level{l}/lev3l_{l}.png')
width, height = im1.size
funs = [
lambda x, y: (x, y),
lambda x, y: (x, height - 1 - y),
lambda x, y: (width - 1 - x, y),
lambda x, y: (width - 1 - x, height - 1 - y),
lambda x, y: (y, x),
lambda x, y: (y, width - 1 - x),
lambda x, y: (height - 1 - y, x),
lambda x, y: (height - 1 - y, width - 1 - x),
]
for f in funs:
pp = find_pixel(im1, im2, f=f)
if not pp:
continue
tryy(l, *pp)
i = 0
while True:
do(i)
i += 1
```
We had to do this 1024 times to get the flag: `{FLG:p1xel0ut0fBound3xcept1on_tr4p_1s_shutt1ng_d0wn}`.