题目链接:ctf.show
下载附件得到了一张照片
使用kali中binwalk查看,发现有隐藏文件
使用foremost分离文件
发现压缩包嵌套
解压两次发现,有一串base字符
base64解码得到密码123456(用于解压下一个压缩包)得到
写个脚本解一解
import re
from tqdm import tqdm
def read_file(filepath):
with open(filepath) as fp:
content=fp.read();
return content
number = read_file('thienc.txt')
result = []
result.append(re.findall(r'.{2}', number))
result = result[0]
strings =''
for i in tqdm(result, total=len(result), desc="处理中"):
y = bytearray.fromhex(i)
z = str(y)
z= re.findall("b'(.*?)'",z)[0]
strings += z
b= strings.split('0x')
strings=''
for i in b:
if len(i) ==1:
i= '0' + i
strings +=i
with open('te.txt', 'w') as f:
f.write(strings)
把解出来的结果导入到编辑器中保存,发现是7Z头
但是解压需要密码,我们foremost分离出来的还有个图片,010查看末尾发现
base64+32解码得到KEY{Lazy_Man}
解压7z得到
发现base64 base32解码发现不行
后来发现是个base64+32循环解码。
使用脚本解码,也可以使用在线网站解码
import base64
import re
f = open('secenc.txt').read().encode('utf-8')
while True:
if re.match('^[2-7A-Z=]+$', f.decode('utf-8')):
f = base64.b32decode(f)
elif re.match('^[0-9a-zA-Z+/=]+$', f.decode('utf-8')):
f = base64.b64decode(f)
else:
print(f.decode('utf-8'))
break
with open('result.txt', 'w', encoding='utf-8') as file:
file.write(str(f,encoding='utf-8'))
print("Decryption complete!")
得到flag:flag{Welc0me_tO_cTf_3how!}
有点菜
制作不易
勿喷!!!!