Python Challenge (level 20)

URI: [url]http://www.pythonchallenge.com/pc/hex/idiot2.html[/url]
Username: butter; password: fly

说明:
得到的Zip文件就是level 21.

解题方法:
import httplib, base64

base64_login = base64.encodestring('%s:%s' % ("butter", "fly"))[:-1]
headers = {"Authorization": "Basic %s" % base64_login}
conn = httplib.HTTPConnection("www.pythonchallenge.com")

# Needless to say that normally we wouldn't know about the exact byte
# ranges yet and thus probably use infinite loops instead ...

for n in range(30203, 30314):
headers["Range"] = "bytes=%s-%s" % (n, n + 1)
conn.request("GET", "/pc/hex/unreal.jpg", "", headers)
response = conn.getresponse()
data = response.read()

if data:
print data

# We now know that our username is "invader".

for n in (2123456744, 2123456743):
headers["Range"] = "bytes=%s-%s" % (n, n + 1)
conn.request("GET", "/pc/hex/unreal.jpg", "", headers)
response = conn.getresponse()

print response.read()

# We learned that "the password is your new nickname in reverse", thus:
# "redavni". Further, that "it is hiding at 1152983631".

headers["Range"] = "bytes=1152983631-1152983632"
conn.request("GET", "/pc/hex/unreal.jpg", "", headers)
response = conn.getresponse()

h = open("data.zip", "wb")
h.write(response.read())
h.close()

# Unzip the file and read the "readme.txt" it contains.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值