The Python Challenge – Level 17

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

이미지를 보면 쿠키 그림이 있다. cookies.html 페이지가 존재 함을 알 수 있었고 chocolate.html 그리고 play.html이 존재한다. 하지만 마지막에 가보면 되돌아가라는 메세지 뿐이다.

다시 한번 이미지 그림을 살펴 보면 왼쪽 하단에 이전에 보았던 이미지가 있다. Level 4에서의 이미지이며 Level 4로 되돌아 가면 쿠키가 셋팅된다.

you should have followed busynothing...

busynothing의 이미지를 한참 생각하다 Level 4의 풀이를 보면 인자로 nothing인 것을 확인할 수 있었다. 이 인자를 busynothing으로 바꾸어 Level 4의 코드로 확인하여 보았다. 각 페이지 마다 쿠키가 셋팅되어 있었고 모든 쿠키를 수집하여 보니 첫 시작 부분이 많이 본 부분이다.

확인한 결과 bzip 포멧이였고 아래 코드로 bzip 파일 내용을 확인할 수 있었다.

#!C:\Python26\python.exe
import httplib, urllib, re, bz2

def gogo(number):
    conn = httplib.HTTPConnection('www.pythonchallenge.com')
    conn.request('GET', '/pc/def/linkedlist.php?busynothing=' + str(number))
    r1 = conn.getresponse()
    data1 = r1.read()
    data2 = r1.getheaders()

    cookie = re.search('.+; e', data2[2][1][5:]).group()
    cookie = cookie.replace('; e', '')
    conn.close()

    if data1.find('Yes. Divide by two and keep going.') == 0:
        return int(number) / 2, cookie
    elif data1.find('that\'s it.') == 0:
    return 31337, cookie
    else:    
        tmp = re.search('and the next busynothing is [0-9]+', data1).group()
        return re.search('[0-9]+', tmp).group(), cookie

output = ''
x, ret = gogo(12345)
output = ret
print 'Loding',
while 1:
    print '.',
    x, ret = gogo(x)
    output += ret
    if x == 31337:
    print '\n' + bz2.decompress(urllib.unquote_plus(output))
    break

메세지를 확인하여 보면 아래와 같다.

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

아버지께 전화를 걸라고 하니 이전에 풀었던 Level 13 XML 관련 문제로 풀어보았다. 먼저 mozart의 아버지 이름을 확인해보기 위해 검색하여 보니 Leopold 였다. 따라서 아래 코드를 통해 메세지를 받을 수 있었다.

#!C:\python26\python.exe
from xmlrpclib import ServerProxy
server = ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php')
print server.system.listMethods()
print server.system.methodHelp('phone')
print server.phone('Leopold')

출력 결과는 555-VIOLIN 이다. 이전 Level 13을 풀때도 뒷부분을 소문자로 입력해야 했었으니 소문자로 입력하여 접속하여 보니 아래의 주소가 나타났다.

http://www.pythonchallenge.com/pc/stuff/violin.php

이후 위 페이지에서 쿠키 문제였기 때문에 "the flowers are on their way" 로 셋팅을 해주면 아래와 같은 메세지가 나타난다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다