Adapt scripts to podman. Additionally add script which pushes image to registry.
This commit is contained in:
parent
573f9e8f1a
commit
e22a7f16ce
14
README.md
14
README.md
@ -1,4 +1,4 @@
|
||||
# docker-binaryexploitation
|
||||
# podman-binexp
|
||||
Create a docker container that is purpose-built for binary exploitation using Linux CLI tooling. It is a repeatable build process and I don't need to provision a virtual machine to have all this. It ticks off Docker purists too, which is an added bonus.
|
||||
|
||||
|
||||
@ -15,10 +15,22 @@ Create a docker container that is purpose-built for binary exploitation using Li
|
||||
|
||||
## Usage
|
||||
Build the docker container: `./build.sh`
|
||||
To build and push to the registry: `PUSH=true ./build.sh`
|
||||
|
||||
Run the docker container: `./run.sh`
|
||||
|
||||
Get a shell in the container: `./shell.sh`
|
||||
|
||||
### Push to registry
|
||||
Adapt the script `push.sh` to a registry you're logged into and can push to.
|
||||
Then, to push to with tag "latest":
|
||||
```base
|
||||
./push.sh
|
||||
```
|
||||
or, you can add any tag you like
|
||||
```bash
|
||||
./push 2025-pwn-time
|
||||
```
|
||||
|
||||
## Thanks
|
||||
Thanks to https://github.com/deadbeefmonster/docker-binaryexploitation. Your base repository helped a lot!
|
||||
|
||||
40
build.sh
40
build.sh
@ -1,2 +1,40 @@
|
||||
#!/bin/sh
|
||||
docker build -t docker-binaryexploitation:ubuntu23.04 .
|
||||
|
||||
# Static configuration
|
||||
REGISTRY="gitea.slebba.net"
|
||||
REPO="seb/podman-binexp-img"
|
||||
TAG=$(date -u +%Y-%m-%d-%H%M)
|
||||
PUSH=true # Set to 'true' to push the image after build
|
||||
|
||||
IMAGE="$REGISTRY/$REPO:$TAG"
|
||||
LATEST_IMAGE="$REGISTRY/$REPO:latest"
|
||||
echo "Building image: $IMAGE"
|
||||
|
||||
# Ensure Containerfile exists
|
||||
if [ ! -f Containerfile ]; then
|
||||
echo "Error: Containerfile not found!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build the image
|
||||
if podman build -t "$IMAGE" -f Containerfile .; then
|
||||
echo "Build successful: $IMAGE"
|
||||
|
||||
# Tag the image as latest
|
||||
podman tag "$IMAGE" "$LATEST_IMAGE"
|
||||
echo "Tagged $IMAGE as $LATEST_IMAGE"
|
||||
|
||||
# Push the image if PUSH is enabled
|
||||
if [ "$PUSH" = "true" ]; then
|
||||
echo "Pushing image: $IMAGE and $LATEST_IMAGE"
|
||||
if podman push "$IMAGE" && podman push "$LATEST_IMAGE"; then
|
||||
echo "Images pushed successfully: $IMAGE, $LATEST_IMAGE"
|
||||
else
|
||||
echo "Failed to push images!" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Build failed!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
24
push.sh
Normal file
24
push.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Static configuration
|
||||
REGISTRY="gitea.slebba.net"
|
||||
REPO="seb/podman-binexp-img"
|
||||
TAG=${1:-latest} # Default to 'latest' if no tag is provided
|
||||
|
||||
IMAGE="$REGISTRY/$REPO:$TAG"
|
||||
|
||||
echo "Pushing image: $IMAGE"
|
||||
|
||||
# Check if the image exists locally
|
||||
if ! podman images | grep -q "$IMAGE"; then
|
||||
echo "Error: Image '$IMAGE' not found locally!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Push the image to the registry
|
||||
if podman push "$IMAGE"; then
|
||||
echo "Image pushed successfully: $IMAGE"
|
||||
else
|
||||
echo "Failed to push image: $IMAGE" >&2
|
||||
exit 1
|
||||
fi
|
||||
20
run.sh
20
run.sh
@ -1,2 +1,20 @@
|
||||
#!/bin/sh
|
||||
docker run --rm -v "$(pwd)/host:/host" -v "$(pwd)/logs:/logs" --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -d --name docker-binaryexploitation -i docker-binaryexploitation:ubuntu23.04
|
||||
|
||||
# Static configuration
|
||||
IMAGE="gitea.slebba.net/seb/podman-binexp-img:latest" # Adjust to the desired image tag
|
||||
CONTAINER_NAME="pwner"
|
||||
HOST_DIR="$(pwd)/host"
|
||||
LOGS_DIR="$(pwd)/logs"
|
||||
|
||||
# Ensure host and logs directories exist
|
||||
mkdir -p "$HOST_DIR" "$LOGS_DIR"
|
||||
|
||||
# Run the container
|
||||
podman run --rm \
|
||||
-v "$HOST_DIR:/host:z" \
|
||||
-v "$LOGS_DIR:/logs:z" \
|
||||
--cap-add=SYS_PTRACE \
|
||||
--security-opt seccomp=unconfined \
|
||||
-d \
|
||||
--name "$CONTAINER_NAME" \
|
||||
-i "$IMAGE"
|
||||
|
||||
15
shell.sh
15
shell.sh
@ -1,2 +1,15 @@
|
||||
#!/bin/sh
|
||||
docker exec -it docker-binaryexploitation /bin/bash
|
||||
|
||||
# Name of the running container
|
||||
CONTAINER_NAME="pwner"
|
||||
|
||||
# Check if the container is running
|
||||
if podman ps --filter "name=$CONTAINER_NAME" --format "{{.Names}}" | grep -q "^$CONTAINER_NAME$"; then
|
||||
# Attach interactively to the container
|
||||
podman exec -it "$CONTAINER_NAME" /bin/bash
|
||||
else
|
||||
echo "Error: Container '$CONTAINER_NAME' is not running." >&2
|
||||
echo "You can start the container with ./run.sh"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user