IT/webhacking

[webhacking.kr] Challenge 18

안선생 Dr.Ahn 2023. 4. 20. 16:03
728x90
반응형

old - 18

 

 

<?php
  include "../../config.php";
  if($_GET['view_source']) view_source();
?><html>
<head>
<title>Challenge 18</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
input { background:silver; }
a { color:lightgreen; }
</style>
</head>
<body>
<br><br>
<center><h1>SQL INJECTION</h1>
<form method=get action=index.php>
<table border=0 align=center cellpadding=10 cellspacing=0>
<tr><td><input type=text name=no></td><td><input type=submit></td></tr>
</table>
</form>
<a style=background:gray;color:black;width:100;font-size:9pt;><b>RESULT</b><br>
<?php
if($_GET['no']){
  $db = dbconnect();
  if(preg_match("/ |\/|\(|\)|\||&|select|from|0x/i",$_GET['no'])) exit("no hack");
  $result = mysqli_fetch_array(mysqli_query($db,"select id from chall18 where id='guest' and no=$_GET[no]")); // admin's no = 2

  if($result['id']=="guest") echo "hi guest";
  if($result['id']=="admin"){
    solve(18);
    echo "hi admin!";
  }
}
?>
</a>
<br><br><a href=?view_source=1>view-source</a>
</center>
</body>
</html>

 

주석으로 답을 알려줬다.

id='guest로 고정되어 있기 때문에, no=아무숫자나 넣고(어차피 거짓), or 뒤에 참(no=2)을 넣어서 전체가 참이 되도록 한다.

 

이 문제는 페이크가 있는데,

값을 url에 입력해서 전달해야 한다.

?no=0%09or%09no=2

사람마다 url 띄어쓰기 코드는 다르게도 작성하는 듯.

나는 그냥 tab url 코드로 작성. 

728x90
반응형