Python Challenge level 21: “hidden pack”
There’s no page for this challenge. From the previous level we get a hidden file that was “hiding at 1152983631″. It’s a zipfile with a password. Luckily back in level 20 we also got a tip “esrever ni emankcin wen ruoy si drowssap eht”, and a nickname: invader.
After extracting the archive, we get a text file with the hints, and a file named package.pack
Hint 1: We used to play this game when we were kids.
Hint 2: When I had no idea what to do, I looked backwards.
Hint 3: package.pack
The .pack extension suggested something, so after trying several compression modules the winner is zlib . Once extracted the file’s size is more or less the same. Suspicious. Still unreadable. The second hint comes in handy, and it looks like the tail of the file is a reversed bzip2 header. We already have experience with that thanks to previous levels, isn’t it? Again unreadable. Again reversible. Again compressed. And the show goes on. We’ll have to go back and forth several times to extract the content.
import zlib,bz2
st=open('21_package.pack').read()
log=''
log_len=len(log)
while True:
try: #zlib
st=zlib.decompress(st)
log+=' '
except:
try: #bzip2
st=bz2.decompress(st)
log+='#'
except: #reverse
if log_len==len(log): break
st=st[::-1]
print log[log_len:]
log_len=len(log)
open('21_package.unpack','wb').write(st)
After the whole run we get to read what’s in package.pack:
look at your logs
Originaly I kept a list with the number of zlib and bzip2 cycles en each run, expecting a banner(ish) run length encoding. I noticed that the sum of cycles needed to complete each direction was allways roughly the same. That is, before I had to reverse the string to start over, the sum of bzip+zip+bzip+… was more or less 73. And that meant that the output was meant to be directly graphical, so I sticked with a simpler log version that simplifies the code in turn.
The logs in question look like:
### ### ######## ######## ########## ########
####### ####### ######### ######### ######### #########
## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ##
## ## ## ######### ######### ######## #########
## ## ## ######## ######## ######## ########
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ##
####### ####### ## ## ######### ## ##
### ### ## ## ########## ## ##
Will wonders never cease? Very nice level. It took me a while to figure out the representation for the logs and I never made sense of the first hint -something cultural I suppose-, but an excellent level nevertheless.
Copper is the next level. Level 22.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
The cultural reference is pass the parcel. Its a children’s party game where you have music, pass a parcel around and when the music stops the person holding it unwraps a layer of the parcel. the parcel usually has a sweet in each layer and a present in the middle.
It’s been such a long time since the last post… But whatever… The link that leads to the level 22 solution is broken. >.<' Don't know if it's a dumb comment but…
Try this link:
http://unixwars.com/2007/09/28/python-challenge-level-22/
If it doesn’t work, hit the month September 2007, and look for level 22 on that page.