bWAPP A3 Cross-Site-Scripting - Reflected (Eval)
itsecgames.com
www.itsecgames.com
PHP Eval 함수를 이용하여 XSS 공격을 실습하는 웹페이지이다. Eval 함수는 전달 인자를 PHP, JS 등으로 실행시켜 준다.
* PHP Eval() Function
PHP: eval - Manual
If you want to allow math input and make sure that the input is proper mathematics and not some hacking code, you can try this: I can't guarantee you absolutely that this will block every possible malicious code nor that it will block malformed code, but t
www.php.net
low
low 레벨이다. URL을 보면 GET 방식으로 data 파라미터에 Date() 값이 전달된다. 모양을 보니 PHP의 Data() 함수로 보인다.
* PHP Date() Function
PHP: date - Manual
Most spreadsheet programs have a rather nice little built-in function called NETWORKDAYS to calculate the number of business days (i.e. Monday-Friday, excluding holidays) between any two given dates. I couldn't find a simple way to do that in PHP, so I thr
www.php.net
크롬 브라우저의 개발자 도구를 통해 웹페이지 소스코드를 보면 eval 함수를 통해 Date() 함수가 작동되는 것을 확인할 수 있다.
data 파라미터의 값으로 "document.cookie" 값을 전달하면 현재 쿠키 값이 웹페이지에 출력된다. 또한 세미콜론을 붙여서 추가적으로 스크립트를 실행시킬 수 있다.
위와 같이 "); 문자를 입력하여 Eval 함수를 닫아주고 세미콜론을 통해 document.location.href 함수를 실행시킬 수 있다. document는 현재 웹페이지를 의미하고 location.href는 현재 웹페이지의 URL을 의미한다. 이 값에 새로운 URL을 전달해줌으로써 새로운 웹페이지로 리다이렉션시킨다.
위와 같이 다른 웹페이지로 리다이렉션된 것을 확인할 수 있다. 관련 공격으로 피싱 공격에 이용될 수 있겠다.
* Location href Property
Location href Property
Location href Property ❮ Location Object Example Return the entire URL (of the current page): var x = location.href; The result of x will be: document.write(location.href); --> Try it Yourself » More "Try it Yourself" examples below. Definition and Usag
www.w3schools.com
medium
medium 레벨이다. medium 레벨에서도 document.cookie 값을 전달하여 쿠키 값을 출력할 수 있다.
하지만, low 레벨과 다르게 single quote를 사용하여 웹페이지를 리다이렉션 시키는 공격은 먹히지 않는다. 웹페이지 소스코드를 보면 singlq quote, double quote 값이 HTML 엔티티 값으로 변환된 것을 확인할 수 있다. 서버에서 필터링을 하는 것으로 추측할 수 있다.
high
high 레벨이다. high 레벨의 경우 document.cookie 값을 전달해서 쿠키 값을 확인할 수 없다. medium 레벨보다 강한 필터링을 하고 있는 것 같다.
먼저 medium 레벨의 경우 htmlspecialchars() 함수로 필터링을 하고 있다. [사진 5]에서 웹페이지를 리다이렉트시키기 위해 single quote, double quote가 사용되는데, 이 값이 HTML 엔티티로 변횐되기 때문이다.
그리고 high 레벨의 경우 전달된 값이 "Date()" 문자열이 아니면 잘못된 값이라고 출력해버린다. 따라서 high 레벨에서 XSS 공격은 어렵겠다.
'Wargame > bWAPP' 카테고리의 다른 글
bWAPP A3 Cross-Site-Scripting - Reflected (Login Form) (0) | 2020.11.24 |
---|---|
bWAPP A3 Cross-Stie-Scripting - Reflected (HREF) (0) | 2020.11.23 |
bWAPP A3 Cross-Site-Scripting - Reflected (Custom Header) (0) | 2020.11.18 |
bWAPP A3 Cross-Site-Scripting - Reflected (Back Button) (0) | 2020.11.18 |
bWAPP A3 Cross-Site-Scripting - Reflected (AJAX/XML) (0) | 2020.11.17 |