PIL库学习(misc)+ 国赛Gif runningxxx

写在前面

后天考python TCTF不敢打。。。
正好python要考PIL库
那我们就借此机会向CTF misc无限拓展。。。

例子

准备拿国赛那道gif题下手
首先观察出 RGB 为 (233,233,233)
现在要从所有的帧中找到 RGB 为 这个的点的位置。。。
再拿来画图
找到flag

读文档

从动画里提取帧

from PIL import Image, ImageSequence

with Image.open("animation.fli") as im:
    index = 1
    for frame in ImageSequence.Iterator(im):
        frame.save(f"frame{index}.png")
        index += 1

Image.convert(mode)

将图像转换为mode模式

getpixel

getpixel函数是用来获取图像中某一点的像素的RGB颜色值,getpixel的参数是一个坐标点。对于图象的不同的模式,getpixel函数返回的值有所不同。

from PIL import Image ,ImageSequence

# im = Image.open("running_pixel.gif")
# # print(image.size)   (400, 400)
# w, h = im.size
# #我们想要找到像素为(233,233,233)的点 然后把他串起来。。。
# #首先 把gif拆开???
# #可以
#
# index = 1
# for frame in ImageSequence.Iterator(im):
#
#     frame = frame.convert("RGB")
#     frame.save("PNGS/run{}.png".format(index))
#     index += 1

# points = []
#
# def search(png):
#     for x in range(0,400):
#         for y in range(0,400):
#             if png.getpixel((x,y)) == (233,233,233):
#                 points.append((x,y))
#                 points
#
#
#
#
#
#
# for i in range(1,383):
#     with Image.open("PNGS/run{}.png".format(i)) as png:
#         search(png)
#
# print(points)




ls = [(325, 171), (326, 171), (327, 171), (328, 171), (329, 171), (229, 114), (229, 115), (229, 116), (230, 116), (231, 114), (231, 115), (231, 116), (232, 114), (233, 114), (233, 115), (233, 116), (36, 242), (36, 243), (36, 244), (37, 242), (38, 242), (38, 243), (38, 244), (39, 244), (40, 242), (40, 243), (40, 244), (306, 256), (306, 257), (306, 258), (307, 256), (307, 258), (308, 256), (308, 258), (309, 256), (309, 258), (310, 256), (310, 257), (310, 258), (359, 145), (359, 147), (360, 145), (360, 147), (361, 145), (361, 146), (361, 147), (362, 147), (363, 147), (152, 101), (152, 102), (153, 101), (153, 103), (154, 101), (154, 103), (155, 101), (155, 103), (156, 101), (156, 102), (360, 225), (360, 226), (360, 227), (361, 225), (361, 227), (362, 225), (362, 227), (363, 225), (363, 227), (364, 225), (364, 226), (364, 227), (235, 383), (235, 384), (235, 385), (236, 383), (237, 383), (237, 384), (237, 385), (238, 383), (239, 383), (32, 197), (32, 198), (32, 199), (278, 35), (278, 36), (278, 37), (279, 35), (279, 37), (280, 35), (280, 36), (280, 37), (281, 37), (282, 35), (282, 36), (282, 37), (174, 295), (174, 296), (175, 295), (175, 297), (176, 295), (176, 297), (177, 295), (177, 297), (178, 295), (178, 296), (167, 231), (167, 232), (167, 233), (168, 231), (169, 231), (169, 232), (169, 233), (170, 231), (171, 231), (171, 232), (171, 233), (249, 356), (250, 356), (251, 356), (252, 356), (253, 356), (342, 340), (342, 341), (342, 342), (243, 65), (243, 67), (244, 65), (244, 67), (245, 65), (245, 66), (245, 67), (246, 67), (247, 67), (117, 346), (117, 347), (118, 346), (118, 348), (119, 346), (119, 347), (120, 346), (120, 348), (121, 346), (121, 347), (67, 229), (67, 230), (67, 231), (68, 229), (68, 231), (69, 229), (69, 231), (70, 229), (70, 231), (71, 229), (71, 230), (71, 231), (39, 278), (39, 279), (39, 280), (40, 278), (40, 280), (41, 278), (41, 280), (42, 278), (42, 280), (43, 278), (43, 279), (43, 280), (279, 14), (279, 15), (279, 16), (264, 374), (264, 375), (264, 376), (265, 374), (265, 376), (266, 374), (266, 375), (266, 376), (267, 374), (267, 376), (268, 374), (268, 375), (268, 376), (70, 52), (70, 53), (70, 54), (71, 54), (72, 54), (73, 54), (74, 54), (228, 63), (229, 62), (229, 64), (230, 62), (230, 63), (230, 64), (231, 62), (231, 64), (232, 62), (232, 64), (321, 163), (321, 164), (321, 165), (322, 163), (323, 163), (323, 164), (323, 165), (324, 165), (325, 163), (325, 164), (325, 165), (289, 238), (289, 239), (289, 240), (161, 296), (162, 295), (162, 297), (163, 295), (163, 296), (163, 297), (164, 295), (164, 297), (165, 295), (165, 297), (72, 134), (72, 135), (72, 136), (73, 134), (74, 134), (74, 135), (74, 136), (75, 136), (76, 134), (76, 135), (76, 136), (165, 344), (165, 345), (165, 346), (166, 344), (167, 344), (167, 345), (167, 346), (168, 344), (169, 344), (310, 124), (310, 125), (311, 124), (311, 126), (312, 124), (312, 126), (313, 124), (313, 126), (314, 124), (314, 125), (357, 246), (357, 247), (358, 246), (358, 248), (359, 246), (359, 248), (360, 246), (360, 248), (361, 246), (361, 247), (14, 124), (14, 125), (14, 126), (15, 124), (15, 126), (16, 124), (16, 126), (17, 124), (17, 126), (18, 124), (18, 125), (18, 126), (386, 92), (386, 93), (386, 94), (387, 92), (387, 94), (388, 92), (388, 93), (388, 94), (389, 94), (390, 92), (390, 93), (390, 94), (315, 190), (315, 191), (315, 192), (316, 190), (316, 192), (317, 190), (317, 191), (317, 192), (318, 190), (318, 192), (319, 190), (319, 191), (319, 192), (231, 95), (231, 96), (231, 97), (232, 95), (233, 95), (233, 96), (233, 97), (234, 95), (234, 97), (235, 95), (235, 96), (235, 97), (337, 78), (338, 77), (338, 79), (339, 77), (339, 78), (339, 79), (340, 77), (340, 79), (341, 77), (341, 79), (379, 59), (379, 60), (379, 61), (380, 59), (380, 61), (381, 59), (381, 61), (382, 59), (382, 61), (383, 59), (383, 60), (383, 61), (122, 204), (122, 205), (122, 206), (123, 204), (123, 206), (124, 204), (124, 206), (125, 204), (125, 206), (126, 204), (126, 205), (126, 206)]
#flag是多少位? 怎么让它有序的显示出来?
#画图软件??
# print(len(ls))  346
pic = Image.new('1',(400,400),255)
index = 0
for i in ls:
    index += 1
    for j in range(0,index):
        pic.putpixel(ls[j],0)
    pic.save("picture/example{}.png".format(index))

#     pic.putpixel(i,0)

我们把像素一个一个加上去 然后一个一个点开看就ok了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值