-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
46 lines (34 loc) · 1.14 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM ubuntu:18.04
LABEL maintainer "@CMNatic <https://cmnatic.co.uk">
RUN apt-get -qq update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends -qq install \
openssh-server \
apt-utils \
sudo=1.8.21p2-3ubuntu1 && \
mkdir -p /var/run/sshd && \
mkdir -p /root/.ssh && \
echo "Packages installed"
# Lets put this user add on another layer for clarity
RUN useradd -m uogctf -s /bin/bash && \
mkdir -p /home/uogctf/.ssh && \
echo "uogctf:uogctf" | chpasswd && \
echo "uogctf user successfully added"
# Add user to sudoers
RUN echo "uogctf ALL=(ALL,!root) NOPASSWD: /bin/bash" >> /etc/sudoers && \
echo "uogctf user added to sudoers"
#Place flag
RUN echo "UOGCTF{wahey_get_rekt}" > /root/root.txt
WORKDIR /etc/ssh
# Take values from ARGS and modify sshd_config accordingly
RUN \
echo "root:uogctf" | chpasswd && \
echo "Successfully changed root password" && \
\
sed --in-place 's/^\(UsePAM\|UseDNS\)/#\1/' sshd_config && \
echo "" >> sshd_config && \
echo "UsePAM no" >> sshd_config && \
echo "UseDNS no" >> sshd_config && \
echo "SSHD updated"
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]