The Python Challenge 闯关笔记
The Python Challenge : http://www.pythonchallenge.com/
Level 0:
看提示图片中为2**38,计算值为274877906944。
Hint: try to change the URL address.
下一关地址:http://www.pythonchallenge.com/pc/def/274877906944.html
Level 1:
Hint 1:K->M O->Q E->G
此提示可看出是位移计算,都是位移两位
Hint 2: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.
想必是利用Hint 1的唯一算法转换字符串,得到下一关的地址信息,需要注意的是转换是在26个字母中转换的,不多说,上代码
- s = "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."
- def change_str(s):
- if s is 'y':
- return 'a'
- if s is 'z':
- return 'b'
- if s.isalpha() and s not in 'yz':
- return chr(ord(s)+2)
- return s
- ns = map(change_str, s)
- print ''.join(ns)
解密得到: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.
根据提示,使用同样的方法转换map,得到ocr
下一关地址:http://www.pythonchallenge.com/pc/def/ocr.html
Level 2:
根据提示密码藏在图片的书中,或者页面源码中,看了下图片果断F12,看到页面源码中有一大段字符串,提示找出重复最少的
- import collections
- def mycount(s):
- lit = []
- lit_num = []
- for item in s:
- if item in lit:
- continue
- lit.append(item)
- for item in lit:
- num = s.count(item)
- lit_num.append(num)
- return collections.OrderedDict(zip(lit, lit_num))
- dic = mycount(s)
- for k, v in dic.iteritems():
- print k, '=', v
由于字符是有顺序的,所以这里我使用了有序的字典,进行存储字符跟出现次数,得到结果为;equality
下一关地址:http://www.pythonchallenge.com/pc/def/equality.html
Level 3:
Hint :One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.
找到这么一个小写字母,两边都是三个大写字母,要求:xXXXxXXXx
两边都是连续的三个大写字母,所以再边上就要是小写字母,不然就不满足要求了
在哪里找这些字符呢??查看页面源码,发现有一大串字符串,一定是在这里找了。
使用正则表达式进行查找字符串,附上代码:
- regex = r"[^A-Z][A-Z]{3}[a-z][A-Z]{3}[^A-Z]"
- REGEX = re.compile(regex)
- result = REGEX.findall(s)
- print result
得到:['qIQNlQSLi', 'eOEKiVEYj', 'aZADnMCZq', 'bZUTkLYNg', 'uCNDeHSBj', 'kOIXdKBFh', 'dXJVlGZVm', 'gZAGiLQZx', 'vCJAsACFl', 'qKWGtIDCj']
取的小写字母得:linkedlist
访问:http://www.pythonchallenge.com/pc/def/linkedlist.html,得到linkedlist.php
下一关地址:http://www.pythonchallenge.com/pc/def/linkedlist.php
Level 4:
点击图片跳转页面显示:and the next nothing is 44827
查看页面源码发现: urllib may help. DON'T TRY ALL NOTHINGS, since it will never
end. 400 times is more than enough.
尝试把nothing改为44827,页面跳转显示:and the next nothing is 45439
根据提示应该是要一直访问,访问400次就的到下一关页面
- import urllib
- from bs4 import BeautifulSoup
- def challenge(noth):
- url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing={}".format(noth)
- responce = urllib.urlopen(url)
- html = responce.read()
- soup = BeautifulSoup(html, 'lxml')
- body_text = soup.find('body').text
- nothing = (body_text.split('.')).pop()
- if 'html' == nothing:
- print 'Congratulations!!!!-----------------------------------------------'
- print body_text
- else:
- print '-----------------------------------------------------------------'
- print body_text
- nothing = (body_text.split(' ')).pop()
- try:
- if isinstance(int(nothing), int):
- return challenge(nothing)
- except ValueError:
- nothing = int(noth) / 2
- print nothing
- print '--------------------------------------------------------------'
- return challenge(nothing)
查看记录得到:peak.html
下一关地址:http://www.pythonchallenge.com/pc/def/peak.html
Level 5:
这题有点坑爹,找不到突破点,百度了下,根据发音的到需要用pickle处理数据,晕....
查看源码,下载banner.p,打开看了下,确实像是pickle处理过的,使用pickle处理得到
- [[(' ', 95)], [(' ', 14), ('#', 5), (' ', 70), ('#', 5), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 6), ('#', 3), (' ', 6), ('#', 4), (' ', 3), ('#', 3), (' ', 9), ('#', 3), (' ', 7), ('#', 5), (' ', 3), ('#', 3), (' ', 4), ('#', 5), (' ', 3), ('#', 3), (' ', 10), ('#', 3), (' ', 7), ('#', 4), (' ', 1)], [(' ', 3), ('#', 3), (' ', 3), ('#', 2), (' ', 4), ('#', 4), (' ', 1), ('#', 7), (' ', 5), ('#', 2), (' ', 2), ('#', 3), (' ', 6), ('#', 4), (' ', 1), ('#', 7), (' ', 3), ('#', 4), (' ', 1), ('#', 7), (' ', 5), ('#', 3), (' ', 2), ('#', 3), (' ', 5), ('#', 4), (' ', 1)], [(' ', 2), ('#', 3), (' ', 5), ('#', 3), (' ', 2), ('#', 5), (' ', 4), ('#', 4), (' ', 3), ('#', 3), (' ', 3), ('#', 4), (' ', 4), ('#', 5), (' ', 4), ('#', 4), (' ', 2), ('#', 5), (' ', 4), ('#', 4), (' ', 3), ('#', 3), (' ', 5), ('#', 3), (' ', 3), ('#', 4), (' ', 1)], [(' ', 1), ('#', 3), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 3), ('#', 3), (' ', 4), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 6), ('#', 4), (' ', 2), ('#', 4), (' ', 1)], [(' ', 1), ('#', 3), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 10), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 7), ('#', 3), (' ', 2), ('#', 4), (' ', 1)], [('#', 4), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 5), ('#', 2), (' ', 3), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 7), ('#', 3), (' ', 2), ('#', 4), (' ', 1)], [('#', 4), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 3), ('#', 10), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 14), (' ', 2), ('#', 4), (' ', 1)], [('#', 4), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 4), ('#', 4), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 12), ('#', 4), (' ', 1)], [('#', 4), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 5), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 12), ('#', 4), (' ', 1)], [(' ', 1), ('#', 3), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 5), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 12), ('#', 4), (' ', 1)], [(' ', 2), ('#', 3), (' ', 6), ('#', 2), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 4), ('#', 4), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 3), ('#', 3), (' ', 6), ('#', 2), (' ', 3), ('#', 4), (' ', 1)], [(' ', 3), ('#', 3), (' ', 4), ('#', 2), (' ', 3), ('#', 4), (' ', 5), ('#', 4), (' ', 3), ('#', 11), (' ', 3), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 4), ('#', 3), (' ', 4), ('#', 2), (' ', 4), ('#', 4), (' ', 1)], [(' ', 6), ('#', 3), (' ', 5), ('#', 6), (' ', 4), ('#', 5), (' ', 4), ('#', 2), (' ', 4), ('#', 4), (' ', 1), ('#', 6), (' ', 4), ('#', 11), (' ', 4), ('#', 5), (' ', 6), ('#', 3), (' ', 6), ('#', 6)], [(' ', 95)]]
看到元组的第一个元素不是空格就是#,第二个元素可能是个数,尝试了下
- import pickle
- f = open('banner.p')
- l = pickle.load(f)
- print l
- print '\n'.join([''.join([p[0] * p[1] for p in item]) for item in l])
- for item in l:
- for p in item:
- s = p[0] * p[1]
- f.close()
果真是一幅图
- ##### #####
- #### ####
- #### ####
- #### ####
- #### ####
- #### ####
- #### ####
- #### ####
- ### #### ### ### ##### ### ##### ### ### ####
- ### ## #### ####### ## ### #### ####### #### ####### ### ### ####
- ### ### ##### #### ### #### ##### #### ##### #### ### ### ####
- ### #### #### ### ### #### #### #### #### ### #### ####
- ### #### #### ### #### #### #### #### ### ### ####
- #### #### #### ## ### #### #### #### #### #### ### ####
- #### #### #### ########## #### #### #### #### ############## ####
- #### #### #### ### #### #### #### #### #### #### ####
- #### #### #### #### ### #### #### #### #### #### ####
- ### #### #### #### ### #### #### #### #### ### ####
- ### ## #### #### ### #### #### #### #### #### ### ## ####
- ### ## #### #### ########### #### #### #### #### ### ## ####
- ### ###### ##### ## #### ###### ########### ##### ### ######
坑爹!坑爹!
下一关地址:http://www.pythonchallenge.com/pc/def/channel.html
Level 6:
Hint:查看页面源码,发现注释zip,可能与Zip文件有关
将channel.html改为channel.zip,还真有zip文件;
打开zip文件,看到有个readme.txt,内容如下:
welcome to my zipped list.
hint1: start from 90052
hint2: answer is inside the zip
发现其他文件名都是数字,于是采用zipfile模块处理文件,献上代码:
- import zipfile
- file_zip = zipfile.ZipFile('channel.zip')
- files = file_zip.namelist()
- def item(start):
- if start in files:
- with file_zip.open(start) as f:
- content = f.read()
- print content
- result = '{}.txt'.format(content.split(' ').pop())
- return item(result)
- else:
- result = start.split('.')
- print 'The result is: ', result[0]
- if __name__ == '__main__':
- item('90052.txt')
程序最后得到:Collect the comments.
comment??哪里来的comment,想到可能是文件的,查看到zipfile有个comment属性
于是修改程序,收集每个文件的comment,
- import zipfile
- file_zip = zipfile.ZipFile('channel.zip')
- files = file_zip.namelist()
- lst = []
- def item(start):
- if start in files:
- with file_zip.open(start) as f:
- content = f.read()
- com = file_zip.getinfo(start).comment
- lst.append(com)
- print content
- result = '{}.txt'.format(content.split(' ').pop())
- return item(result)
- else:
- result = start.split('.')
- print 'The result is: ', result[0]
- if __name__ == '__main__':
- item('90052.txt')
- result = ''.join(lst)
- print result
得到:
- ****************************************************************
- ****************************************************************
- ** **
- ** OO OO XX YYYY GG GG EEEEEE NN NN **
- ** OO OO XXXXXX YYYYYY GG GG EEEEEE NN NN **
- ** OO OO XXX XXX YYY YY GG GG EE NN NN **
- ** OOOOOOOO XX XX YY GGG EEEEE NNNN **
- ** OOOOOOOO XX XX YY GGG EEEEE NN **
- ** OO OO XXX XXX YYY YY GG GG EE NN **
- ** OO OO XXXXXX YYYYYY GG GG EEEEEE NN **
- ** OO OO XX YYYY GG GG EEEEEE NN **
- ** **
- ****************************************************************
- **************************************************************
访问:http://www.pythonchallenge.com/pc/def/hockey.html
得到:it's in the air. look at the letters.
还没完成,看到comments里有些字母,“OXYGEN”,将hockey改为oxygen得带下一关地址
下一关地址:http://www.pythonchallenge.com/pc/def/oxygen.html
持续更新
The Python Challenge 闯关笔记的更多相关文章
- the python challenge闯关记录(0-8)
0 第零关 2**38 = 274877906944 下一关的url:http://www.pythonchallenge.com/pc/def/274877906944.html 1 第一关 移位计 ...
- the python challenge闯关记录(9-16)
9 第九关 是一张图,上面有很多的黑点,查看网页源代码发现了上一关的提示: 还发现了一大串的数字 感觉又是一个使用PIL库进行图像处理的题,百度后知道要将这些点连接起来并重新画图.但是不能在原始图上修 ...
- Python Challenge 第一关
偶然在网上看到这个,PYTHON CHALLENGE,利用Python语言闯关,觉得挺有意思,就记录一下. 第0关应该算个入口吧,试了好几次才试出来,没什么代码就不写了.计算一个结果出来就行. 第一关 ...
- Python 爬虫闯关(第一关)
在学习爬虫时,遇到了一个有意思的网站,这个网站设置了几个关卡,需要经过爬虫进行闯关,随着关卡的网后,难度不断增加,在闯关的过程中需要学习不同的知识,你的爬虫水平也自然随之提高. 今天我们先来第一关,访 ...
- XSS Challenges闯关笔记
前言 做xss做疯了再来一个. 地址:https://xss-quiz.int21h.jp/ ,这个貌似是日本的一个安全研究员yamagata21做的. 做到第九关就跪了,而总共有二十关.一半都还没有 ...
- 某xss挑战赛闯关笔记
0x0 前言 在sec-news发现先知上师傅monika发了一个xss挑战赛的闯关wp([巨人肩膀上的矮子]XSS挑战之旅---游戏通关攻略(更新至18关)https://xianzhi.aliyu ...
- W3CSchool闯关笔记(Bootstrap)
该闯关内容与JS闯关衔接. 每一题的答案均在注释处, 第一关:把所有的HTML内容放在一个包含有container-fluid的class名称的div下(注意,是所有的HTML内容,style标签属于 ...
- W3CSchool实战闯关笔记(JavaScript)
//handsome /** *ugly **/ 第一关注释 // 举例 var myName; // Define myName below this line 第二关声明变量 // Setup v ...
- W3CSchool闯关笔记(JQuery)
<script> $(document).ready(function(){ }); </script> <!-- Only change code above this ...
随机推荐
- c# 单元测试 ,对静态方法(static)和私有方法(private) 进行单元测试
利用反射: /// <summary> /// 调用静态方法 /// </summary>akf /// <param name="t">类全名 ...
- DFA算法以及ios中OC实现DFA
DFA不同于苹果手机的idfa DFA全称为:Deterministic Finite Automaton,即确定有穷自动机.其特征为:有一个有限状态集合和一些从一个状态通向另一个状态的边,每条边上标 ...
- Other | 十招教你找到海量PPT模板
转载自:https://www.douban.com/note/330962457/ 问:PPT模板是什么含义? 答: 先假定你们要的是这种网上到处泛滥成灾的主题PPT吧,下面请耐心看到最后,秋叶老师 ...
- 获取手机本地IP地址
public String getLocalIpAddress() { try { for (Enumeration<NetworkInterface> en = NetworkInter ...
- Rate 评分
评分组件 基础用法 评分被分为三个等级,可以利用颜色对分数及情感倾向进行分级(默认情况下不区分颜色).三个等级所对应的颜色用过colors属性设置,而它们对应的两个阈值则通过 low-threshol ...
- TimePicker 时间选择器
用于选择或输入日期 固定时间点 提供几个固定的时间点供用户选择 使用 el-time-select 标签,分别通过star.end和step指定可选的起始时间.结束时间和步长 <el-time- ...
- (WPF)360安全卫士界面设计
点击下载 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&qu ...
- JavaScript权威指南(第六版) 初读笔记
JavaScript的5种原始类型:undefined.null.布尔值.数字和字符串. JavaScript中两个非常重要的数据类型是对象和数组. 通过方括号定义数组元素和通过花括号定义对象属性名和 ...
- Hibernate初了解
Hibernate是一个开放源代码的对象关系映射框架, 它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库. Hibernate可以应用在任何使用JD ...
- Platform区分不同平台
用于区分平台 OS 属性 表示当前的平台类型.只有 ios 与 android 两个值.如可以使用为同一个属性在不同的平台上赋不同的值 const styles = StyleSheet.create ...