题目
给出一张图片
解题
from PIL import Image
import random
# 读取txt文件
with open("rgb.txt", "r") as file:
lines = file.readlines()
# 跳过第一行(包含尺寸信息)
lines = lines[1:]
# 提取RGB颜色值
colors = [tuple(map(int, line.strip().strip('()').split(","))) for line in lines]
# 图像尺寸
width, height = 800, 800
# 创建一个新的图像,使用RGB模式,并指定尺寸
image = Image.new("RGB", (width, height))
# 计算每个颜色需要重复的次数(向上取整)
# 但由于颜色数量可能不足以填充整个图像,我们可能需要随机化
pixels_per_color = max(1, (width * height) // len(colors))
# 初始化一个列表来存储像素数据
pixel_data = []
# 遍历颜色列表,并添加足够多的重复颜色到像素数据中
for color in colors:
pixel_data.extend([color] * pixels_per_color)
# 如果像素数据少于图像的总像素数,则随机分配剩余像素的颜色
while len(pixel_data) < width * height:
pixel_data.append(random.choice(colors))
# 使用像素数据填充图像
image.putdata(pixel_data)
# 保存图像
output_filename = "output_800x800.png"
image.save(output_filename)
┌──(holyeyes㉿kali2023)-[~/Misc/tool-misc/zsteg]
└─$ zsteg *.png
imagedata .. text: "56,>D8\t\r"
b1,r,lsb,xy .. text: "`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`L`Lr"
b1,rgb,lsb,xy .. file: PNG image data, 572 x 138, 8-bit/color RGBA, non-interlaced
b1,bgr,msb,xy .. file: OpenPGP Secret Key
b2,rgb,msb,xy .. text: "_UUUUU@W#A"
b2,bgr,msb,xy .. text: "}UUUUU@w!"
b3,g,lsb,xy .. text: "IW%M%$I6"
b3,g,msb,xy .. text: "$MeYiZ[m-"
b4,r,lsb,xy .. text: "guEweUEvfvg3"
b4,g,lsb,xy .. text: "\"\"$Dgvf\"\""
b4,g,msb,xy .. text: "f.\"\"*JLL"
b4,b,lsb,xy .. text: "vfftBDDDU\"\"#\"$DDF"
b4,b,msb,xy .. text: "nff.B\"\"\""
b4,rgb,msb,xy .. text: "C5R#5R#5R#5"
b4,bgr,msb,xy .. text: "2%S2%S2%S:"
┌──(holyeyes㉿kali2023)-[~/Misc/tool-misc/zsteg]
└─$ zsteg -E b1,rgb,lsb,xy out*.png > new.png
得到flag
DASCTF{Dish_dog}