Wargame/bWAPP

bWAPP A1 PHP Code Injection

0xe82de_ 2020. 10. 28. 23:12
728x90
728x90
728x90
 

itsecgames.com

 

www.itsecgames.com

[사진 1]
[사진 2]

PHP 코드에 인젝션하는 문제이다. 하단의 bold체로 강조되어 있는 "message"를 클릭하면 "test" 문자열이 출력된다. URL을 보면 message 파라미터 값으로 "test" 값이 전달됨을 알 수 있다. "test" 문자열을 PHP 코드에서 HTML로 출력함을 추측할 수 있다.

 

low

[사진 3]

위와 같이 ";" 세미콜론과 system() 함수를 사용하여 추가적인 명령어를 실행할 수 있다.

 

* PHP system() function

 

PHP: system - Manual

If you can't see any output or error from system(), shell_exec() etc, you could try this: array('pipe', 'r'), 1=>array('pipe', 'w'), 2=>array('pipe', 'w')), $pipes);

www.php.net

 

medium

medium 레벨이다. medium 레벨의 경우 low 레벨에서처럼 system() 함수를 사용하여 추가적인 명령을 실행할 수 없다.

 

[사진 4]

php 코드(phpi.php를 보면 medium, high 레벨의 경우 htmlspecialchars() 함수를 통해 전달받은 텍스트 값을 전부 HTML 엔티티로 변환한다. 따라서, PHP 코드에 추가 명령어를 Injection 하는 것은 매우 어려워진다.

 

* PHP htmlspecialchars() function

 

PHP: htmlspecialchars - Manual

if your goal is just to protect your page from Cross Site Scripting (XSS) attack, or just to show HTML tags on a web page (showing on the page, for example), then using htmlspecialchars() is good enough and better than using htmlentities().  A minor point

www.php.net

 

high

high 레벨의 경우 medium 레벨과 같은 이유로 Injection이 매우 어렵다.

728x90
728x90