No matter how hard I try, the flag doesn’t come out.
Can anyone tell me what flags appear when I use the three codes below?
help me …
<code 1. chall.c>
(Please refer to the photo)enter image description here
<code 2. Dockerfile>
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y socat gcc
RUN useradd -d /home/ctf ctf -s /bin/bash
RUN mkdir /home/ctf
ADD ./chall.c /home/ctf/chall.c
ADD ./flag /home/ctf/flag
WORKDIR /home/ctf
RUN gcc -o chall chall.c -no-pie -z relro -O2 -fno-stack-protector
RUN chown -R root:ctf /home/ctf/chall
RUN chmod 750 /home/ctf/chall
RUN chown root:ctf /home/ctf/flag
RUN chmod 440 /home/ctf/flag
WORKDIR /home/ctf
CMD socat -T 300 TCP-LISTEN:1337,reuseaddr,fork EXEC:/home/ctf/chall,su=ctf
EXPOSE 1337
<code 3. docker compose.yaml>
services:
untrusted_compiler:
build:
context: ./
ports:
– “1337:1337”
restart: always
After making sure that the Dockerfile and docker-compose.yml files were written correctly, I built and ran the container with Docker Compose.
After that, I set the chall program to listen on port 1337 and even wrote the code for the exploit.py file.
Sik Choon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.