Python Challenge [6]

Files within files.

From the clue, we have a zip file called channel.zip that we’ll need to take a look at.[1]


import os,re
os.chdir("/home/dan/Documents/channel")
os.getcwd()
nada = "90052"
while True:
	history.append(nada)
	file = nada + ".txt"
	raw = open(file).read()  
	print raw
	nada = "".join(re.findall('[0-9]',raw))
	if(len(nada)==1):
		break

After a hint to check $unzip -l channel.zip | less


import re,zipfile
nada="90052"
file = zipfile.ZipFile("channel.zip", "r")
history = []
while True:
        history.append(nada)
	raw = file.read(nada + ".txt")
	print raw
	nada = "".join(re.findall('[0-9.]',raw))
	if(len(nada)==1):
		break

print ''.join([file.getinfo(i+'.txt').comment for i in history])

[1] A side note about zip files: you can create a ‘hidden-in-plain-sight’ file by zipping a text file and jpeg image, then renaming the compressed file to the name of the image and replacing the extension with ‘jpg’.