BUUCTF-MISC-两道绘图类题目

梅花香自苦寒来

用 py 的 image(pillow) 库

f1 = open(r'D:\0CTF\BUUCTF\Misc\梅花香自苦寒来\梅花香之苦寒来\2.txt','w+')
with open(r'D:\0CTF\BUUCTF\Misc\梅花香自苦寒来\梅花香之苦寒来\1','r')as f2:
    while 1:
        x = f2.read(2)
        if not x:
            break
        s = '0x' + x
        f1.write(chr(int(s,16)))
f1.close()
from PIL import Image, ImageDraw, ImageFont, ImageFilter
f1 = open(r'D:\0CTF\BUUCTF\Misc\梅花香自苦寒来\梅花香之苦寒来\2.txt','r')
width = 300
height = 300
image = Image.new('RGB', (width, height), (255, 255, 255))
draw = ImageDraw.Draw(image)
color = (0,0,0)
while 1:
    s = f1.readline()
    if not s:
        break
    s = s.strip('\n')
    s = s.lstrip('(')
    s = s.rstrip(')')
    a = int(s.split(',')[0],10)
    b = int(s.split(',')[1],10)
    draw.point((a, b), fill=color)
image.show()


[BJDCTF 2nd]Real_EasyBaBa

同理用image处理hint得二维码

from PIL import Image, ImageDraw, ImageFont, ImageFilter
width = 70
height = 40
image = Image.new('RGB', (width, height), (255, 255, 255))
draw = ImageDraw.Draw(image)
color = (0,0,0)
with open(r'D:\0CTF\BUUCTF\Misc\[BJDCTF 2nd]Real_EasyBaBa\hint','r') as f:
    x = 0
    y = 0
    while 1:
        s = f.read(1)
        if not s:
            break
        if s== ' ':
            x += 1
        elif s== '\n':
            y += 1
            x = 0
        elif s== '#':
             draw.point((x, y), fill=color)
             x += 1
image.show()

可以到以下两个链接继续学习
https://www.liaoxuefeng.com/wiki/1016959663602400/1017785454949568
https://blog.csdn.net/leemboy/article/details/83792729

你可能感兴趣的:(BUUCTF-MISC-两道绘图类题目)