pythonchallenge Level 21

隐藏在20关中

import zlib,bz2
file = open("./readme/package.pack",'rb').read()
print(file)

def unwrap(data):
    while True:
        if data.startswith(b'x\x9c'):
            data = zlib.decompress(data)
        elif data.startswith(b'BZh'):
            data = bz2.decompress(data)
        elif data.endswith(b'\x9cx'):
            data = data[::-1]
        else:
            return data

print(unwrap(file)) # b'sgol ruoy ta kool'
print(unwrap(file)[::-1]) # b'look at your logs'

def unwrap(data):
    result = ""
    while True:
        if data.startswith(b'x\x9c'):
            data = zlib.decompress(data)
            result += ' '
        elif data.startswith(b'BZh'):
            data = bz2.decompress(data)
            result += '#'
        elif data.endswith(b'\x9cx'):
            data = data[::-1]
            result += '\n'
        else:
            print(result)
            return data

unwrap(file)

这关没搞懂,根据资料拿到下一关地址copper

获得下一关地址:http://www.pythonchallenge.com/pc/hex/copper.html

posted @ 2021-12-07 10:01  OTAKU_nicole  阅读(73)  评论(0编辑  收藏  举报