Restricted shellcode challenge with bypassable SECCOMP filter via Open-Read-Write (ORW) chain.
Challenge Overview
Coding Test is a simple shellcode injection challenge that allows the user to write to an allocated buffer that is subsequently executed.
However, there are some SECCOMP constraints that we have to bypass.
Constructing ORW Chain
Since execve and execveat is blacklisted, making it impossible to spawn a shell, we can instead use an open > read > write (ORW) chain to read file contents from the remote system.
Looking at the Docker File, the flag name is obscured by appending an MD5 hash. This makes it a little difficult to get the flag by reading the file directly.
FROM ubuntu:22.04
RUN apt-get update -y
RUN apt-get install -y xinetd
RUN apt-get install -y libseccomp-dev
RUN useradd -mU ctf_user
COPY ./coding_test /home/ctf_user/coding_test
COPY ./flag /home/ctf_user/flag
COPY ./xinetd /etc/xinetd.d/ctf_user
RUN chmod 750 /home/ctf_user /home/ctf_user/coding_test
RUN chmod 440 /home/ctf_user/flag
RUN chown -R root:ctf_user /home/ctf_user
RUN md5sum /home/ctf_user/flag | awk '{print $1}' | xargs -I {} mv /home/ctf_user/flag /home/ctf_user/flag_{}
CMD ["/usr/sbin/xinetd","-dontfork"]
To circumvent this, we can use openat to get all file names from the current directory: