http://www.pythonchallenge.com/
前情提要就此略过!(被打)
想着会不会太怠惰了啊……之前差不多四,五天有一篇,最近半个月都写不出一点orz正好基友推荐了这个网站就去玩了!顺便写写记录给自己点“我还是干了点事的”的心理安慰x
0.warming up
Hint: try to change the URL address.
图片是238,尝试改成238.html,果然不对www得到提示
No... the 38 is a little bit above the 2...
于是拿python算一下2**38,进到第一关~
>>> 2**38
274877906944
1.What about making trans?
everybody thinks twice before solving this.
g fmnc wms bgblr rpylqjyrc gr zw fylb.
rfyrq ufyr amknsrcpq ypc dmp.
bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle.
sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
图片提示k->m,o->q,e->g
可能是玩ctf的原因吧……一眼就看出是个位移2的凯撒密码,解密如下:
i hope you didnt translate it by hand.
thats what computers are for.
doing it in by hand is inefficient and that's why this text is so long.
using string.maketrans() is recommended. now apply on the url.
可是string.maketrans()在py3.4以后就没有了啊
总之把网页url也凯撒一下,得到ocr.html,成功进入第二关☆
>>> import Caesar
>>> Caesar.main()
依次输入信息,密钥,模式,以逗号隔开。1为加密,2为解密,非英文保持不变
不输入密钥默认为暴力破解
map,2,1
ocr
2.ocr
recognize the characters. maybe they are in the book
but MAYBE they are in the page source.
提示很明显了,右键源代码,看到一大串字符和提示
<!--
find rare characters in the mess below:
-->
就只要从这坨特殊字符里找到英文字母就好~改成equality.html,进入第三关(。・ω・。)
>>> a='''%%$@_$^__#)^)&!_+]!*@..........'''
>>> l='abcdefghijklmnopqrstuvwxyz'
>>> b=''
>>> for i in a:
if i in l:
b+=i
>>> b
'equality'
#另附一个有点装逼的解法。。因为下一题去看的正则,真的好难orz用不来用不来
>>> import re
>>> ''.join(re.findall('[a-z]',a))
'equality'
'''
18.8.10 edit
想起这个坑,正好学了点新东西,返回来看前面的时候发现之前写的那是啥啊……
真实拿写c的思维写python了,毫不优雅(
其实也根本不用费劲复制那堆源码……公开处刑.jpg
lambda真好用,正则真好用,真香
'''
import requests
import re
url = 'http://www.pythonchallenge.com/pc/def/ocr.html'
source = requests.get(url)
pattern = re.findall('<!--(.*?)-->',source.text,re.S)
print (''.join(re.findall('[a-z]',pattern[1])))
#另一种解法,py3的filter返回迭代器所以需要转list
l='abcdefghijklmnopqrstuvwxyz'
print ("".join(list(filter(lambda x: x in l, pattern[1]))))
3.re
One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.
习惯性右键。。。又是一大坨字符串。。。老老实实去翻了正则。
http://www.jb51.net/tools/zhengze.html
#是aAAAaAAAa这样的格式
>>> a='''kAewtloYgcFQaJNhHVGxXDiQmz.......'''
>>> ''.join(re.findall('[a-z][A-Z]{3}([a-z])[A-Z]{3}[a-z]',a))
'linkedlist'
改linkedlist.html得到提示linkedlist.php,照样子改好进入第四关~
4.follow the chain
点一下图片进入链接/linkedlist.php?nothing=12345,试了几次结果Your hands are getting tired
,行吧(……)结合源码里的注释
<!-- urllib may help. DON'T TRY ALL NOTHINGS, since it will never
end. 400 times is more than enough. -->
没必要手动给nothing赋值,提示使用urllib,这里还是使用requests
时隔三个月我终于学会使用requests(……)
py -3 -m pip install requests -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
import requests
import re
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
num = '73950'
while True:
source=requests.get(url+num)
print(source.text)
num = "".join(re.findall('\d+',source.text))
if num=="":
break
print(num)
在16044,82682处甚至有两个坑(……)
Yes. Divide by two and keep going.
There maybe misleading numbers in the text. One example is 82683. Look only for the next nothing and the next nothing is 63579
and the next nothing is 66831
66831
peak.html
总之得到了下一关的地址orz
5.peak hell
日常右键源码看提示
<!-- peak hell sounds familiar ? -->
我:peak是啥,孔雀?
然后百度一下发现是山峰,英语太差害死人
然后光速卡关,对不起(……
网友评论