문제 코드
<?php
include "./config.php";
login_chk();
$db = sqlite_open("./db/chupacabra.db");
$query = "select id from member where id='{$_GET[id]}' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = sqlite_fetch_array(sqlite_query($db,$query));
if($result['id'] == "admin") solve("chupacabra");
highlight_file(__FILE__);
?>
공격 백터
- id
- pw
코드 설명
$db = sqlite_open("./db/chupacabra.db");
이번 문제부턴 Mysql이 아닌 Sqlite로 변경된 것으로 보인다.
$query = "select id from member where id='{$_GET[id]}' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = sqlite_fetch_array(sqlite_query($db,$query));
if($result['id'] == "admin") solve("chupacabra");
이번 문제는 공격 백터에 대한 검증이 없어서 바로 공격 백터가 쿼리문에 들어간다.
쿼리문은 id='공격 백터 id' and pw='공격 백터 pw'
인 member 테이블에 저장된 id을 반환하게 된다.
이번 문제는 그 동안 Mysql 문제를 풀었으니, Sqlite로도 SQLi 공격을 해보라는 의미로 보인다.
문제 풀이
Mysql은 SELECT id FROM member WHERE id='admin'#' and pw=''
으로 처리하여 문제를 클리어할 수 있다.
이번 문제는 Sqlite라서 Sqlite의 주석 처리로 해야한다.
SQLite의 주석 처리
- 단일 라인 주석 (Single-line comment) :
--
- 블록 주석 (Multi-line comment) :
/**/
아주 간단하게 문제 풀이를 하였다.
'워게임 > Lord of SQLInjection' 카테고리의 다른 글
[Lord of SQLInjection] banshee Write UP (0) | 2021.09.14 |
---|---|
[Lord of SQLInjection] Manticore Write UP (0) | 2021.09.13 |
[Lord of SQLInjection] Cyclops Write UP (0) | 2021.09.12 |
[Lord of SQLInjection] Godzilla Write UP (0) | 2021.09.12 |
[Lord of SQLInjection] Death Write UP (0) | 2021.09.10 |