TigerDemon
Webhacking.kr 39번 문제 풀이 본문
https://webhacking.kr/challenge/bonus-10/
Chellenge 39
webhacking.kr

39번 문제에 들어가면 위 사진처럼 뜬다. 이때 view-source 를 누르면 아래 코드가 나온다.
<?php
include "../../config.php";
if($_GET['view_source']) view_source();
?><html>
<head>
<title>Chellenge 39</title>
</head>
<body>
<?php
$db = dbconnect();
if($_POST['id']){
$_POST['id'] = str_replace("\\","",$_POST['id']);
$_POST['id'] = str_replace("'","''",$_POST['id']);
$_POST['id'] = substr($_POST['id'],0,15);
$result = mysqli_fetch_array(mysqli_query($db,"select 1 from member where length(id)<14 and id='{$_POST['id']}"));
if($result[0] == 1){
solve(39);
}
}
?>
<form method=post action=index.php>
<input type=text name=id maxlength=15 size=30>
<input type=submit>
</form>
<a href=?view_source=1>view-source</a>
</body>
</html>
1단게 : 백슬래시가 제거된다.
$_POST['id'] = str_replace("\\","",$_POST['id']);
2단계 : 작은 따옴표가 ' ' 로 변경된다.
$_POST['id'] = str_replace("'","''",$_POST['id']);
3단계 : 길이가 제한된다. 16번째부터 잘린다.
$_POST['id'] = substr($_POST['id'],0,15);
이 문제는 '가 ''로 바뀌는 부분에 중심을 둬야한다. 따라서 admin 입력 후 띄어쓰기를 하고 마지막에 '를 추가하면 된다.


'2026-SWLUG > 웹해킹' 카테고리의 다른 글
| Webhacking.kr 54번 문제 풀이 (0) | 2026.07.12 |
|---|---|
| Webhacking.kr 25번 문제 풀이 (0) | 2026.07.05 |
| WEBHACKING.KR 7번 풀기 (0) | 2026.05.24 |
| webhacking.kr 18번 (0) | 2026.05.13 |
| webhacking.kr 27번 (0) | 2026.05.06 |