The Python Challenge – Level 23

http://www.pythonchallenge.com/pc/hex/bonus.html

문제 페이지 접속 후 해당 문제 소스를 보면 아래와 같다.

<!--
TODO: do you owe someone an apology? now it is a good time to
tell him that you are sorry. Please show good manners although
it has nothing to do with this level.
-->
<html>
<head>
  <title>what is this module?</title>
  <link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<center>
<br>
<br>
<img src="bonus.jpg"> 
<!--     it can't find it. this is an undocumented module. -->
</body>
</html>

<!--
'va gur snpr bs jung?'
-->

해당 소스를 보면 모듈을 찾을 수 없다는 내용이 있으며 아래 암호화된 것으로 보이는 문자열이 존재한다.
우선 암호화 된 문자열을 해독해 보자. 암호화 된 문자열은 ROT13으로 암호화 된 것이며 아래와 같이 해독된다.

'in the face of what?'

여기서 부터는 도저히 풀지 못해 아는분께 물어보고 풀게 되었다. 지인분은 "Python 설치 폴더 아래에 어떤 모듈이 존재하며 해당 모듈 내부에 암호화 된 스트링이 존재한다" 라고 하였다. 이제 검색을 해보도록 하자.

C:\Python25\Lib>grep 'gur snpr bs' *
this.py:Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.

this.py 를 찾았다! this.py 내용은 아래와 같다.

s = """Gur Mra bs Clguba, ol Gvz Crgref

Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf orggre guna pbzcyvpngrq.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
Nygubhtu cenpgvpnyvgl orngf chevgl.
Reebef fubhyq arire cnff fvyragyl.
Hayrff rkcyvpvgyl fvyraprq.
Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.
Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.
Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.
Abj vf orggre guna arire.
Nygubhtu arire vf bsgra orggre guna *evtug* abj.
Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.
Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""

d = {}
for c in (65, 97):
    for i in range(26):
        d[chr(i+c)] = chr((i+13) % 26 + c)

print "".join([d.get(c, c) for c in s])

해당 this.py 를 실행하여 보면 아래와 같은 문자가 출력된다. 위 s 변수의 스트링 내용은 모두 ROT13으로 암호화 된 내용이였다. (왜 암호화를 해둔거지?)

C:\Python25\Lib>this.py
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

문제 페이지 소스에 있던 문자에서 암호화 된 문자가 'in the face of what?' 였으므로 'In the face of ambiguity' 내용이 눈에 띈다.

답은 ambiguity (근데 this.py 얘는 뭐하는 녀석인거지? -_- )

답글 남기기

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