wargame/pythonchallenge.com
http://www.pythonchallenge.com/pc/def/ocr.html
Sanguine
2014. 6. 3. 04:27
아래쪽의 글을 해석해보면 다음과 같다.
문자를 인식합니다. 어쩌면 그들은 책에
하지만 어쩌면 그들은 페이지 소스에 있습니다.
페이지소스를 보라는것 같다.
소스를 보면
<html> | |
<head> | |
<title>ocr</title> | |
<link rel="stylesheet" type="text/css" href="../style.css"> | |
</head> | |
<body> | |
<center><img src="ocr.jpg"> | |
<br><font color="#c03000"> | |
recognize the characters. maybe they are in the book, <br>but MAYBE they | |
are in the page source.</center> | |
<br> | |
<br> | |
<br> | |
<font size="-1" color="gold"> | |
General tips: | |
<li>Use the hints. They are helpful, most of the times.</li> | |
<li>Investigate the data given to you.</li> | |
<li>Avoid looking for spoilers.</li> | |
<br> | |
Forums: <a href="http://www.pythonchallenge.com/forums"/>Python Challenge Forums</a>, | |
read before you post. | |
<br> | |
IRC: irc.freenode.net #pythonchallenge | |
<br><br> | |
To see the solutions to the previous level, replace pc with pcc, i.e. go | |
to: http://www.pythonchallenge.com/pcc/def/ocr.html | |
</body> | |
</html> | |
<!-- | |
find rare characters in the mess below: | |
--> | |
<!-- | |
%%$@_$^__#)^)&!_+]!*@&^}@[@%]()%+$&[(_@%+%$*^@$^!+]!&_#)_*}{}}!}_]$[%}@[{_@#_^{* | |
@##&{#&{&)*%(]{{([*}@[@&]+!!*{)!}{%+{))])[!^})+)$]#{*+^((@^@}$[**$&^{$!@#$%)!@(& | |
+^!{%_$&@^!}$_${)$_#)!({@!)(^}!*^&!$%_&&}&_#&@{)]{+)%*{&*%*&@%$+]!*__(#!*){%&@++ | |
!_)^$&&%#+)}!@!)&^}**#!_$([$!$}#*^}$+&#[{*{}{((#$]{[$[$$()_#}!@}^@_&%^*!){*^^_$^ | |
.......... | |
+!@!^*@}!}&{]*#^@}_[)}#@%!_*#!$}!)[(${+^&!{[&&&*[{}+*+(#+_[}{$$)#([*!)%@^%_]#%$$ | |
(++^+&)}*_&%@#[^^+^&@_%]+$%$#$*)@!(]*+@]}%$$}$(#$&^(%[*([&]*^&}(!#{&_}^(*{(+$#}} | |
(&_+][&_@)$&$&^[_$(++$^}]&^^*(+*!&#_$]*+@!]+{%^_*+!&}@$!#^{+_#([+@(((*+)[()__}(^ | |
@)](+[$*_(]*$[[&@^(_*#(*&!^{+]_%)_)^[}@]#]%#@+^+[%{_*{!)}#$@#)_$!_(!*+#}%%}+$&$[ | |
%&]!{{%*_!*}&)}$**_{*!#%[[#]!](^^$![#[[*}%(_#^^!%))!_^@)@**@}}(%%{#*%@(((]^%^![& | |
}!)$]&($)@](+(#{$)_%^%_^^#][{*[)%}+[##(##^{$}^]#&(&*{)%)&][&{]&#]}[[^^&[!#}${@_( | |
#@}&$[[%]_&$+)$!%{(}$^$}* | |
--> 주석으로 위의 암호문에서 희귀한 문자를 찾아보란다. 그래서 다음과 같이 코딩하였다. import urllib,re def get_problem(): url="http://www.pythonchallenge.com/pc/def/ocr.html" file=urllib.urlopen(url) count=0 flag=False prob="" for line in file.readlines(): if line=="<!--\n": count+=1 if count==2: flag=True if flag: if line=="-->\n": break prob+=line return prob print "".join(re.findall("([a-zA-Z])",get_problem())) |
실행결과