khast3x / Redcloud
- среда, 31 августа 2022 г. в 00:35:16
Automated Red Team Infrastructure deployement using Docker
Early release. Follow me on Twitter to stay updated on Redcloud's development.
Quick Start - Architecture - Use-cases - Screenshots
Redcloud is a powerful and user-friendly toolbox for deploying a fully featured Red Team Infrastructure using Docker. Harness the cloud's speed for your tools. Deploys in minutes. Use and manage it with its polished web interface.
Ideal for your penetration tests, shooting ranges, red teaming and bug bounties!
Self-host your attack infrastructure painlessly, deploy your very own live, scalable and resilient offensive infrastructure in a matter of minutes.
The following demo showcases deployment of Redcloud through ssh, followed by Metasploit. We then look at Traefik and a live volume attached to Metasploit. Finally, we check that Metasploit's DB is functional with the web terminal, delete the container, and terminate Redcloud.
Setup:
# If deploying using ssh
> cat ~/.ssh/id_rsa.pub | ssh root@your-deploy-target-ip 'cat >> .ssh/authorized_keys'
# If deploying using docker-machine, and using a machine named "default"
> eval (docker-machine env default)
# Check your Python version
# Use python3 if default python version is 2.x
> python --version
Deploy:
> git clone https://github.com/khast3x/redcloud.git
> cd redcloud
> python redcloud.py
Redcloud uses PyYAML
to print the list of available templates. It's installed by default on most systems.
If not, simply run:
# Use pip3 if default python version is 2.x
> pip install -r requirements.txt
Redcloud has 3 different deployment methods:
authorized_keys
file.eval (docker-machine env deploy_target)
line to preload your env with your docker-machine, and run redcloud.py
. Redcloud should automatically detect your docker-machine, and highlight menu items relevant to a docker-machine deployment.Briefly,
redcloud.py
deploys a Portainer stack, preloaded with many tool templates for your offensive engagements, powered by Docker. Once deployed, control Redcloud with the web interface. Uses Traefik as reverse-proxy. Easy remote deploy to your target server using the system ssh
or docker-machine
.
Use the web UI to monitor, manage, and interact with each container. Use the snappy web terminal just as you would with yours. Create volumes, networks and port forwards using Portainer's simple UI.
Deploy and handle all your favorite tools and technics with the power of data-center-grade internet
In the following section, we'll be going more in-depth inside Redcloud's design concepts. You can get started without having to dive inside though.
redcloud.py
: Starts/Stops the Web interface and App Templates, using Docker and Portainer.portainer
: Portainer web interface.traefik
: Traefik reverse-proxy container to the web interface, api and files containers. Some templates have pre-configured routes for convenience. See the templates.yml
.templates
: python3 http.server
container that feeds the App Templates. Lives in an "inside" network.cert_gen
: The omgwtfssl container that generates the SSL certificates using common best practices.redcloud_files
volume. You can also access the redcloud_log
container content, protected by the same .htpasswd
as Traefik. Default credentials: admin:Redcloud
Redcloud deployment workflow is as follows:
redcloud.py
.redcloud.py
automatically:
docker
& docker-compose
on target machine.docker
& docker-compose
if absent.docker-compose
.redcloud.py
will output the URL. Head over to https://your-deploy-machine-ip/portainer.App Template deployment is as follows:
docker inspect
).bash
or sh
. Choose accordingly from the drop-down menu.Redcloud makes it easy to play around with networks and containers.
You can create additional networks with different drivers, and attach your containers as you see fit. Redcloud comes with 2 networks, redcloud_default
and redcloud_inside
.
You can share data between containers by sharing volumes. Redcloud comes with 3 volumes:
certs
: Container with the certificates generated by omgwtfssl.files
: Standard file sharing volume. For now, the files are available when browsing https://your-server-ip/files, and are served by the Traefik reverse-proxy container directly from the files
volume. A typical use-case is to attach the volume to a Metasploit container, generate your payload directly into the files
volume. You can now serve your fresh payload directly through the Traefik to file server route.logs
: Available for logs, served by the file-server too. Access requires basic auth. Default is admin:Redcloud
.If you wish to stay in your terminal to work with the deployed containers, its very easy using Docker. Keep these things in mind:
bash
, but some use sh
insteadred_
, such as red_msf-postgresql
docker exec
or attach
to interact with a container
exec
is preferred as it creates a new processattach
lands you straight on the running process, potentially killing your running containerdocker-machine
, simply type these in your local shellssh
, first ssh into your deployment target to run the following commandsTo start interacting with the desired deployed container:
> docker exec -it red_container-name /bin/bash
root@70a819ef0e87:/#
If you see the following message, it means bash
is not installed. In that case simply replace /bin/bash
with /bin/sh
:
> docker exec -it red_container-name /bin/bash
OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown
> docker exec -it red_container-name /bin/sh
#
To use docker attach
, simply run:
> docker attach red_container-name
If using attach
, the container needs to be started in interactive mode
, so as to land in a interactive shell.
Point your browser to https://your-redcloud-ip/files
.
Please refer to the files
volume for more information.
Redcloud generates a new unsigned SSL certificate when deploying.
The certificate is generated by omgwtfssl, implementing most best practices.
Once generated:
It will dump the certificates it generated into /certs by default and will also output them to stdout in a standard YAML form, making them easy to consume in Ansible or other tools that use YAML.
Certificates are stored in a shared docker volume called certs
. Your containers can access this volume if you indicate it in "+ Advanced Settings" when deploying it. The Traefik reverse-proxy container fetches the certificates directly from its configuration file. If you wish to replace these certificates with your own, simply replace them on this volume.
It also means you can share the generated certificates into other containers, such Empire or Metasploit for your reverse callbacks, or for a phishing campaign.
Most SSL related configurations can be found in traefik/traefik.toml
or the docker-compose.yml
file.
You can stop Redcloud directly from the menu.
Deployed App templates need to be stopped manually before stopping Redcloud. You can stop them using the Portainer web interface, or docker rm -f container-name
.
If you wish to force the Portainer containers running Redcloud to stop, simply run docker-compose kill
inside the redcloud/
folder.
The local and docker-machine stop option is the same, thus they are combined in the same option.
Redcloud uses Portainer to orchestrate and interface with the Docker engine. Portainer in itself is a fantastic project to manage Docker deployments remotely. Portainer also includes a very convenient template system, which is the major component for our Redcloud deployment.
Templates can be found in ./templates/templates.yml
. Portainer fetches the template file from a dedicated container (templates
).
Traefik is a wonderful "cloud-native edge router". It has replaced the previous NGINX reverse-proxy setup.
A Traefik image is built during deployment, using the Dockerfile located in traefik/Dockerfile
. It adds a .htpasswd
with admin:Redcloud
credentials.
By default, deployment spawns the following routes:
https://your-server-ip/portainer
https://your-server-ip/files
https://your-server-ip/api
Authentications are based of the .htaccess
data.
From the Traefik api web interface, you can view your deployed routes, monitor health, as well as real time metrics. Its very neat.
You can add additional labels that tell Traefik where to route traffic, using either:
traefik/traefik.toml
filedocker-compose.yml
filetemplates.yml
fileSee the official documentation for more information.
Redcloud deploys with a self-signed https certificate, and proxies all interactions with the web console through it.
However, the default network exposes your containers' ports to the outside world.
You can:
labels
to create routes with Traefik. See the docker-compose.yml
file for inspiration.Additionally:
docker
& docker-machine
installations require root privileges. You can downgrade privilege requirements following the official documentation.redcloud.py
fetches Redcloud's public IP address using icanhazip.com.Deploy Target | Status |
---|---|
Ubuntu Bionic | |
Ubuntu Xenial | |
Debian Strech |
python --version
. Redcloud needs python 3+.python3
instead of python
if on an older system.redcloud.py
requires that deployment candidate have the public key in their .ssh/authorized_keys
, and handles password-less authentication using the user's public key. This is the default configuration for most VPS workflows.eval
command as illustrated above.docker
& docker-machine
installations require root privileges. You can downgrade privilege requirements following the official documentationrm -rf /opt/portainer/data
python3-distutils
package using apt-get install python3-distutils
on debian/ubuntu base.portainer
will be unable to use its default volume location /opt/
. To solve this, open the docker-compose.yml
file, replace /opt/portainer/data:/data
with a folder with write-access, for example: /tmp/portainer/:/data
and create the /tmp/portainer
directory before running Redcloud./files/
URI./files/
URI.msfconsole
through the web interfaceAny help is appreciated. This is a side project, so it's probably missing a few bolts and screws. Above all:
You can host Redcloud on any Unix server that runs Docker.
Redcloud is intended to be used in a cloud environment, such as a simple VPS with ssh, or even an AWS EC2, GCP, etc...
A large range of cloud providers offer free credits to get familiar with their services. Many lists and tutorials cover getting free hosting credits from major vendors. This list is a good place to start.
Regarding deployment method, I personally prefer working with docker-machine as it becomes ridiculously easy to spawn new machines and manage them once you've got your cloud provider's driver setup. If you prefer using ssh
, be sure to take a look at evilsocket's shellz project to manage your keys and profiles.
Red Team Infrastructure Wiki - bluscreenofjeff
Automated Red Team Infrastructure Guide - rastamouse
Safe Red Team Infrastructure - Tim MalcomVetter
Red Baron - Coalfire Research
Rapid Attack Infrastructure - Obscurity Labs
Decker - Steven Aldinger
hideNsneak - Mike Hodges
Finally, if you wish to see your tool integrated, hit me up on Twitter. This project is maintained on my free time. Keep an eye out in the dev branch for upcoming features.
Redcloud was originally developed to make deploying training environments for infosec students easier.
If you wish to stay updated on this project: