zip套娃爆破

exp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import zipfile
import os

# 初始设置:压缩包存储目录和初始zip文件名称
"""只要修改路径和需要解压的压缩包即可"""
zip_directory = r'D:\网站下载\taowa'
zip_name = '999.zip'

# 循环解压嵌套的压缩包
while True:
# 拼接当前的完整压缩包路径
zip_path = os.path.join(zip_directory, zip_name)

# 打开当前压缩包
with zipfile.ZipFile(zip_path, 'r') as myzip:
# 获取压缩包内文件列表
file_list = myzip.namelist()

# 判断是否有zip文件,提取文件名
if not any('.zip' in f for f in file_list): # 如果文件列表中没有zip文件
print(f"Final unzipped location: {zip_path}")
# 解压到目标目录
myzip.extractall(os.path.join(zip_directory, 'final'))
break # 终止循环
else:
# 如果文件列表中有zip文件,提取其中第一个zip文件
for file_name in file_list:
if file_name.endswith('.zip'):
zip_name = file_name # 更新zip_name为内部的zip文件
break
# 解压当前的zip包到同级目录
myzip.extractall(zip_directory)

import os

def find_deepest_txt_file(root_dir):
deepest_path = ‘’
max_depth = -1
txt_file_path = ‘’

for current_dir, dirs, files in os.walk(root_dir):
    depth = current_dir.count(os.sep)
    if depth > max_depth and any(f.endswith('.txt') for f in files):
        max_depth = depth
        deepest_path = current_dir
        # 只读取第一个 .txt 文件(如果有多个可以改成循环)
        for f in files:
            if f.endswith('.txt'):
                txt_file_path = os.path.join(current_dir, f)
                break

if txt_file_path:
    print(f'找到的最深层 .txt 文件路径是:\n{txt_file_path}\n')
    with open(txt_file_path, 'r', encoding='utf-8') as file:
        content = file.read()
    print('文件内容如下:\n')
    print(content)
else:
    print('没有找到 .txt 文件')

if name == ‘main‘:
root_dir = ‘next_or_end/‘ # 可修改为你的起始目录
find_deepest_txt_file(root_dir)

例题

解不完的压缩包

这里附上爆破脚本(使用时记得修改初始设置)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import zipfile
import os

# 初始设置:压缩包存储目录和初始zip文件名称
"""只要修改路径和需要解压的压缩包即可"""
zip_directory = r'D:\网站下载\taowa'
zip_name = '999.zip'

# 循环解压嵌套的压缩包
while True:
# 拼接当前的完整压缩包路径
zip_path = os.path.join(zip_directory, zip_name)

# 打开当前压缩包
with zipfile.ZipFile(zip_path, 'r') as myzip:
# 获取压缩包内文件列表
file_list = myzip.namelist()

# 判断是否有zip文件,提取文件名
if not any('.zip' in f for f in file_list): # 如果文件列表中没有zip文件
print(f"Final unzipped location: {zip_path}")
# 解压到目标目录
myzip.extractall(os.path.join(zip_directory, 'final'))
break # 终止循环
else:
# 如果文件列表中有zip文件,提取其中第一个zip文件
for file_name in file_list:
if file_name.endswith('.zip'):
zip_name = file_name # 更新zip_name为内部的zip文件
break
# 解压当前的zip包到同级目录
myzip.extractall(zip_directory)

拿到1.zip

1727162769582-eb127e25-d6a5-46ac-b6e8-6133526e930f.png

发现解压要密码

1727162838854-3e32704b-17d0-4f2a-a939-e926b2803165.png

crcexp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from binascii import crc32
import string
import zipfile

dic = string.printable


def CrackCrc(crc):
for i in dic:
# print (i)
for j in dic:
s = i + j
# print (crc32(bytes(s,'ascii')) & 0xffffffff)
if crc == (crc32(bytes(s, 'ascii')) & 0xffffffff):
print(s)
return


def getcrc32(fname):
l = []
file = fname
f = zipfile.ZipFile(file, 'r')
global fileList
fileList = f.namelist()
print(fileList)
# print (type(fileList))
for filename in fileList:
Fileinfo = f.getinfo(filename)
# print(Fileinfo)
crc = Fileinfo.CRC
# print ('crc',crc)
l.append(crc)
return l


def main(filename=None):
l = getcrc32(filename)
# print(l)
for i in range(len(l)):
print(fileList[i], end='的内容是:')
CrackCrc(l[i])


if __name__ == "__main__":
main('cccccccrc.zip')

1727164516506-a5ae1627-40bb-4b70-83b6-683929ea5824.png

密码*m:#P7j0

1727164624552-ae97851f-33a5-426e-a268-1cd29be4b1d5.png

更新: 2024-09-24 15:57:34
原文: https://www.yuque.com/chaye-apqbl/vsc85q/xqwsgv9y6oifi0yf

  1. | | |—| |import os| || |def find_deepest_txt_file(root_dir):| |deepest_path = ‘’| |max_depth = -1| |txt_file_path = ‘’| || |for current_dir, dirs, files in os.walk(root_dir):| |depth = current_dir.count(os.sep)| |if depth > max_depth and any(f.endswith(‘.txt’) for f in files):| |max_depth = depth| |deepest_path = current_dir| |# 只读取第一个 .txt 文件(如果有多个可以改成循环)| |for f in files:| |if f.endswith(‘.txt’):| |txt_file_path = os.path.join(current_dir, f)| |break| || |if txt_file_path:| |print(f’找到的最深层 .txt 文件路径是:\n{txt_file_path}\n’)| |with open(txt_file_path, ‘r’, encoding=’utf-8’) as file:| |content = file.read()| |print(‘文件内容如下:\n’)| |print(content)| |else:| |print(‘没有找到 .txt 文件’)| || |if name == ‘main‘:| |root_dir = ‘next_or_end/‘ # 可修改为你的起始目录| |find_deepest_txt_file(root_dir)| ||

http://example.com/2026/01/19/MISC/zip解密/zip套娃爆破/
Author
chaye
Posted on
January 19, 2026
Licensed under