I spent much more time on this problem.
the information behind this pic:
1. the image from level4
2. lots of cookies
==> go into the corresponding cookies of level4 and you will find a hint:
'you+should+have+followed+busynothing...'
then repeat level 4 processes with the url (........./busynothing=....)
find the correct value
at the same time, during the loop, all pages including a cookie, try to figure out useful info.
Anyway, the code:
>>> import urllib2,cookielib,re
>>> cookies=cookielib.CookieJar()
>>> opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
>>> response=opener.open('http://www.pythonchallenge.com/pc/def/linkedlist.php')
>>> cookies
>>> value=12345
>>> match='(is) (\b+)'
>>> info=''
>>> while True:
str='http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing=%s'%value
html=urllib2.urlopen(urllib2.Request(str))
request=opener.open(str)
for item in cookies:
if item.name=='info':
info=info+item.value
cont=html.read()
res=re.findall(match,cont)
if res[0][1]==value:
break
else:
value=res[0][1]
>>> import urllib
>>> ninfo=urllib.unquote_plus(info)
>>> ninfo
'BZh91AY&SY\x94:\xe2I\x00\x00!\x19\x80P\x81\x11\x00\xafg\x9e\xa0 \x00hE=M\xb5#\xd0\xd4\xd1\xe2\x8d\x06\xa9\xfa&S\xd4\xd3!\xa1\xeai7h\x9b\x9a+\xbf`"\xc5WX\xe1\xadL\x80\xe8V<\xc6\xa8\xdbH&32\x18\xa8x\x01\x08!\x8dS\x0b\xc8\xaf\x96KO\xca2\xb0\xf1\xbd\x1du\xa0\x86\x05\x92s\xb0\x92\xc4Bc\xf1w$S\x85\t\tC\xae$\x90'
>>> binfo=bz2.decompress(ninfo)
>>> binfo
'is it the 26th already? call his father and inform him that "the flowers are on their way". he'll understand.'
>>> import xmlrpclib
>>> s=xmlrpclib.ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php')
>>> s.phone('Leopold') # Leopold is his father
'555-VIOLIN'
#then go the 'http://www.pythonchallenge.com/pc/stuff/violin.php' whose title is 'it is me, what do you what?'
>>> req=urllib2.Request('http://www.pythonchallenge.com/pc/stuff/violin.php')
>>> req.add_header('Cookie','info=the flowers are on their way')
>>> response=opener.open(req)
>>> response.read()
the answer comes out. it is 'balloons.html'
the information behind this pic:
1. the image from level4
2. lots of cookies
==> go into the corresponding cookies of level4 and you will find a hint:
'you+should+have+followed+busynothing...'
then repeat level 4 processes with the url (........./busynothing=....)
find the correct value
at the same time, during the loop, all pages including a cookie, try to figure out useful info.
Anyway, the code:
>>> import urllib2,cookielib,re
>>> cookies=cookielib.CookieJar()
>>> opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
>>> response=opener.open('http://www.pythonchallenge.com/pc/def/linkedlist.php')
>>> cookies
>>> value=12345
>>> match='(is) (\b+)'
>>> info=''
>>> while True:
str='http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing=%s'%value
html=urllib2.urlopen(urllib2.Request(str))
request=opener.open(str)
for item in cookies:
if item.name=='info':
info=info+item.value
cont=html.read()
res=re.findall(match,cont)
if res[0][1]==value:
break
else:
value=res[0][1]
>>> import urllib
>>> ninfo=urllib.unquote_plus(info)
>>> ninfo
'BZh91AY&SY\x94:\xe2I\x00\x00!\x19\x80P\x81\x11\x00\xafg\x9e\xa0 \x00hE=M\xb5#\xd0\xd4\xd1\xe2\x8d\x06\xa9\xfa&S\xd4\xd3!\xa1\xeai7h\x9b\x9a+\xbf`"\xc5WX\xe1\xadL\x80\xe8V<\xc6\xa8\xdbH&32\x18\xa8x\x01\x08!\x8dS\x0b\xc8\xaf\x96KO\xca2\xb0\xf1\xbd\x1du\xa0\x86\x05\x92s\xb0\x92\xc4Bc\xf1w$S\x85\t\tC\xae$\x90'
>>> binfo=bz2.decompress(ninfo)
>>> binfo
'is it the 26th already? call his father and inform him that "the flowers are on their way". he'll understand.'
>>> import xmlrpclib
>>> s=xmlrpclib.ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php')
>>> s.phone('Leopold') # Leopold is his father
'555-VIOLIN'
#then go the 'http://www.pythonchallenge.com/pc/stuff/violin.php' whose title is 'it is me, what do you what?'
>>> req=urllib2.Request('http://www.pythonchallenge.com/pc/stuff/violin.php')
>>> req.add_header('Cookie','info=the flowers are on their way')
>>> response=opener.open(req)
>>> response.read()
the answer comes out. it is 'balloons.html'