Skip to content

Commit 71afb10

Browse files
author
Pongsakorn Sommalai
committed
Harden flag.txt and change user
1 parent 0a900cd commit 71afb10

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ubuntu:20.04
22

33
RUN apt-get update && \
4-
apt install -y wget build-essential sudo unzip && \
4+
apt install -y wget build-essential unzip && \
55
rm -rf /var/lib/apt/lists/* && \
66
useradd -d /home/ctf/ -m -p ctf -s /bin/bash ctf && \
77
echo "ctf:ctf" | chpasswd
@@ -15,8 +15,9 @@ RUN gcc chall.c -o chall -fno-stack-protector -z execstack -no-pie
1515
RUN wget https://github.com/joewalnes/websocketd/releases/download/v0.3.0/websocketd-0.3.0-linux_amd64.zip && \
1616
unzip websocketd-0.3.0-linux_amd64.zip && \
1717
chmod +x websocketd && \
18-
chown -R root:root /home/ctf && \
1918
apt remove -y wget build-essential unzip && \
2019
apt autoremove -y
2120

21+
USER ctf
22+
2223
CMD ./start.sh

chall.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
echo $1 > ./flag.txt
4+
./chall

start.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#!/bin/sh
22

3-
echo $FLAG > ./flag.txt
4-
5-
./websocketd --binary=true --port=$PORT ./chall
3+
./websocketd --binary=true --port=$PORT ./chall.sh $FLAG

0 commit comments

Comments
 (0)