2016.6.8
心血来潮决定攻略Python Challenge,不知道什么时候能通(fang)关(qi)嗯
话说在Google的帮助下,应该能通关吧,恩,立个flag
http://www.pythonchallenge.com/
挑战开始
http://www.pythonchallenge.com/pc/def/0.html
2016.6.9
先吐个槽,csdn这个博客好难用啊。。。不能随手插图片不说,这个什么是个什么鬼啊,我昨天晚上发出去之后审核了一个多小时,行不行啊。。。
算了,感觉更几关然后写作业去了
第0关
http://www.pythonchallenge.com/pc/def/0.html
我上课做这个的时候一定是没睡醒,这个看着怎么也不像238啊,显然是2^38……
pow(2,38)
得到结果274877906944L。去掉无用的L,进入下一关
第1关
http://www.pythonchallenge.com/pc/def/map.html
明显是把字母加2嘛,g fmnc翻译成i hope,但是不可能手翻,代码如下:
chr(ord(ch)+2)<span style="white-space:pre"> </span># ch为每一个字符
需要考虑的条件是ch为字母,且若翻译过后大于'z'则需减去26 。 不难得到结果 "ocr"
第2关
http://www.pythonchallenge.com/pc/def/ocr.html
MAYBE they are in the page source,显然答案在网页的源码里啊
</body>
</html>
<!--
find rare characters in the mess below:
-->
<!--
%%$@_$^__#)^)&!_+]!*@&^}@[@%]()%+$&[(_@%+%$*^@$^!+]!&_#)_*}{}}!}_]$[%}@[{_@#_^{*
@##&{#&{&)*%(]{{([*}@[@&]+!!*{)!}{%+{))])[!^})+)$]#{*+^((@^@}$[**$&^{$!@#$%)!@(&
+^!{%_$&@^!}$_${)$_#)!({@!)(^}!*^&!$%_&&}&_#&@{)]{+)%*{&*%*&@%$+]!*__(#!*){%&@++
!_)^$&&%#+)}!@!)&^}**#!_$([$!$}#*^}$+&#[{*{}{((#$]{[$[$$()_#}!@}^@_&%^*!){*^^_$^
]@}#%[%!^[^_})+@&}{@*!(@$%$^)}[_!}(*}#}#___}!](@_{{(*#%!%%+*)^+#%}$+_]#}%!**#!^_
)@)$%%^{_%!@(&{!}$_$[)*!^&{}*#{!)@})!*{^&[&$#@)*@#@_@^_#*!@_#})+[^&!@*}^){%%{&#@
@{%(&{+(#^{@{)%_$[+}]$]^{^#(*}%)@$@}(#{_&]#%#]{_*({(])$%[!}#@@&_)([*]}$}&${^}@(%
(%[@%!}%*$}(*@)}){+@(%@*$&]*^*}*]&$[}*]%]+*}^!}*$^^_()#$^]++@__){&&+((#%+(&+){)$
%&&#($[[+##*%${)_!+{_[})%++)$#))]]]$]@]@($+{&%&%+!!!@]_]+])^*@$(@#${}}#}{%}#+{(@
后边还有很多,就不都粘在这了。看这意思是要在这堆字符里找到出现次数最少的.
代码部分先跳过吧,码几个字睡觉了。。。上边这题的结果是equality
第3关
http://www.pythonchallenge.com/pc/def/equality.html
连网页title都提示用re了,那就用吧。核心语句:
exp = re.compile('[^A-Z][A-Z]{3}[a-z][A-Z]{3}[^A-Z]')
得到结果linkedlist。话说我第一次看成linkedin了我会说。。。
第4关
http://www.pythonchallenge.com/pc/def/linkedlist.html
2016.6.11更新
按照提示,地址改为http://www.pythonchallenge.com/pc/def/linkedlist.php
不知道干什么,依旧查看源码
<html>
<head>
<title>follow the chain</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<!-- urllib may help. DON'T TRY ALL NOTHINGS, since it will never
end. 400 times is more than enough. -->
<center>
<a href="linkedlist.php?nothing=12345"><img src="chainsaw.jpg" border="0"/></a>
<br><br><font color="gold"></center>
Solutions to previous levels: <a href="http://wiki.pythonchallenge.com/"/>Python Challenge wiki</a>.
<br><br>
IRC: irc.freenode.net #pythonchallenge
</body>
</html>
发现图片带个链接,
linkedlist.php?nothing=12345
点开,页面显示
and the next nothing is 44827
那我就把url里的12345改成44827呗,
and the next nothing is 45439
继续,
Your hands are getting tired and the next nothing is 94485
这意思是不让我手动复制粘贴了呗,那就用脚本实现数字的提取和页面的访问
while True:
text = urllib.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=' + nothing).read()
print(text)
words = text.split(' ')
nothing = words[-1]
反正运行速度也不快,我可以一直盯着访问结果,中间有几个不那么老实的页都被我发现了,最终得到结果peak.html
第5关
http://www.pythonchallenge.com/pc/def/peak.html