bugku 蜘蛛侠
链接
思路
- 查看hint
- decode key.jpg
- import os
data_jpg = open('file.jpg', 'wb')
def jpg_encode():
with open('file.jpg', 'rb') as handle:
size = os.path.getsize('file.jpg')
print(size)
i = 0
while i<size:
bytedata = handle.read(1)
process_data = data_encode(bytedata)
data_write(process_data)
i = i + 1def data_encode(bytedata):
data = int.from_bytes(bytedata,byteorder='big')
if (data % 2 == 0):
data = (data + 1) ^ 128
else:
data = (data - 1) ^ 128
data = bytes([data])
return datadef data_decode(bytedata):
data = int.from_bytes(bytedata,byteorder='big')
if (data % 2 == 0):
data = (data - 1) ^ 128
else:
data = (data + 1) ^ 128
data = bytes([data])
return datadef jpg_decode():
with open('key.jpg', 'rb') as handle:
size = os.path.getsize('key.jpg')
print(size)
i = 0
while i<size:
bytedata = handle.read(1)
process_data = data_encode(bytedata)
data_write(process_data)
i = i + 1def data_write(process_data):
data_jpg.write(process_data)if __name__ == '__main__':
jpg_decode()
data_jpg.close()
- 得到file的jpg
- 010查看发现ffd9后有一串IQ2?kEcY/KK#ojDrHoR'seBbase92编码
- 解码得到提示silenteye,下载软件解密得到flag
文章评论