from getchallenge import challenge from PIL import Image from io import BytesIO clue = "hockey.html" problem = challenge(clue) print(problem.text) ''' Its in the air. Look at the letters if we look at the letters that make up hockey they spell oxygen so lets try that one ''' clue2 = 'oxygen.html' problem = challenge(clue2) print(problem.text) ''' a png file, looks like image processing may be needed so the image has a band of grey pixels this bad must be my encoded data I need to figure out a way to read it. ''' clue3 = 'oxygen.png' problem = challenge(clue3) pic = Image.open(BytesIO(problem.content)) # loaded image into an image object , now the real work begins data = [pic.getpixel((i, 45)) for i in range(0, pic.size[0], 7)] ords = [r for r, g, b, a in data if r == g == b]
''' Based on the clue given it is either a zipfile or pythons zip function When looking at the channel.zip we ca return a file for download The easy way to process this would be to download the file into our directory by hand and process the data however this solution uses requests to pull the file automatically ''' from zipfile import ZipFile from getchallenge import challenge from io import BytesIO import re data = challenge("channel.zip") zipped = BytesIO(data.content) # takes the data in as bytestream data # lets us work entirely in memory zipped = ZipFile(zipped) # | converts the zipfile into a dictionary using # V the names as keys and the contents as values stuff = {name: zipped.read(name).decode("utf-8") for name in zipped.namelist()} stuff = stuff def linkedPy(start, files): # function to go through the dictionary text = str(files.get(start)) pat = re.search('[-+]?\d+[\.]?\d*', text) if pat is None: return "not a file" else:
from getchallenge import challenge from PIL import Image from io import BytesIO clue = "hockey.html" problem = challenge(clue) print(problem.text) ''' Its in the air. Look at the letters if we look at the letters that make up hockey they spell oxygen so lets try that one ''' clue2 = 'oxygen.html' problem = challenge(clue2) print(problem.text) ''' a png file, looks like image processing may be needed so the image has a band of grey pixels this bad must be my encoded data I need to figure out a way to read it. ''' clue3 = 'oxygen.png' problem = challenge(clue3) pic = Image.open(BytesIO(problem.content)) # loaded image into an image object , now the real work begins
''' Based on the clue given it is either a zipfile or pythons zip function When looking at the channel.zip we ca return a file for download The easy way to process this would be to download the file into our directory by hand and process the data however this solution uses requests to pull the file automatically ''' from zipfile import ZipFile from getchallenge import challenge from io import BytesIO import re data = challenge("channel.zip") zipped = BytesIO(data.content) # takes the data in as bytestream data # lets us work entirely in memory zipped = ZipFile(zipped) # | converts the zipfile into a dictionary using # V the names as keys and the contents as values stuff = {name: zipped.read(name).decode("utf-8") for name in zipped.namelist()} stuff = stuff def linkedPy(start, files): # function to go through the dictionary text = str(files.get(start)) pat = re.search('[-+]?\d+[\.]?\d*', text) if pat is None: return "not a file" else: return pat.group(0) # returns a string result from re.search