Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 소프트웨어보안
- 시스템해킹
- webhacking
- CodeEngn
- WarGame
- hacking
- 비박스
- 워게임
- 알고리즘
- 순서도
- dreamhack
- 시스템
- XSS
- 네트워크보안
- TCP
- Web
- 소프트웨어
- 해킹
- network
- 네트워크
- Webhaking
- 웹
- 드림핵
- bee-box
- 모의해킹
- 리버싱
- reversing
- ftz
- System
- 웹해킹
Archives
- Today
- Total
Without a Break
[Dreamhack] xss-2 본문
[문제 파일]
vuln()
def vuln():
return render_template("vuln.html")
- vuln.html을 렌더링한다.
flag()
@app.route("/flag", methods=["GET", "POST"])
def flag():
if request.method == "GET":
return render_template("flag.html")
elif request.method == "POST":
param = request.form.get("param")
if not check_xss(param, {"name": "flag", "value": FLAG.strip()}):
return '<script>alert("wrong??");history.go(-1);</script>'
return '<script>alert("good");history.go(-1);</script>'
- GET method를 요청받았을 때, flag.html 페이지를 렌더링한다.
- POST method를 요청받았을 때, flag를 포함하고 있는 check_xss() 함수를 실행한다.
check_xss()
def check_xss(param, cookie={"name": "name", "value": "value"}):
url = f"http://127.0.0.1:8000/vuln?param={urllib.parse.quote(param)}"
return read_url(url, cookie)
- name(=flag)과 value를 인자로 받은 쿠키를 생성하여 /vuln에 접속 요청을 보낸다.
memo()
@app.route("/memo")
def memo():
global memo_text
text = request.args.get("memo", "")
memo_text += text + "\n"
return render_template("memo.html", memo=memo_text)
- memo 파라미터에 입력한 값이 text에 저장되고, 줄바꿈을 적용하여 memo_text 변수에 저장된 후 memo.html에 출력한다.
[페이지]
vuln(xss) page
- 스크립트가 우회되어 팝업창이 뜨지 않는다.
memo
- memo 파라미터의 값을 저장한 변수인 memo_text가 출력된다.
flag
- xss 파라미터에 test 입력 후 제출 시, good이라는 팝업창이 뜬다.
[풀이]
먼저, vuln 페이지에서 script 태그를 사용하지 못하는 부분을 우회할 방법을 찾아보자.
https://m.blog.naver.com/noorol/221222225861
XSS 공격 구문 분석
▣ XSS 공격 구문 분석 XSS Filter Evasion Cheat Sheet - OWASPXSS Filter Evasion ...
blog.naver.com
위 블로그를 참고하여 알아보았다. 여기선 svg 태그를 사용해 볼 것이다.
vuln 페이지에 /vuln?param=<svg/onload="alert('1')">를 입력해주면
다음과 같이 정상적으로 팝업창이 뜨게 된다.
xss 방화벽이 우회되는 것을 봤으니 이제 svg 태그를 이용하여 플래그를 찾아보자.
memo 페이지에 flag가 포함된 쿠키 값을 출력하도록 해야 하므로,
<svg/onload="location.href='/memo?memo='+document.cookie">
flag 페이지에서 위와 같이 코드를 입력하고 제출한다.
제출한 뒤, memo 페이지로 가면
다음과 같이 플래그가 출력된다.
답 : DH{3c01577e9542ec24d68ba0ffb846508f}
'Web > Wargame' 카테고리의 다른 글
[Dreamhack] csrf-1 (0) | 2022.09.24 |
---|---|
[Dreamhack] ClientSide: CSRF (0) | 2022.09.21 |
[Dreamhack] xss-1 (0) | 2022.09.21 |
[Dreamhack] ClientSide: XSS (0) | 2022.09.19 |
[Dreamhack] Cookie (0) | 2022.09.17 |