[BWAPP] Cross-site scripting – Reflected (GET)

2022. 8. 2. 08:01·Hacking/Web Hacking

Quest. xss 취약점이 있는지 알아봅시다. 다음 화면을 띄워보세요.

경고창을 누른 후 화면 (Welcome success 출력)


난이도 low

first name에 si, last name에 ss를 넣으니 사진과 같게 출력되었다.

alert(<script>alert("XSS")</script>)를 입력해 경고창을 출력해보겠다.

first name에 <script>alert("XSS")</script>를 입력하고 last name에 success를 입력했더니 alert 창이 뜨는 것을 확인할 수 있었다.

​

last name에 코드를 삽입해도 같은 동작을 하는 것을 확인했다.


난이도 medium

난이도 low와 같이 태그를 입력했으나 이번에는 alert 창이 뜨지 않았다.

원인을 파악하기 위해 소스코드를 살펴보았다.

보안 레벨에 대한 것은 /BWAPP/xss_get.php에 있다고 한다.

터미널창에서 해당 파일을 확인해보았다.

cd /var/www/bWAPP

vim xss_get.php

보안 레벨이 medium(1)일 경우에는 xss_check_4 함수를 실행한다.

해당 함수의 내용을 확인하기 위해 functions_external.php 파일을 읽었다.

xss_check_4() 안에서는 addslashes라는 함수가 실행된다.

addslashes 함수는 입력한 문자($data)에 들어있는 ', ", \와 NUL 앞에 \를 추가한다.

​

https://www.php.net/manual/en/function.addslashes.php

 

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

 

따라서 ', ", \를 사용하지 않고 태그를 삽입하면 alert 창을 띄울 수 있다.

<script>alert(/XSS/)</script>를 입력해보았다.

alert 창을 띄운 뒤에 success를 출력했다.


난이도 high

보안 레벨이 high(2)일 경우 xss_check_3 함수를 실행한다.

xss_check_3 함수에서는 htmlspecialchars 함수가 실행된다.

htmlspecialchars 함수는 &, ', ", <, >의 특수한 글자들을 HTML 엔티티로 변환하여 출력한다.

따라서 태그를 통한 alert()를 사용할 수 없기 때문에 XSS 공격을 성공시킬 수 없다.

​

https://www.php.net/manual/en/function.htmlspecialchars

 

PHP: htmlspecialchars - Manual

One MUST specify ENT_HTML5 in addition to double_encode=false to avoid double-encoding.The reason is that contrary to the documentation, double_encode=false will NOT unconditionally and globally prevent double-encoding of ALL existing entities. Crucially,

www.php.net

 

'Hacking/Web Hacking' 카테고리의 다른 글
  • [BWAPP] Cross-site scripting – Stored(Blog)
  • [BWAPP] Cross-site scripting – Reflected (POST)
  • [BWAPP] SQL Injection (POST/search)
  • [BWAPP] SQL Injection (GET/search)
단축키실행해보세요
단축키실행해보세요
공대생
  • 단축키실행해보세요
    Ctrl + Shift + ESC
    단축키실행해보세요
  • 전체
    오늘
    어제
    • 분류 전체보기 (171)
      • 외부 활동 (4)
      • BOJ (36)
        • Python (24)
        • C++ (12)
        • Java (0)
      • Hacking (91)
        • Crypto (4)
        • Forensics (2)
        • Mobile Hacking (5)
        • Reversing (21)
        • System (21)
        • Web Hacking (38)
      • Cloud (14)
        • Serverless (1)
        • AWS (8)
      • ML (5)
      • Data Structure (16)
      • Git (0)
      • DevOps (0)
        • Terraform (0)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    SAA
    CodeEngn
    acc
    bWAPP
    부하테스트
    ML
    AI
    pwnable
    EC2
    Dreamhack
    XPath
    자료구조
    c
    basicrce3
    Systemhacking
    Redis
    python
    backjoon
    유석종교수님
    beebox
    System
    AWS
    cloud
    Reversing
    datastructure
    SISS
    htmlinjection
    S3
    백준
    Reflected
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
단축키실행해보세요
[BWAPP] Cross-site scripting – Reflected (GET)
상단으로

티스토리툴바