紧张,变态,又刺激的Python Challenge第17关(太值得关注)

介绍

游戏介绍

平时自己学python,大家肯定很是无聊,推荐一个很早之前的网页版python闯关游戏——Python Challenge,虽然说这个网站很早了,但是很有意思,你会发现这些游戏一点也不简单,基本都需要通过编程来解决……

有意思的是,这是个解谜游戏,所以需要你细心去发现线索,破解谜底,并且考察的知识量也不是很小,很有意思。

游戏链接:http://www.pythonchallenge.com/

界面是这样的:

点击图中Click here to get challenged开始挑战。

全解(持续更新)

Python challenge 全解(持续更新中,建议收藏)

基础知识

Python challenge基础知识与套路
刚刚写了这个,没想到突然就来了兴致,那就写完吧。
这一关累死人啊,复习了好多关卡,看来,这也是个**“期中考试”**啊!!

重点必看

第8关我们得到了一个账号和密码:huge.file,这个需要牢牢记住,因为后面的关卡,基本都需要登录。

第17关

在这里插入图片描述
貌似没什么信息,看源码:


<html>
<head>
  <title>eat?</title>
  <link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
	<br><br>
	<center>
	<font color="gold">
	<img src="cookies.jpg" border="0"/>
</body>
</html>

啥也没有,那就看图片吧。
图片中出现的小甜饼,联想到英文cookie,这就能想到cookie字段,左下角的图片熟悉吗?其实就是第四关的图片,接下来就看看第四关的cookie吧。(事实上我当时就看到了,不过看不懂)

果然得到了信息,看来还是和第四关差不多的套路。

info=you+should+have+followed+busynothing...

这里让我们循环busynothing。

import requests
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing='
nothing = '12345'
num = 0
for i in range(200):
    try:
        r = requests.get(url +nothing).text
        nothing = r.split()[-1]
        num += 1
        print(num,nothing, sep=': ')
    except:
        print('error')

这个循环很慢,那就先200吧,输出结果:

………………
116: 96070
117: 83051
118: it.
119: 72758
…………

果然有问题,那就查看一下这个吧,显示:

that’s it

好吧,没发现啥,其实我们忽略了一点,那就是cookie接下来就打印出来看看:

import requests
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing='
nothing = '12345'
cookies=[]
for i in range(118):
    try:
        r = requests.get(url +nothing)
        cookie = requests.utils.dict_from_cookiejar(r.cookies)
        cookies.append(cookie['info'])
        nothing = r.text.split()[-1]
    except:
        print('error')
print(''.join(cookies))

结果是:

BZh91AY%26SY%94%3A%E2I%00%00%21%19%80P%81%11%00%AFg%9E%A0+%00hE%3DM%B5%23%D0%D4%D1%E2%8D%06%A9%FA%26S%D4%D3%21%A1%EAi7h%9B%9A%2B%BF%60%22%C5WX%E1%ADL%80%E8V%3C%C6%A8%DBH%2632%18%A8x%01%08%21%8DS%0B%C8%AF%96KO%CA2%B0%F1%BD%1Du%A0%86%05%92s%B0%92%C4Bc%F1w%24S%85%09%09C%AE%24%90

看起来熟悉吗?其实这就是我们在第8关遇到的加密方式,使用bz2解谜

import bz2
string = b'BZh91AY%26SY%94%3A%E2I%00%00%21%19%80P%81%11%00%AFg%9E%A0+%00hE%3DM%B5%23%D0%D4%D1%E2%8D%06%A9%FA%26S%D4%D3%21%A1%EAi7h%9B%9A%2B%BF%60%22%C5WX%E1%ADL%80%E8V%3C%C6%A8%DBH%2632%18%A8x%01%08%21%8DS%0B%C8%AF%96KO%CA2%B0%F1%BD%1Du%A0%86%05%92s%B0%92%C4Bc%F1w%24S%85%09%09C%AE%24'
text= bz2.decompress(string)

报错了Invalid data stream
网上搜了之后发现这段字符需要转换一下。

import bz2
import urllib.parse as prs
string = 'BZh91AY%26SY%94%3A%E2I%00%00%21%19%80P%81%11%00%AFg%9E%A0+%00hE%3DM%B5%23%D0%D4%D1%E2%8D%06%A9%FA%26S%D4%D3%21%A1%EAi7h%9B%9A%2B%BF%60%22%C5WX%E1%ADL%80%E8V%3C%C6%A8%DBH%2632%18%A8x%01%08%21%8DS%0B%C8%AF%96KO%CA2%B0%F1%BD%1Du%A0%86%05%92s%B0%92%C4Bc%F1w%24S%85%09%09C%AE%24%90'
new_string=string.replace('+', ' ')
new_strings= prs.unquote_to_bytes(new_string)
text = bz2.decompress(new_strings)
print(text)

得到结果:

is it the 26th already? call his father and inform him that “the flowers are on their way”. he’ll understand.

熟悉吧,就是莫扎特那一关(15关)。。。因此需要打电话给莫扎特的父亲Leopold Mozart,如何打电话?phone,十三关的phone。

import xmlrpc.client
xmlrpc = xmlrpc.client.ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php')
print(xmlrpc.phone('Leopold'))

结果出来555-VIOLIN, 太遗憾了,VIOLIN依然不是最终答案,提示no! i mean yes! but …/stuff/violin.php. 再按提示改成http://www.pythonchallenge.com/pc/stuff/violin.php,出来个头像:
在这里插入图片描述
这就是百度搜到的Leopold的头像。
标题是it’s me. what do you want? 前面告诉了说call his father and inform him that “the flowers are on their way
需要传给他这句话,肯定用cookies,

import requests

headers = {'Cookie':'info=the flowers are on their way'}
url = 'http://www.pythonchallenge.com/pc/stuff/violin.php'
print(requests.get(url, headers=headers).text)

得到结果:

<html>
<head>
  <title>it's me. what do you want?</title>
  <link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
	<br><br>
	<center><font color="gold">
	<img src="leopold.jpg" border="0"/>
<br><br>
oh well, don't you dare to forget the balloons.</font>
</body>
</html>

看到了一句话:

oh well, don't you dare to forget the balloons.

试试balloons,替换得到了正确的url:

结果链接

http://www.pythonchallenge.com/pc/return/balloons.html

第18关预告

找不同
在这里插入图片描述

最后,大家不妨关注一下可怜的我。。

发布了14 篇原创文章 · 获赞 18 · 访问量 877

猜你喜欢

转载自blog.csdn.net/weixin_46283214/article/details/105543383
今日推荐