728x90
728x90
728x90
 

itsecgames.com

 

www.itsecgames.com

[사진 1]

 

[사진 2]

SSI 파일에 대한 인젝션 문제이다. First name, Last name 텍스트를 입력하면 ssii.shtml 웹페이지로 이동하고, 입력한 텍스트들이 화면에 출력된다. SSI에 대한 설명은 구글에 검색하면 좋은 자료들이 많다.

 

* OWASP Server-Side Includes (SSI) Injection

 

Server-Side Includes (SSI) Injection Software Attack | OWASP Foundation

Server-Side Includes (SSI) Injection on the main website for The OWASP Foundation. OWASP is a nonprofit foundation that works to improve the security of software.

owasp.org

 

low

 

[사진 3]
[사진 4]

SSI 지시어로 '<!--#exec cmd="cat /etc/passwd" -->'를 전달해보면 지시어가 실행된 결과를 확인할 수 있다. 이전 문제들과 마찬가지로 nc 명령어를 통해 원격 쉘 접속도 가능하다.

 

medium

[사진 5]

medium 레벨이다. low 레벨에서 사용했던 지시어를 사용하면 텍스트를 전달하면 SSI 지시어가 실행되지 않는다.

 

[사진 6]
[사진 7]

single quote, double quote 대신 backtick 문자를 사용하면 SSI 지시어를 실행할 수 있다. <!--#exec cmd=`cat /etc/passwd` -->

 

[사진 8]

서버에 생성된 ssii.shtml 파일을 보면 backtick이 잘 들어간 것을 확인할 수 있다.

 

사진 [9]

double quote를 사용하게 되면 double quote 앞에 backslash가 붙어 있는 것을 확인할 수 있다. backslash때문에 double quote가 일반 문자로 변환되어 명령어가 수행되지 않는 것이다.

 

[사진 10]

php 코드(ssii.php)를 보면 medium 레벨의 경우 security_level이 1이므로 xss_check_4() 함수에 의해 입력한 텍스트가 변환된다.

 

[사진 11]

functions_external.php 파일을 보면 xss_check_4() 함수는 php addslashes() 함수를 사용하여 텍스트를 필터링하고 있다. addslashes() 함수는 single quote, double quote, backslash, NULL 값 앞에 backslash를 붙여서 일반 문자로 변환한다.

 

* PHP addslashes() function

 

PHP: addslashes - Manual

spamdunk at home dot com, your way is dangerous on PostgreSQL (and presumably MySQL). You're quite correct that ANSI SQL specifies using ' to escape, but those databases also support \ for escaping (in violation of the standard, I think). Which means that

www.php.net

 

high

[사진 12]

high 레벨의 경우 medium 레벨처럼 backtick을 사용해도 지시어가 실행되지 않는다.

 

[사진 13

서버에 생성된 ssii.shtml 파일을 보면 "<", ">" 문자가 각각 "&lt", "&gt" 문자로 변환된 것을 확인할 수 있다.

 

[사진 14]

high 레벨의 경우 xss_check_3() 함수에 의해 입력한 텍스트가 변환된다.

 

[사진 15]

xss_check_3() 함수는 htmlspecialchars() 함수를 통해 입력한 텍스트를 HTML 엔티티로 변환한다. 따라서 SSI 지시어는 HTML 엔티티로 변환되고 실행되지 않는다.

 

* HTMl Entities

 

HTML Entities

HTML Entities Reserved characters in HTML must be replaced with character entities. HTML Entities Some characters are reserved in HTML. If you use the less than (<) or greater than (>) signs in your text, the browser might mix them with tags. Character ent

www.w3schools.com

* 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

728x90
728x90

'Wargame > bWAPP' 카테고리의 다른 글

bWAPP A1 SQL injection (GET/Select)  (0) 2020.10.28
bWAPP A1 SQL Injection (GET/Search)  (0) 2020.10.28
bWAPP A1 PHP Code Injection  (0) 2020.10.28
bWAPP A1 OS Command Injection - Blind  (0) 2020.10.28
bWAPP A1 OS command Injection  (0) 2020.10.28

+ Recent posts