commit 3a7e6ddda1e771c84dfd1777f5555ef3bec53563 Author: bad Date: Tue May 10 18:54:42 2022 +0200 Initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1aea6b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ubuntu:latest +RUN mkdir /PWD +RUN apt-get -y update +RUN apt-get -y upgrade +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get -y install gdb gdbserver python3 python3-pip python-is-python3 libc6-i386 +RUN pip install pwntools +ADD spawn-on-host-tmux.sh /bin/spawn-on-host-tmux.sh +RUN chmod +x /bin/spawn-on-host-tmux.sh +RUN ln -s /bin/spawn-on-host-tmux.sh /bin/pwntools-terminal +WORKDIR /PWD +ENTRYPOINT ["bash"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d6c8aa --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +A small utility to spawn a podman container with pwntools and ability to spawn terminal tabs on the host terminal diff --git a/spawn-on-host-tmux.sh b/spawn-on-host-tmux.sh new file mode 100644 index 0000000..37d7827 --- /dev/null +++ b/spawn-on-host-tmux.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +echo $@ > /tmux-sock diff --git a/spawn.sh b/spawn.sh new file mode 100755 index 0000000..a3aca3f --- /dev/null +++ b/spawn.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -eou pipefail + +pipe="$(mktemp -u)" +trap "rm -f $pipe" EXIT +mkfifo "$pipe" + +label="tmux-host-container-id"="$(head -c 32 /dev/urandom | base64)" + +function interact() { + # Wait for the container to start + container_id="" + while [ -p "$pipe" ] && [ -z $container_id ]; do + container_id="$(podman container ps -f label="$label" --format "{{ .ID }}")" + done + + while [ -p "$pipe" ]; do + if read line; then + echo $line + tmux split podman exec -it "$container_id" $line + fi + done <"$pipe" +} +interact & +container_name="pwntools" +podman run --rm --security-opt seccomp=unconfined --cap-add=SYS_PTRACE --label="$label" -v $PWD:/PWD -v "$pipe":"/tmux-sock" -it "$container_name" $@