목표 : 코드 독해를 통한 필터링 우회
제출칸과 소스가 있다
<?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>
PHP
복사
\ 가 들어오면 공백으로, ‘ 가 들어오면 ‘’로 변환한다.
입력이 길이 15를 넘으면 잘라낸다.
그래놓고 id=’ 으로 ‘을 하나 쓰고 있다.
‘를 쓰고 싶으니 15자를 맞추면 ‘’ 잘려나가지 않을까
참이기만 하면 되니까 admin을 Id에 넣는다 생각하고 15자를 맞추자
admin ‘