pythonchallenge(19-20)

来源:互联网 发布:网络信息安全事件案列 编辑:程序博客网 时间:2024/06/06 20:53
19. http://www.pythonchallenge.com/pc/hex/bin.html
import base64
 
content = open('data','rb').read()
decode_cotent = base64.b64decode(content)
 
open('1.wav','w').write(decode_cotent)
文件解码储存为wav格式后智能听到个sorry. 问"what are you apologizing for?",说明没听全。
网上说india地图陆地和海洋的颜色反了,想到字节翻转。。注意,是字节翻转,解码后的。而不是编码字符串(直接反转会解码错误)
import base64
import array
import wave
 
content = open('data','rb').read()
decode_cotent = base64.b64decode(content)
inv_content = array.array('c', decode_cotent)
inv_content.byteswap() #反转
 
f = wave.open('1.wav','wb')
f.setnchannels(1)  #写wav参数设置
f.setsampwidth(1)
f.setframerate(22050)
 
f.writeframes(inv_content.tostring())
f.close()
最后出来是idiot,也是考验听力。。

20. http://www.pythonchallenge.com/pc/hex/idiot2.html
注意连接变成了2. 图上是‘private property beyond this fence‘,下面文字却说‘but inspecting it carefully is allowed.
import urllib
 
#这样打开需要在Debug I/O中输入用户名和密码
#wp = urllib.urlopen('http://www.pythonchallenge.com/pc/hex/unreal.jpg')
 
#用户名密码直接加进
wp = urllib.urlopen('http://butter:fly@www.pythonchallenge.com/pc/hex/unreal.jpg')
 
print wp.info()
网上所查看图片的包头,即图片链接http头部信息。(info() ,返回一个httplib.HTTPMessage这个python对象,可以显示你访问的网络资源服务器的HTTP头部信息。
得到结果:
Content-Range:bytes 0-30202/2123456789 网上分析: 这看上去与所谓的“断点续传”十分相似。从这个信息知道原始图片大小有2123456789 个字节,但是目前的“unreal.jpg” 只有前面的30202 个字节,这就说明看到的“unreal.jpg”并不完整。那就先要把“unreal.jpg”下载完全才行。
import urllib
 
tom = urllib.FancyURLopener()
tom.addheader('Range','bytes=30203-')
 
wp = tom.open('http://butter:fly@www.pythonchallenge.com/pc/hex/unreal.jpg')
 
print wp.info()
print wp.read()
显示:
继续:
import urllib
 
tom = urllib.FancyURLopener()
tom.addheader('Range','bytes=30207-')
 
wp = tom.open('http://butter:fly@www.pythonchallenge.com/pc/hex/unreal.jpg')
 
print wp.info()
print wp.read()
结果:
这样做似乎太低效率了。
写了一个循环,但
我一直不知道这是什么错误。。
手动:接着出现如下信心:
stop hear!
invader!invader!
ok,invader.you are inside now.
之后就没有了,所以这里手动也没几次。
修改url为invader,出现信息:yes, that's you.
然后呢??
再看看尾文件。。我也是。。通信不熟啊。。全当学习了。。
import urllib
import re
 
tom = urllib.FancyURLopener()
tom.addheader('Range','bytes=2123456789-'
wp = tom.open('http://butter:fly@www.pythonchallenge.com/pc/hex/unreal.jpg')
 
print wp.info()
 
c = wp.read()
print c[::-1]
原来尾文件这么看。。可以猜想信息发送格式。。
(说明password是之前invader的逆序:redavni)接着:
and it is hiding at 1152983631.
从1152983631的位置接着。
得到:
保存为zip文件。
import urllib
import re
 
tom = urllib.FancyURLopener()
tom.addheader('Range','bytes=1152983631-'
wp = tom.open('http://butter:fly@www.pythonchallenge.com/pc/hex/unreal.jpg')
 
print wp.info()
 
c = wp.read()
open('1.zip','wb').write(c)
于是得到一个zip文件,文件是加了密的,密码为之前的redavni.
有一个readme:
Yes! This is really level 21 in here.
And yes, After you solve it, you'll be in level 22!

Now for the level:

* We used to play this game when we were kids
* When I had no idea what to do, I looked backwards.
直接进入第21关了




0 0
原创粉丝点击