天天看点

【愚公系列】2021年11月 攻防世界-进阶题-MISC-030(red_green)一、red_green二、答题步骤总结

文章目录

文件:攻防世界下载对应文件

下载得到一张图片

解法一:pytho脚本

#生成脚本

from PIL import Image

import os

import bitstring

#image_name = 'flag.jpg'

image_name = input("请输入当前文件夹下图片的名称>>>\n")

current_path = os.path.dirname(__file__)

with open(os.path.join(current_path,image_name),'rb') as f:

   bin_content = bitstring.Bits(f)

   im = Image.new("RGB",(1024,780),(255,0,0))

   pim = im.load()

   for i,val in enumerate(bin_content.bin):

       if val == '0':

           pim[i%1024,i/1024] = (0,255,0)

   im.save(os.path.join(current_path,'red_green.png'))

#还原脚本

image_name = 'red_green.png'

im = Image.open(os.path.join(current_path,image_name))

image_width = im.size[0]

image_height = im.size[1]

# load pixel

pim = im.load()

bin_result = ''

for row in range(image_height):

   for col in range(image_width):

       if pim[col,row][0] == 255:

           bin_result += '1'

       else:

           bin_result += '0'

with open(os.path.join(current_path,'result.jpg'),'wb') as f:

   f.write(bitstring.BitArray(bin=bin_result).bytes)

解法二:stegsolve,lsb隐写保存二进制

【愚公系列】2021年11月 攻防世界-进阶题-MISC-030(red_green)一、red_green二、答题步骤总结

解法三:zsteg

zsteg -E b1,r,lsb,xy 2ec5da20345342909d2336aa7418afed.png > new.jpg

  • zsteg