![[DREAMHACK 워게임] 웹해킹_simple_sqli 문제풀이](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbUF4n1%2FbtsAM4gl6oj%2FoEF1k29XjlsU5a6S2D6r1K%2Fimg.png)
[DREAMHACK 워게임] 웹해킹_simple_sqli 문제풀이Security/Secure Coding2023. 11. 24. 14:01
Table of Contents
해당문제는 sql injection 유형이다.
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'GET':
return render_template('login.html')
else:
userid = request.form.get('userid')
userpassword = request.form.get('userpassword')
res = query_db(f'select * from users where userid="{userid}" and userpassword="{userpassword}"')
if res:
userid = res[0]
if userid == 'admin':
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>'
코드를 살펴보면 flag가 admin으로 로그인이 성공할 시 나타나는 것을 알 수 있다.
이때 쿼리문이 row query이므로 인증우회구문을 넣으면 된다.
필자의경우에는
id : admin’–
pw : 1234 를 넣었다.
반응형
'Security > Secure Coding' 카테고리의 다른 글
간편 로그인의 종류와 보안 위협 (SSO, OAuth, OIDC) (0) | 2025.04.15 |
---|---|
[웹해킹] SQL INJECTION 공격 종류 (In band / blind / out of band ) (0) | 2024.02.21 |
[DREAMHACK 워게임] 웹해킹_command-injection-1 문제풀이 (1) | 2023.11.24 |
[DREAMHACK 워게임] 웹해킹_CSRF-2 문제풀이 (2) | 2023.11.24 |
[DREAMHACK 워게임] 웹해킹_xss-2 문제풀이 (0) | 2023.11.24 |
[DREAMHACK 워게임] 웹해킹_XSS문제 풀이 (0) | 2023.11.24 |
@염염 :: 왕감자
공부하고 정리하는 기록모음