32 lines
900 B
Python
32 lines
900 B
Python
|
import string
|
||
|
from bs4 import BeautifulSoup
|
||
|
from PIL import Image
|
||
|
from pyzbar.pyzbar import decode
|
||
|
|
||
|
qr_size = 25
|
||
|
pix_size = 10
|
||
|
img_size = pix_size * qr_size
|
||
|
|
||
|
with open("templates/santa.j2", "r") as f:
|
||
|
soup = BeautifulSoup(f.read(), "html.parser")
|
||
|
img = Image.new("RGB", (img_size, img_size), "white")
|
||
|
y = 0
|
||
|
|
||
|
for c in string.ascii_lowercase:
|
||
|
bin_str = ""
|
||
|
x = 0
|
||
|
for e in soup.find_all("span"):
|
||
|
if e.text.strip() == "{{" + c + "}}":
|
||
|
if "a" in e["class"]:
|
||
|
color = (0, 0, 0)
|
||
|
else:
|
||
|
color = (255, 255, 255)
|
||
|
|
||
|
for xi in range(x, x+pix_size):
|
||
|
for yi in range(y, y+pix_size):
|
||
|
img.putpixel((xi, yi), color)
|
||
|
|
||
|
x += pix_size
|
||
|
y += pix_size
|
||
|
|
||
|
print("[+] Flag:", decode(img)[0].data.decode())
|