关卡七:smarty 足智
oxygen.png提示:
图片当中包含一道灰黑色条理,网页源代码也没任何线索,因此只能从图片入手。
python3开始解谜:
需要python3中用于图像处理库的包Pillow。
from PIL import Image
img = Image.open(r'C:\Users\GWT9\Desktop\oxygen.png')
print('图片高包含像素个数:%s'%img.height)
print('图片宽包含像素个数:%s'%img.width)
#输出结果:
#图片高包含像素个数:95
#图片宽包含像素个数:629
因为这一道灰黑条理比较特殊,将其rgb的值打印出,以便查看线索。首先定位这个条理。一种方法是将图片放大,数出这个条理的高度。
pixel.png
其中红色箭头指向的小方块就是一个像素。数完发现灰色条理在第43-51行。当然也可利用拾色器,然后再利用程序找出。
for i in range(0, img.height):
r, g, b, a = img.getpixel((0, i))
if r==g==b==115:#根据拾色器可得最左边的灰色条理的rgb值为[115,115,115]
print(i)
#运行结果为
43
44
45
46
47
48
49
50
51
下面打印出灰色条理的rgb值,因为43-51行都是一样的,我们只打印出43行的rgba值。另外我们发现灰色条理并未到最右边,因此我们只打印出rgb三个值相同的。
注意:这个图片的height和图片的width并不是像素矩阵中的行和列值。getpixel((i,j))其中i表是在图片的宽度范围,j表示在图片的高度范围。例如要想得到像素矩阵中第二行的第一列的像素的rgba值,其语句应该为getpixel((0, 1)),0为width值,1为height值。
for i in range(0, img.width):
r, g, b, a = img.getpixel((i, 43))
if r==g==b:
print(img.getpixel((i, 43)))
#运行结果:
(115, 115, 115, 255)
(115, 115, 115, 255)
(115, 115, 115, 255)
(115, 115, 115, 255)
(115, 115, 115, 255)
(109, 109, 109, 255)
(109, 109, 109, 255)
(109, 109, 109, 255)
(109, 109, 109, 255)
(109, 109, 109, 255)
(109, 109, 109, 255)
(109, 109, 109, 255)
(97, 97, 97, 255)
(97, 97, 97, 255)
(97, 97, 97, 255)
…………
(49, 49, 49, 255)
(93, 93, 93, 255)
(93, 93, 93, 255)
(93, 93, 93, 255)
(93, 93, 93, 255)
(93, 93, 93, 255)
(93, 93, 93, 255)
(93, 93, 93, 255)
(93, 93, 93, 255)
因为rgb值均一样,因为只保存r值。
save = []
start = 43 #灰色条码开始的高度
for i in range(0, img.width):
r, g, b, a = img.getpixel((i, start))
if r == g == b:
save.append(r)
print(save)
#运行结果:[115, 115, 115, 115, 115, 109, 109, 109, 109, 109, 109, 109, 97, 97, 97, 97, 97, 97, 97, 114, 114, 114, 114, 114, 114, 114, 116, 116, 116, 116, 116, 116, 116, 32, 32, 32, 32, 32, 32, 32, 103, 103, 103, 103, 103, 103, 103, 117, 117, 117, 117, 117, 117, 117, 121, 121, 121, 121, 121, 121, 121, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 121, 121, 121, 121, 121, 121, 121, 111, 111, 111, 111, 111, 111, 111, 117, 117, 117, 117, 117, 117, 117, 32, 32, 32, 32, 32, 32, 32, 109, 109, 109, 109, 109, 109, 109, 97, 97, 97, 97, 97, 97, 97, 100, 100, 100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 101, 101, 32, 32, 32, 32, 32, 32, 32, 105, 105, 105, 105, 105, 105, 105, 116, 116, 116, 116, 116, 116, 116, 46, 46, 46, 46, 46, 46, 46, 32, 32, 32, 32, 32, 32, 32, 116, 116, 116, 116, 116, 116, 116, 104, 104, 104, 104, 104, 104, 104, 101, 101, 101, 101, 101, 101, 101, 32, 32, 32, 32, 32, 32, 32, 110, 110, 110, 110, 110, 110, 110, 101, 101, 101, 101, 101, 101, 101, 120, 120, 120, 120, 120, 120, 120, 116, 116, 116, 116, 116, 116, 116, 32, 32, 32, 32, 32, 32, 32, 108, 108, 108, 108, 108, 108, 108, 101, 101, 101, 101, 101, 101, 101, 118, 118, 118, 118, 118, 118, 118, 101, 101, 101, 101, 101, 101, 101, 108, 108, 108, 108, 108, 108, 108, 32, 32, 32, 32, 32, 32, 32, 105, 105, 105, 105, 105, 105, 105, 115, 115, 115, 115, 115, 115, 115, 32, 32, 32, 32, 32, 32, 32, 91, 91, 91, 91, 91, 91, 91, 49, 49, 49, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 53, 53, 53, 53, 53, 53, 53, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 54, 54, 54, 54, 54, 54, 54, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 49, 49, 49, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 49, 49, 49, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 51, 51, 51, 51, 51, 51, 51, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 52, 52, 52, 52, 52, 52, 52, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 49, 49, 49, 49, 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 53, 53, 53, 53, 53, 53, 53, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 54, 54, 54, 54, 54, 54, 54, 44, 44, 44, 44, 44, 44, 44, 32, 32, 32, 32, 32, 32, 32, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 49, 49, 49, 49, 49, 49, 49, 93, 93, 93, 93, 93, 93, 93, 93]
除了第一个115是5个之外,最后一个93是8个之外,其他的均是7个或者是7的倍数个。因此我们间隔7个数取值。
addsave = [115] * 2 + save#在前面添加2个[115]
jingjian = [addsave[fg] for fg in range(0, len(addsave), 7)]#间隔7个取数
du = ''
for hh in jingjian:
du += chr(hh)#数字转化为ASCII码对应的符号
print(du)
运行结果:smart guy, you made it. the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]]。最后多一个“]”是因为数据序列中有8个93,应该不影响结果。下面根据给出的数据序列,再次利用ASCII码转化。
result = ''
for kk in [105, 110, 116, 101, 103, 114, 105, 116, 121]:
result += chr(kk)
print(result)
最终得运行结果为:integrity。将浏览器地址栏中的oxygen.html改为integrity.html,成功进入下一关
不定期更新,欢迎留言,敬请关注!!!
网友评论