d0r1

[dreamhack] pathtraversal 본문

dreamhack/misc

[dreamhack] pathtraversal

d0r1 2023. 11. 16. 16:57
@app.route('/get_info', methods=['GET', 'POST'])
def get_info():
    if request.method == 'GET':
        return render_template('get_info.html')
    elif request.method == 'POST':
        userid = request.form.get('userid', '')
        info = requests.get(f'{API_HOST}/api/user/{userid}').text
        return render_template('get_info.html', info=info)

@app.route('/api')
@internal_api
def api():
    return '/user/<uid>, /flag'

@app.route('/api/user/<uid>')
@internal_api
def get_flag(uid):
    try:
        info = users[uid]
    except:
        info = {}
    return json.dumps(info)

@app.route('/api/flag')
@internal_api
def flag():
    return FLAG

 

중요한 부분만 간추리면 다음과 같다.

 

flag는 /api/flag 에 존재한다고 한다

 

코드를 확인해보면, get_info를 수행할 때, {HOST}/api/user/{user_id} 를 통해 user_id에 해당 하는 파일을 불러오는 거 같다

 

그렇다면, user_id에 경로를 강제로 주입함으로써, 문제를 풀 수 있다.

 

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

[dreamhack] robocaptcha  (0) 2025.07.08
[dreamhack] Batch Checker  (1) 2024.01.09
[dreamhack] 산타 할아버지도 힘들어요  (0) 2024.01.09
[dreamhack] password in the box  (0) 2024.01.09
[dreamhack] set-int  (1) 2023.10.19