BUUCTF_misc_N种方法解决
环境
N种方法解决,base64图片
flag{dca57f966e4e4e31fd5b15417da63269}
wp
文件是一个文本文件,里面的base64编码的图片
import base64
import os
input_file = "D:\\rainbow\\Downloads\\1.txt"
output_file = os.path.join(os.path.dirname(input_file), "output.jpg")
try:
with open(input_file, "r") as file:
base64_data = file.read().strip()
if base64_data.startswith("data:image/jpg;base64,"):
base64_data = base64_data.split(",")[1]
binary_data = base64.b64decode(base64_data)
with open(output_file, "wb") as image_file:
image_file.write(binary_data)
print(f"图片已成功保存为 {output_file}")
except FileNotFoundError:
print(f"文件 {input_file} 未找到")
except base64.binascii.Error:
print("Base64 数据格式错误")
except Exception as e:
print(f"发生错误: {e}")
扫描二维码即可


浙公网安备 33010602011771号