2021DASCTF实战精英夏令营暨DASCTF July X CBCTF 4th writeup

根据赛后讲解学习。

Misc

Nuclear_wastewater

二维码扫码没啥内容。。看图片像素。

from PIL import Image

pic = Image.open("aaaaa.png")  # type: Image.Image
width, height = pic.size
lst = []
for x in range(0, width, 10):  # 放大图片看一格子是10x10像素
    for y in range(0, pic.height, 10):
        pixel = pic.getpixel((x, y))
        if pixel == (255, 255, 255):
            continue
        r, g, b = pixel
        lst.extend(pixel)
from collections import Counter

data = ''
for i in lst:
    if i == 0: continue
    if i < 32 or i > 128:
        continue
    data += chr(i)

counter = Counter(data)
for k, count in counter.most_common():
    print(k, end='')  # key就是前面的  theKEYis:#R@/&p~!

得到解压密码。解压后文件用 Unicode Steganography with Zero-Width Characters 解不出来。
用winhex/vim看一下。有200c,200d,200e,勾选这3项解码。
得到提示:ctrix和去掉宽字符的密文

使用cyberchef进行ctrix解码2次得到flag

0x4Just_a_GIF

gif解压出图片451张。每11张循环一次
1.将相同图片对比像素点,得到一组图片a, 其中有2张提示9张拼接图
2.将a组合超来形成新图片b, 发现b是二维码的一部分
3.按提示将图拼拼来扫码

脚本

from pathlib import Path

from PIL import Image


def get_name(i):
    return str(i).rjust(3, '0') + '.png'


def diff(a, b, img) -> Image:  #
    a = Image.open(a)  # type: Image.Image
    b = Image.open(b)  # type: Image.Image
    a = a.convert("RGB")
    b = b.convert("RGB")

    w, h = a.size

    for x in range(w):
        for y in range(h):
            ra = a.getpixel((x, y))
            rb = b.getpixel((x, y))
            if ra != rb:
                img.putpixel((x, y), (1, 0, 0))


def main():
    count = len(list(Path('.').glob('*.png')))
    size = Image.open('001.png').size

    for start in range(11):
        img = Image.new("RGB", size, color=(255, 255, 255))
        for i in range(start, count, 11):
            if i + 11 > 450:
                break
            fp = get_name(i)
            fp_next = get_name(i + 11)
            diff(fp, fp_next, img)

        dst = Path('../res')
        if not dst.exists():
            dst.mkdir()
        img.save(dst / f'{start}.png')


if __name__ == '__main__':
    main()

我用手机上的barcode scanner扫的。qr searcher扫不到

其他wp链接:
http://www.snowywar.top/?p=2424
https://blog.csdn.net/qq_42880719/article/details/119301367

posted @ 2021-08-03 09:07  wgf4242  阅读(281)  评论(0编辑  收藏  举报