Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Building and running

**Running challenge**
Make sure you are in the `sol` directory and run the following command:

```bash
./run.sh
```
This will build the `challenge07` docker and run it. Afterwards, the `vuln`
executable will be copied to the `sol` directory and the `exploit.py` script
will be executed.
Cleanup will be done automatically after the script is finished.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# Build the Docker image from the correct directory

Check failure on line 2 in chapters/exploitation-techniques/shellcodes/drills/07-challenge-shellcode-on-stack/sol/run.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 2
cd ..
docker build -f src/Dockerfile -t challenge07 .

# Run container in background
docker run -d --name challenge07 -p 31345:31345 challenge07

# Copy the binary from the container for local analysis
docker cp challenge07:/app/vuln sol/vuln

# Navigate to the sol directory and run the exploit
cd sol
python3 exploit.py

# Cleanup: Remove the local copy of the binary and stop the container
rm -f vuln
docker stop challenge07
docker rm -f challenge07

Check failure on line 19 in chapters/exploitation-techniques/shellcodes/drills/07-challenge-shellcode-on-stack/sol/run.sh

View workflow job for this annotation

GitHub Actions / Checkpatch

WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add ending newline.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Build Stage
FROM gcc AS builder
WORKDIR /build

# Copy only the content from the src directory
COPY src/ .

RUN make

# Runtime Stage
FROM python:3.9-slim
WORKDIR /app

RUN apt-get update && \
apt-get install -y --no-install-recommends binutils cpp && \
rm -rf /var/lib/apt/lists/* && \
pip install --no-cache-dir pwntools

ENV TERM=xterm

COPY --from=builder /build/vuln /app/vuln
COPY sol/exploit.py /app/exploit.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you copy the exploit?


# Expose port 31345
EXPOSE 31345

# Run the vulnerable binary
CMD ["/app/vuln"]