题目链接:http://www.shiyanbar.com/ctf/1850
首先对这种文件先使用file命令查看一下文件类型,sos: Linux rev 1.0 ext2 filesystem data, UUID=0b92a753-7ec9-4b20-8c0b-79c1fa140869
,是一个linux文件系统,可以使用mount挂载查看内容,也可以直接使用binwalk -e SOS
提取(注:使用foremost提取失败),提取的结果是242个压缩包,每个压缩包中各有一个字符
#!/usr/bin/env python
# coding=utf-8
import gzip
import os
OUT_DIR_NAME = 'out'
if not os.path.exists(OUT_DIR_NAME):
os.mkdir(OUT_DIR_NAME)
OUT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), OUT_DIR_NAME)
# 解压缩所有压缩包
def un_gz(file_name):
f_name = file_name
g_file = gzip.GzipFile(file_name)
open(os.path.join(OUT_DIR, f_name), 'w').write(g_file.read())
g_file.close()
# 读取所有文件拼凑字符串
def conbine():
out = ''
for i in xrange(1, 243):
with open(os.path.join(OUT_DIR, str(i)), 'r') as f:
out += f.read()
print(out)
if __name__ == '__main__':
all_file = os.listdir('.')
all_file.remove(__file__)
for i in all_file:
if os.path.isfile(i):
un_gz(i)
conbine()
运行代码后,得到输出字符I'm from Black Eye Galaxy,Our spaceship broke down when we passed Mars.We need your help and we are available at any terminal.The key to contact us is CTF{131Ack_3Y3_gA1AxY}.Please contact us as soon as possible.we need your help desperately.
网友评论