查看几个压缩包,发现内容都是一致的,猜测应该flag就藏在这些文本文件中,来个脚本筛选出一个文件夹中文本内容不同的文本文件
import os
import filecmp
def find_different_files(directory):
files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f)) and f.endswith('.txt')]
if len(files) < 2:
print("需要至少两个文件进行比较。")
return []
files = [os.path.join(directory, f) for f in files]
different_files = []
first_file = files.pop(0)
for file in files:
if not filecmp.cmp(first_file, file, shallow=False):
different_files.append(file)
return different_files
directory = 'flag'
different_files = find_different_files(directory)
if different_files:
print("找到以下不同的文件:")
for file in different_files:
print(os.path.relpath(file, directory))
else:
print("所有文件内容都相同。")
293.txt_flag.txt打开就是flag