Read_Flag
Read_Flag
Description
goahead를 사용하는 웹 서비스 입니다.
주석으로 감싸진 FLAG를 획득하세요. 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[Dockerfile]
FROM ubuntu:18.04
# Install prereqs
RUN apt update && apt install -y wget git make gcc
# Setup goahead
WORKDIR /goahead
RUN git clone https://github.com/embedthis/goahead-gpl.git
WORKDIR /goahead/goahead-gpl
RUN git checkout v4.1.4
## Build/install
RUN make ME_GOAHEAD_SSL=0 ME_COM_SSL=0 && make install
# Copy in content files
COPY ./deploy/www /var/www/goahead
COPY ./deploy/goahead /etc/goahead/
WORKDIR /etc/goahead/
COPY ./deploy/start.sh .
CMD ["./start.sh"]
goahead 4.1.4 버전을 사용하는 웹 서비스이다.
flag는 /jwt/flag.jwt 경로로 접속하면 아래 처럼 주석으로 flag가 주석으로 감싸져있다
1
2
3
4
5
6
<html>
<body>
<h1>Can you see flag?</h1>
<% write("read me"/*this is flag [**FLAG**]*/); %>
</body>
</html>
jst : Javascript template
주석으로 처린된 부분을 확인하기 위해서는 소스코드를 직접 가져오거나 볼 수 있는 취약점이 있어야한다.
분석
관련해서 goahead github에 패치된 취약점 목록을 정리한 Security Alert이 있다.
https://github.com/embedthis/goahead/issues/99
여기서 보면 goahead 4 버전 취약점이 있는 Incorrect handler serving content에 관련된 내용이 있다.
해당 내용에서는 아래처럼 “ . “ 을 인코딩하여 %2E로 입력할경우 jst 파일이 적절히 처리되지 않고 내용이 그대로 출력되는 취약점이 명시되어있다.
해당 내용을 따라서 취약점을 공격해보면 아래 처럼 주석에 둘러쌓인 flag가 출력되는것을 볼 수 있다.
This post is licensed under CC BY 4.0 by the author.


