diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d578850..f893cf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,12 +14,12 @@ jobs: - name: Build and test run: | - docker build -t exec . - docker run --name exec exec - docker cp exec:/usr/bin/exec ./exec + docker build -t exec-suid . + docker run --name exec-suid exec-suid + docker cp exec-suid:/usr/bin/exec ./exec-suid - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: - files: ./exec + files: ./exec-suid diff --git a/Dockerfile b/Dockerfile index 8c4dc6f..fe0d64b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,18 +2,18 @@ FROM alpine:latest AS builder RUN apk add --no-cache gcc musl-dev -COPY exec.c . +COPY exec-suid.c . ENV CC="gcc -static -O3 -s" -RUN $CC -o /usr/bin/exec exec.c +RUN $CC -o /usr/bin/exec-suid exec-suid.c FROM alpine:latest RUN apk add --no-cache python3 py3-pytest py3-yaml RUN adduser -D user -COPY --from=builder /usr/bin/exec /usr/bin/exec -RUN chmod 6755 /usr/bin/exec +COPY --from=builder /usr/bin/exec-suid /usr/bin/exec-suid +RUN chmod 6755 /usr/bin/exec-suid COPY tests /tests diff --git a/README.md b/README.md index e8a8848..5801c4b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This project aims to provide a simple interface for running scripts as suid. For example, consider some `/flag` file, which has permissions `root:root 0400`, and we want non-root users to be able to read it if they know the password: ```python -#!/usr/bin/exec -- /usr/bin/python3 -I +#!/usr/bin/exec-suid -- /usr/bin/python3 -I import sys @@ -20,16 +20,16 @@ print(open("/flag").read()) Now, assuming root owns the file, root marks this script as suid (`chmod u+s`), and it will work as expected. -Without `exec`, this would not work, as the python interpreter is not marked suid, and so even if the script is, it will not be able to read the file. +Without `exec-suid`, this would not work, as the python interpreter is not marked suid, and so even if the script is, it will not be able to read the file. # Installation ```sh -wget -O /usr/bin/exec http://github.com/pwncollege/exec/releases/latest/download/exec && \ -chmod 6755 /usr/bin/exec +wget -O /usr/bin/exec-suid http://github.com/pwncollege/exec-suid/releases/latest/download/exec-suid && \ +chmod 6755 /usr/bin/exec-suid ``` -This will install the latest version of `exec` to `/usr/bin/exec`, and mark it as suid-root. +This will install the latest version of `exec-suid` to `/usr/bin/exec-suid`, and mark it as suid-root. This program is designed to be run as root, and will not work properly if it is not. > **Warning** diff --git a/exec.c b/exec-suid.c similarity index 100% rename from exec.c rename to exec-suid.c diff --git a/tests/programs/test_python_as_root_suid b/tests/programs/test_python_as_root_suid index 54849d7..1baf59b 100755 --- a/tests/programs/test_python_as_root_suid +++ b/tests/programs/test_python_as_root_suid @@ -1,4 +1,4 @@ -#!/usr/bin/exec -- /usr/bin/python3 -I +#!/usr/bin/exec-suid -- /usr/bin/python3 -I import os