일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
- OS
- 백준
- java
- 러스트
- 파이썬 알고리즘
- 오라클DB
- 알고리즘
- Rust
- 데이터베이스
- 자바 기초
- 러스트 예제
- 자바
- ubuntu
- 파이썬 챌린지
- Operating System
- Reversing
- 우분투
- 러스트 프로그래밍 공식 가이드
- Python challenge
- 운영체제
- 파이썬
- Database
- 백준 러스트
- data communication
- 오라클
- 파이썬 첼린지
- rust example
- 자바 개념
- 데이터 통신
- Python
- Today
- Total
IT’s Portfolio
[Python Challenge] Level 5 풀이 본문
The Python Challenge
What people have said about us: "These sorts of things are in my opinion the best way to learn a language.", brberg at Media Cloisters "It's the best web site of the year so far.", Andy Todd at halfcooked "Addictive way to learn the ins and outs of Python.
www.pythonchallenge.com
Python Challenge Level 5 풀이.
pronounce it => 그것을 발음
이 단서 하나만으로는 문제를 풀기 힘들 것 같다.
페이지 소스를 봐보자.
"peak hell sounds familiar?" => "peak hell의 발음이 친숙한가?"
픽 헬..
픽헬..
모르겠다
이 외에 <peakhell src="banner.p"/>라는 링크가 보인다.
들어가보자.
이게 뭘까?
파일인 것 같은데 .p 파일 확장자를 찾아봤다.
Python Pickle File 이라고 한다.
peak hell.. pickle..
픽 헬.. 피클..
banner.p를 가져와서 계속 문제를 풀어나가보겠다.
import urllib.request
import pickle
url = "http://www.pythonchallenge.com/pc/def/banner.p"
data = urllib.request.urlopen(url)
pfile = pickle.load(data)
print(pfile[0])
print(pfile[1])
결과:
굳이 pfile의 0번째 리스트와 1번째 리스트를 보지않아도 규칙을 알 수 있다.
문자와 숫자.
문자는 공백과 # 밖에 없다.
숫자는 개수를 뜻하는 듯하다.
스크립트를 짜보자.
import urllib.request
import pickle
url = "http://www.pythonchallenge.com/pc/def/banner.p"
data = urllib.request.urlopen(url)
pfile = pickle.load(data)
txt = open("checkfile.txt", "w")
data = ""
for i in range(0, len(pfile)):
for j in range(0, len(pfile[i])):
data += pfile[i][j][0]*pfile[i][j][1]
data += "\n"
txt.write(data)
결과:
URL 정답값: channel
최신화
2022.10.24
import re, pickle
from get_html_source import get_html
url = "http://www.pythonchallenge.com/pc/def/peak.html"
A = get_html(url)
with open('source.txt', 'w+') as f:
source = A.get_req().replace('\n', '')
m = re.findall('<!--(.+?)-->', source)
m2 = re.findall('[a-z]{6}.p', source)
f.write(m[0].strip()+'\n'+m2[0].strip())
A.change_url(url.replace('peak.html', m2[0]))
'''
peak hell sounds familiar ?
banner.p
'''
with open('banner.p', 'wt') as f:
f.write(A.get_req())
with open('banner.p', 'rb') as f:
pfile = pickle.load(f)
with open('source.txt', 'wt') as f:
for i in range(len(pfile)):
for j in range(len(pfile[i])):
f.write(pfile[i][j][0]*pfile[i][j][1])
f.write('\n')
Level 6으로 갈 수 있는 URL = http://www.pythonchallenge.com/pc/def/channel.html
'Security Study > Wargame Explanation' 카테고리의 다른 글
[Python Challenge] Level 7 풀이 (0) | 2022.11.11 |
---|---|
[Python Challenge] Level 6 풀이 (0) | 2022.11.09 |
[Python Challenge] Level 4 풀이 (0) | 2019.11.24 |
[Python Challenge] Level 3 풀이 (0) | 2019.11.22 |
[Python Challenge] Level 2 풀이 (0) | 2019.11.20 |