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
- Web
- WarGame
- 소프트웨어
- 모의해킹
- CodeEngn
- 비박스
- TCP
- ftz
- 리버싱
- 웹해킹
- 해킹
- Webhaking
- dreamhack
- bee-box
- network
- 순서도
- 네트워크보안
- 네트워크
- XSS
- System
- 워게임
- webhacking
- 드림핵
- 웹
- hacking
- 시스템해킹
- 소프트웨어보안
- reversing
- 알고리즘
- 시스템
Archives
- Today
- Total
Without a Break
[Dreamhack] simple_sqli_chatgpt 본문

코드 분석
@app.route('/login')
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'GET':
return render_template('login.html')
else:
userlevel = request.form.get('userlevel')
res = query_db(f"select * from users where userlevel='{userlevel}'")
if res:
userid = res[0]
userlevel = res[2]
print(userid, userlevel)
if userid == 'admin' and userlevel == 0:
return f'hello {userid} flag is {FLAG}'
return f'<script>alert("hello {userid}");history.go(-1);</script>'
return '<script>alert("wrong");history.go(-1);</script>'
- GET 요청 : login.html 페이지를 렌더링
- POST 요청 : userid와 userlevel을 가져와 출력 후, userid가 admin이고 userlevel이 0일 경우에만 flag를 출력
- res 변수를 보면 userlevel='입력값'이 들어가게 되어있다.
풀이

문제 페이지의 모습이다.

Login 페이지로 들어가면 userlevel을 입력해 login할 수 있다.


0이 아닌 숫자를 입력하면 wrong이라는 문자열이 경고메세지로 출력되고,
0을 입력하면 hello guest를 출력한다.
0을 입력해도 flag가 출력되지 않는 건 userid가 admin이 아니기 때문이다.
0' and userid='admin
위와 같이 입력하면
"select * from users where userlevel=' 0' and userid='admin '"
다음과 같이 입력값이 들어가 userlevel이 0이고 userid가 admin이 되어 플래그를 찾을 수 있다.

플래그 발견!

'Web > Wargame' 카테고리의 다른 글
[Dreamhack] [wargame.kr] login filtering (0) | 2023.08.29 |
---|---|
[Dreamhack] [wargame.kr] strcmp (0) | 2023.08.29 |
[Dreamhack] command-injection-chatgpt (0) | 2023.08.28 |
[Dreamhack] ex-reg-ex (0) | 2023.08.27 |
[Dreamhack] Flying Chars (0) | 2023.08.26 |