diff --git a/Day 8/4dv3ntSn4il.png b/Day 8/4dv3ntSn4il.png new file mode 100644 index 0000000..83755f4 Binary files /dev/null and b/Day 8/4dv3ntSn4il.png differ diff --git a/Day 8/4dv3ntSn4il_cropped.png b/Day 8/4dv3ntSn4il_cropped.png new file mode 100644 index 0000000..14dc08b Binary files /dev/null and b/Day 8/4dv3ntSn4il_cropped.png differ diff --git a/Day 8/decode.py b/Day 8/decode.py new file mode 100755 index 0000000..aaa8b81 --- /dev/null +++ b/Day 8/decode.py @@ -0,0 +1,93 @@ +#!/usr/bin/python + +from PIL import Image +import types + +im = Image.open("4dv3ntSn4il_cropped.png") +pix = im.load() +numTiles = 25 +tileSize = im.size[0] // numTiles + +data = [["0" for x in range(numTiles)] for y in range(numTiles)] + +for x in range(0, numTiles): + for y in range(0, numTiles): + x_abs = x*tileSize + tileSize // 2 + y_abs = y*tileSize + tileSize // 2 + + pixel = pix[x_abs, y_abs] + + if type(pixel) is tuple: + data[x][y] = "0" if pixel == (255,255,255) else "1" + else: + data[x][y] = "0" if pixel / 255 > 0.5 else "1" + +bits = ''.join([''.join([data[x][y] for x in range(numTiles)]) for y in range(numTiles)]) + +print("Number of Zeros:", bits.count("0"), "Number of Ones:", bits.count("1"), "Length:", len(bits)) + +snail = "" +clockwise = False +bounds = [[0,numTiles-1],[0, numTiles-1]] +pos = [0,0] +dir = [1,0] if clockwise else [0, 1] +pixels = [] +while len(snail) < numTiles*numTiles: + if pos in pixels: + print("Fault:", pos, "already processed") + pixels.append(pos) + + snail += data[pos[0]][pos[1]] + next_pos = [pos[0] + dir[0], pos[1] + dir[1]] + if dir[0] == 1 and next_pos[0] > bounds[0][1] or dir[0] == -1 and next_pos[0] < bounds[0][0] or dir[1] == 1 and next_pos[1] > bounds[1][1] or dir[1] == -1 and next_pos[1] < bounds[1][0]: + if clockwise: + if dir[0] == 1: + dir = [0, 1] + bounds[0][1] -= 1 + elif dir[0] == -1: + dir = [0, -1] + bounds[0][0] += 1 + elif dir[1] == 1: + dir = [-1, 0] + bounds[1][1] -= 1 + elif dir[1] == -1: + dir = [1, 0] + bounds[1][0] += 1 + else: + if dir[0] == 1: + dir = [0, -1] + bounds[1][1] -= 1 + elif dir[0] == -1: + dir = [0, 1] + bounds[0][1] -= 1 + elif dir[1] == 1: + dir = [1, 0] + bounds[0][0] += 1 + elif dir[1] == -1: + dir = [-1, 0] + bounds[1][0] += 1 + + next_pos = [pos[0] + dir[0], pos[1] + dir[1]] + pos = next_pos + +if snail.count("0") != bits.count("0") or snail.count("1") != bits.count("1"): + print("Bits do not match") + exit() + +im = Image.new('RGB', im.size) +pix = im.load() + +for tileY in range(0, numTiles): + for tileX in range(0, numTiles): + + bit = snail[tileX * numTiles + tileY] + + for x in range(0, tileSize): + for y in range(0, tileSize): + + x_abs = tileX * tileSize + x + y_abs = tileY * tileSize + y + + pix[x_abs,y_abs] = (0,0,0,255) if bit == "1" else (255,255,255,255) + +im.save("decoded.png") diff --git a/Day 8/decoded.png b/Day 8/decoded.png new file mode 100644 index 0000000..13582f9 Binary files /dev/null and b/Day 8/decoded.png differ diff --git a/Teaser/_ZOoxjUSe1OVB7OPoVrsX.pdf.extracted/break_zip.py b/Teaser/_ZOoxjUSe1OVB7OPoVrsX.pdf.extracted/break_zip.py new file mode 100755 index 0000000..1e8ff9a --- /dev/null +++ b/Teaser/_ZOoxjUSe1OVB7OPoVrsX.pdf.extracted/break_zip.py @@ -0,0 +1,52 @@ +#!/usr/bin/python + +from time import time +from itertools import chain, product +import zipfile +import os +import sys +import tempfile +import shutil +import sys + +charset = "abcdefghijklmnopqrstuvwxyz" +charset = charset + charset.upper() +charset = charset + "0123456789- ." + +# + +def bruteforce(maxlength): + return (''.join(candidate) + for candidate in chain.from_iterable(product(charset, repeat=i) + for i in range(1, maxlength + 1))) + +def main(): + + while True: + try: + myZip = zipfile.ZipFile("z.zip") + except zipfile.BadZipfile: + print("[!] There was an error opening your zip file.") + return + + passwordFound = False + for password in bruteforce(1): + try: + myZip.extract("z.zip", "tmp/", password.encode("utf-8")) + shutil.move("tmp/z.zip", "z.zip") + sys.stdout.write(password) + sys.stdout.flush() + passwordFound = True + break + except Exception as e: + if 'Bad password for file' in str(e) or "Bad CRC-32 for file" in str(e): + pass + else: + print(e) + + if not passwordFound: + print("Sorry, password not found.") + return + +if __name__ == '__main__': + main() diff --git a/Teaser/_ZOoxjUSe1OVB7OPoVrsX.pdf.extracted/z.zip b/Teaser/_ZOoxjUSe1OVB7OPoVrsX.pdf.extracted/z.zip deleted file mode 100644 index caa2f74..0000000 Binary files a/Teaser/_ZOoxjUSe1OVB7OPoVrsX.pdf.extracted/z.zip and /dev/null differ