<?php
include "./config.php";
login_chk();
$db = sqlite_open("./db/poltergeist.db");
$query = "select id from member where id='admin' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = sqlite_fetch_array(sqlite_query($db,$query));
if($result['id']) echo "<h2>Hello {$result['id']}</h2>";
if($poltergeistFlag === $_GET['pw']) solve("poltergeist");// Flag is in `flag_{$hash}` table, not in `member` table. Let's look over whole of the database.
highlight_file(__FILE__);
?>
공격 백터
pw
코드 분석
$query = "select id from member where id='admin' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = sqlite_fetch_array(sqlite_query($db,$query));
if($result['id']) echo "<h2>Hello {$result['id']}</h2>";
id='admin' and pw='공격 백터 pw'인 member 변수에 저장된 id을 반환하는 쿼리문이다. 만약 쿼리문 반환 값이 있다면, hello 반환 값을 페이지에 출력한다.
if($poltergeistFlag === $_GET['pw']) solve("poltergeist");
// Flag is in `flag_{$hash}` table, not in `member` table. Let's look over whole of the database.
문제를 풀기 위해선 $poltergeistFlag와 공격 백터랑 같아야 문제가 클리어하게 된다. $poltergeistFlag은 flag_{$hash}로 되어있는 테이블에 저장되어있다고 한다.
Mysql의 information_schema.TABLES처럼 메타데이터를 이용하여 문제를 풀이하면 될 듯 싶다.
문제 풀이
인터넷에 SQLite의 information_schema의 역할을 하는 것을 검색을 해보니, sqlite_master라는 것을 찾을 수 있었다. 이를 Union을 이용하여 출력해보록 하겠다.