문제
https://dreamhack.io/wargame/challenges/266/
session
쿠키와 세션으로 인증 상태를 관리하는 간단한 로그인 서비스입니다. admin 계정으로 로그인에 성공하면 플래그를 획득할 수 있습니다. Reference Background: Cookie & Session
dreamhack.io
풀이
session-basic의 응용편이다.
코드를 보자.
admin이어야지 flag 값을 볼 수 있다.
def index():
session_id = request.cookies.get('sessionid', None)
try:
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"}')
admin의 sessionid는 랜덤한 1바이트의 hex값이다.
즉, 00 ~ ff 중 하나이다.
if __name__ == '__main__':
import os
session_storage[os.urandom(1).hex()] = 'admin'
print(session_storage)
app.run(host='0.0.0.0', port=8000)
이정도의 길이면, brute-force공격이 가능하다.
login 후, index페이지에 넘어가기 전 /get 요청 시에 brute-force 공격을 해보자.
Burp > Intruder
아래와 같이 공격할 문자열 선택
2) Brute forcer : 특정 Character set에서 문자의 조합을 통하여 특정 길이의 문자 페이로드를 생성한다.
(type을 Simple List할 경우에는 00~ff까지의 내용이 적혀있는 txt파일을 올리면 된다.)
3) 0~9, a~f
유효한 값은 응답값이 다르기 때문에 Length가 다른것을 확인
아래와 같이 나오면 성공이다 :)
'Wargame > Web' 카테고리의 다른 글
[Dreamhack] sql injection bypass WAF (0) | 2023.05.24 |
---|---|
[Dreamhack] file-csp-1 (0) | 2022.07.06 |
[Dreamhack] File Vulnerability Advanced for linux (0) | 2022.06.23 |
[Dreamhack] CSRF Advanced (0) | 2022.06.22 |
[Dreamhack] csrf-2 (0) | 2022.06.22 |
댓글