Moved directories
This commit is contained in:
BIN
Day 01/a-letter-from-santa.zip
Normal file
BIN
Day 01/a-letter-from-santa.zip
Normal file
Binary file not shown.
32
Day 01/decode.py
Normal file
32
Day 01/decode.py
Normal file
@@ -0,0 +1,32 @@
|
||||
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())
|
||||
2
Day 01/templates/santa.j2
Normal file
2
Day 01/templates/santa.j2
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user