wargame / / 2019. 1. 28. 03:13

python challenge - level 4

http://www.pythonchallenge.com/pc/def/linkedlist.php


이미지를 클릭하면  http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345 라는 주소에



and the next nothing is 44827


라고 나온다. nothing을 44827로 바꾸고 들어가보니 


and the next nothing is 45439


가 나오고 45439로 바꾸니


Your hands are getting tired and the next nothing is 94485


라며 손으로 하지말란다.



페이지 소스에 들어가니 


<!-- urllib may help. DON'T TRY ALL NOTHINGS, since it will never 

end. 400 times is more than enough. -->


라는 주석이 있는데. 아마 urllib라는 모듈을 쓰란 소리같음.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import urllib.request
 
req = urllib.request
link = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
 
number = '94485' 
 
date = req.urlopen(link + number).read()
 
try:
    while 1:
        date = req.urlopen(link + number).read()
        number = (date[24:].decode()).lstrip()
        print(date)
except:
    print('end')
cs




이렇게 돌리다보니 


중간에 갑자기 divide by two and keep going 라며 숫자를 2로 나눠주고 계속 가라고 한다.


코드를 추가해줬는데 계속 값을 가져오는 과정에서 오류를 내려고 그러는건지 문자열을 바꾼다.


귀찮아서 수동으로 계속 number값을 바꿔서 돌려주었더니 peak.html이 나옴


위 코드에서 number부분을 계속 수동으로 수정을 해주던가, 아니면 예외처리 + 정규식을 사용하여 문제를 풀던가 하면된다.


http://www.pythonchallenge.com/pc/def/peak.html



'wargame' 카테고리의 다른 글

Reversing.kr Replace  (0) 2020.08.28
python challenge - level3  (0) 2019.01.27
python challenge - level 2  (0) 2019.01.27
python challenge - level 1  (0) 2019.01.27
vortex.labs.overthewire.org@vortex1  (0) 2016.06.01
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유