07
第七关,好吧,提示:it's in the air. look at the letters.
然后鬼知道hockey==>oxygen,
于是url改为oxygen.html就好啦。
发现一张中间有一条灰线的图片,请过目:
好吧,我就知道这条灰线有问题。
下载,然后汇编。。。
代码如下:
from PIL import Image
im=Image.open('oxygen.png')
x,y=im.size
l=[]
k=0
for i in range(3,608,7):
#通过观察,数据从3开始,608结束;另外原始数据怕我抓瞎,每个字符重复了七遍,所以步进为7.
l.append(im.getpixel((i,y/2))[0])
s=''.join(chr(_) for _ in l)
print(s)
结果:
smart guy, you made it. the next level is [105, 110, 116, 101, 103, 114, 105, 116, 121]
接着又是故技重施,我们编译这几个ASCII码就好:
numbers = [105, 110, 116, 101, 103, 114, 105, 116, 121]
word = []
for number in numbers:
word.append(chr(number))
result=''.join(word)
print(result)
结果:
integrity
完毕~
08
今天开始第八关。
打开网址,发现是一只小蜜蜂,好吧,F12,查看代码,发现亮点:
1.<map>标签下有一个链接:../return/good.html
2.代码里有一段提示:
un: 'BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
pw: 'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'
根据1,我们试着打开链接:http://www.pythonchallenge.com/pc//return/good.html
出现登陆提示,所以2就是用户名和密码了。
百度'BZh91AY&SY'发现这是bz2压缩加密,决定解密,代码如下:
import bz2
un='BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
pw='BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'
#注意必须以字节形式进行解码
user_name=bz2.decompress(b'BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084')
pass_word=bz2.decompress(b'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08')
print('username:',user_name,'\npassword:',pass_word)
结果:
username: b'huge'
password: b'file'
完毕~
09
打开代码。发现两组数据,怀疑又是画图题,看到存在数据大于255,应该不是RGB图,又有提示first+second?不懂。。。
看完攻略,原来是连点成线,看到网页图片,恍然大悟。
不多说,代码如下:
from PIL import Image,ImageDraw
first=[
146,399,163,403,170,393,169,391,166,386,170,381,170,371,170,355,169,346,167,335,170,329,170,320,170,
310,171,301,173,290,178,289,182,287,188,286,190,286,192,291,194,296,195,305,194,307,191,312,190,316,
190,321,192,331,193,338,196,341,197,346,199,352,198,360,197,366,197,373,196,380,197,383,196,387,192,
389,191,392,190,396,189,400,194,401,201,402,208,403,213,402,216,401,219,397,219,393,216,390,215,385,
215,379,213,373,213,365,212,360,210,353,210,347,212,338,213,329,214,319,215,311,215,306,216,296,218,
290,221,283,225,282,233,284,238,287,243,290,250,291,255,294,261,293,265,291,271,291,273,289,278,287,
279,285,281,280,284,278,284,276,287,277,289,283,291,286,294,291,296,295,299,300,301,304,304,320,305,
327,306,332,307,341,306,349,303,354,301,364,301,371,297,375,292,384,291,386,302,393,324,391,333,387,
328,375,329,367,329,353,330,341,331,328,336,319,338,310,341,304,341,285,341,278,343,269,344,262,346,
259,346,251,349,259,349,264,349,273,349,280,349,288,349,295,349,298,354,293,356,286,354,279,352,268,
352,257,351,249,350,234,351,211,352,197,354,185,353,171,351,154,348,147,342,137,339,132,330,122,327,
120,314,116,304,117,293,118,284,118,281,122,275,128,265,129,257,131,244,133,239,134,228,136,221,137,
214,138,209,135,201,132,192,130,184,131,175,129,170,131,159,134,157,134,160,130,170,125,176,114,176,
102,173,103,172,108,171,111,163,115,156,116,149,117,142,116,136,115,129,115,124,115,120,115,115,117,
113,120,109,122,102,122,100,121,95,121,89,115,87,110,82,109,84,118,89,123,93,129,100,130,108,132,110,
133,110,136,107,138,105,140,95,138,86,141,79,149,77,155,81,162,90,165,97,167,99,171,109,171,107,161,
111,156,113,170,115,185,118,208,117,223,121,239,128,251,133,259,136,266,139,276,143,290,148,310,151,
332,155,348,156,353,153,366,149,379,147,394,146,399]
second=[
156,141,165,135,169,131,176,130,187,134,191,140,191,146,186,150,179,155,175,157,168,157,163,157,159,
157,158,164,159,175,159,181,157,191,154,197,153,205,153,210,152,212,147,215,146,218,143,220,132,220,
125,217,119,209,116,196,115,185,114,172,114,167,112,161,109,165,107,170,99,171,97,167,89,164,81,162,
77,155,81,148,87,140,96,138,105,141,110,136,111,126,113,129,118,117,128,114,137,115,146,114,155,115,
158,121,157,128,156,134,157,136,156,136]
im = Image.new('RGB', (400,500)) #创建图片文件
draw = ImageDraw.Draw(im) #打开绘制文件
draw.line(first+second, fill = (255,255,255), width = 2)#画图
im.show() #显示
结果:
好吧,答案就是bull~~~
完毕~
10
打开网址,很直白,问len(a[30])是多少,点击图片,发现a的前几个数字,要找规律了,怎么办呢?百度一下吧:
规律是:
1
11--- 表示前一个数“1”是 1 个 1;
21--- 表示前一个数“11”是 由 2 个 1 组成;
1211--- 表示前一个数“21”是 由 1 个 2、1 个 1 组成;
111221--- 即 11 12 21 ,表示前一个数“1211”是依次由 1 个 1,1 个 2,
2 个 1组成;
312211---即 31 22 11,表示前一个数“111221”是依次由 3 个 1,2 个 2,
1 个 1 组成;
所以,下一个数应填 13112221---即 13 11 22 21,表示前一个数“312211”是依次由 1 个 3,1 个 1,2 个 2,2 个 1 组成;
同理,再下一个数根据“13112221”填 1113213211,表示前一个数“13112221”是依次由 1 个 1,1 个 3,2 个 1,3 个 2,1 个 1 组成.
这就好办了,代码如下:
strings = ['1','11']
#计算1-30的元素
for i in range(1,31):
#计数器重置
j = 0
temp = ''
#当计数器j小于当前元素的长度时(即当前元素的长度还未计算完毕时)
while j < len(strings[i]):
count = 1
#当计数器j小于前一个元素的长度时且strings[i][j]==strings[i][j+1]
while j<(len(strings[i])-1) and (strings[i][j]==strings[i][j+1]):
j = j + 1
count = count + 1
temp = '%s%d%c' % (temp,count,strings[i][j])
j = j + 1
strings.append(temp)
print (len(strings[30]))
结果:
5808
完毕~
11
跳转链接http://www.pythonchallenge.com/pc//return/5808.html
出现一张比较模糊的图,题目为odd even,参考攻略,本题考查图像处理,按要求是将偶数行偶数位的像素提取出来构成新图~
代码如下:
from PIL import Image
im=Image.open("cave.jpg")
width=im.size[0]
height=im.size[1]
m=im.mode
s=(width//2,height//2)
even=Image.new(m,s)
for x in range(width):
for y in range(height):
pixel = im.getpixel((x, y))
even.putpixel((x//2, y//2), pixel)
odd.putpixel((x,y),pixel)
even.show()
结果如下:
evil
完毕~