[Dreamhack] session-basic

2022. 7. 26. 10:09web웹/Dreamhack wargame

@app.route('/')
def index():
    session_id = request.cookies.get('sessionid', None) #세션아이디 저장
    try:
        # get username from session_storage 
        username = session_storage[session_id]
        # session_storage의 key 중 session_id가 존재하면 username에 session_storage[session_id]를 저장
    except KeyError:
        return render_template('index.html')

    return render_template('index.html', text=f'Hello {username}, {"flag is " + FLAG if username == "admin" else "you are not admin"}')​

문제에서 제공되는 app.py의 index 부분이다. '/'이 따라붙는 url에 연결될 때 실행된다.

세션아이디를 받아와서 session_id 변수에 저장 후, 이를 이용해 username을 설정한다.

플래그를 보여주는 조건이 결국 세션아이디이므로 세션아이디를 알아내면 된다.

 

@app.route('/admin')
def admin():
    # what is it? Does this page tell you session? 
    # It is weird... TODO: the developer should add a routine for checking privilege 
    return session_storage

'/admin'이 따라붙는 url로 접속하면 session_storage에 있는 값들을 보여주는 것으로 보인다.

 

url/admin으로 접속했을 때

엣지 브라우저 기준으로, [개발자 도구] -> [응용프로그램] -> [저장소] -> [쿠키]로 들어가서 확인해보면 현재 쿠키에 저장된

세션값과 주소가 보인다.

여기서 세션값을 우리가 직접 변경할 수 있는데, 바로 위에서 확인한 admin의 세션아이디로 변경해보겠다.

 

변경 후 /admin이 아니라 /으로 다시 접속해부면 플래그를 확인할 수 있다.

'web웹 > Dreamhack wargame' 카테고리의 다른 글

[Dreamhack] web-ssrf  (0) 2022.08.16
[Dreamhack] XSS-1  (0) 2022.08.02
[Dreamhack] session  (0) 2022.07.26
[Dreamhack] error based sql injection(+문제해결 완)  (0) 2022.07.14