1.[羊城杯 2022]Unlimited Zip Works
1.打开后发现应该是无规则命名无密码zip套娃,再查看注释,发现有内容,组成的应该是一个新的zip,写脚本批量提取(这里使用的是网上找的)
点击查看代码
import zipfile
name = 'file'
infolist = []
num = 1
newzip=b''
while True:
fz = zipfile.ZipFile(name + '.zip', 'r')
for i in fz.namelist():
if "zip" in i:
filename = i[0:5]
# print(filename)
fz.extractall(pwd=bytes(filename, 'utf-8'))
num += 1
name = filename
for j in fz.infolist():
infolist.append(j.comment)
if 'flag.txt' in str(j):
print('[+] 解压完成')
list2 = infolist[::-1]
for k in list2:
newzip += k
with open('./newfile.zip','wb') as f:
f.write(newzip)
print("[+] 成功生成新压缩包newfile.zip")
exit(0)
2.得到一堆zip,要的是newfile.zip,打开后会发现没有什么有用信息,都是txt
3.010打开,查看一下这个zip的结构,可以发现其中好像还隐藏了一个zip,写代码改一下(直接手撕格式上会有问题)
点击查看代码
from zipfile import ZipFile
data = []
with ZipFile( 'newfile.zip', 'r') as zf:
for i in zf.infolist():
data.append(i.extra)
with open('flag.zip','wb') as fz:
for i in data:
fz.write(i)