Skip to content

Commit

Permalink
Rename to exec-suid
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Dec 3, 2024
1 parent 9c7282a commit 14d13e6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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**
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/programs/test_python_as_root_suid
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/exec -- /usr/bin/python3 -I
#!/usr/bin/exec-suid -- /usr/bin/python3 -I

import os

Expand Down

0 comments on commit 14d13e6

Please sign in to comment.