Tips and QOL tricks for mitre/caldera.
You can either follow along this guide section by section, or clone the repo to use the scripts on your system.
Please note: These steps have been tested only on Ubuntu 22.04 LTS
- Update & install required system packages
sudo apt update && sudo apt upgrade -y && sudo apt install build-essential python3-dev python3-venv git snapd -y
- Ensure Go is installed with
go version. If not installed, install it with
sudo snap install go --classic
- Ensure UPX is installed with
upx --version. If not installed, install it with
sudo snap install upx
- Ensure NodeJS 16+ is installed with
node -v. If not installed, install the LTS version with
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash && source ~/.bashrc && nvm install --lts
-
Clone Caldera repo to /opt/caldera
sudo mkdir /opt/caldera && sudo chown -R $(whoami):$(whoami) /opt/caldera && cd /opt/ && git clone https://github.com/mitre/caldera.git --recursive -
Create and activate virtual environment
cd /opt/caldera && python3 -m venv .venv && source .venv/bin/activate -
Install required python modules
pip install setuptools wheel && pip install pyminizip donut-shellcode && pip install -r requirements.txt -
Run caldera server for the first time
cd /opt/caldera/ && python3 server.py --buildKeep note the passwords & api keys. If only testing or it's temporary, you can add the --insecure flag
python3 server.py --build --insecureand use the default red/admin credentials.Navigate to http://localhost:8888 to launch caldera and login with the creds you noted earlier.
To run caldera again after the first build, the --build flag is not required, and make sure you have activated the virtual environment with
source .venv/bin/activatebefore starting the server.
Make sure caldera is not running before continuing
-
This sed command enables the emu plugin in the local.yml config file. If using the --insecure flag, make sure you run the same command on the default.yml file too
cd /opt/caldera/ sed -i '/- training/a\- emu' conf/local.ymlcd /opt/caldera/ sed -i '/- training/a\- emu' conf/default.yml -
Start caldera to download the emu plugin repo. If using venv, make sure you activate the environment first with
source .venv/bin/activatecd /opt/caldera/ && python3 server.py --buildOnce caldera fully starts (after the CALDERA banner), stop the server process with CTRL+C.
-
Run the download_payloads.sh file to download the required payloads and decrypt malware
cd plugins/emu && ./download_payloads.sh && python3 data/adversary-emulation-plans/sandworm/Resources/utilities/crypt_executables.py -i ./ -p malware --decrypt -
Restart and re-build caldera to activate emu abilities & adversaries
cd /opt/caldera/ && python3 server.py --build
Make sure caldera is not running before continuing
- (optional by highly recommended) Backup current installation to a
tar.gzcompressed filetar -czvf ~/caldera-$(date +%m-%d-%Y).tar.gz /opt/caldera - Update to the latest code on github
cd /opt/caldera/ git pull - Start caldera with the
--buildflag to rebuild the cache. If using venv, make sure you activate the environment first withsource .venv/bin/activate.cd /opt/caldera/ && python3 server.py --build
- Ensure tmux is installed with
tmux -V. If not, install it withsudo apt update && sudo apt install tmux - Start a tmux session named
calderatmux new-session -d -s caldera 'cd /opt/caldera/ && source .venv/bin/activate && python3 server.py' - To verify if the session is running, run
tmux ls. To attach to the session runtmux attach-session -t caldera. To disconnect from a tmux session and place it in the background, pressCTRL+BthenD. To kill the caldera a tmux session, runtmux kill-session -t caldera
You must already have installed tmux as per section tmux
- If you haven't done so already, create a log file
sudo touch /var/log/caldera.log && sudo chown $(whoami):$(whoami) /var/log/caldera.log - Create a
caldera.servicefile in/etc/systemd/system/sudo echo "[Unit] Description=Caldera Adversary Emulation Platform After=network.target [Service] Type=forking User=${SUDO_USER:-$(whoami)} WorkingDirectory=/opt/caldera ExecStart=/usr/bin/tmux new-session -d -s caldera 'cd /opt/caldera && source .venv/bin/activate && python3 server.py' Restart=always RestartSec=3 StandardOutput=append:/var/log/caldera.log StandardError=append:/var/log/caldera.log [Install] WantedBy=multi-user.target" | sudo tee /etc/systemd/system/caldera.service > /dev/null && sudo chmod 644 /etc/systemd/system/caldera.service - Set the permissions for
caldera.servicesudo chmod 644 /etc/systemd/system/caldera.service - Reload systemd
sudo systemctl daemon-reload - Enable the service to start on boot
sudo systemctl enable caldera.service - Start the service
Troubleshooting:
sudo systemctl start caldera.service
- You can check the status of the service with
sudo systemctl status caldera.serviceor list the current tmux sessions withtmux lsto see if the caldera session is running. - To disable the service, run
sudo systemctl disable caldera.service. - To stop the service, run
sudo systemctl stop caldera.service. - If you change
caldera.service, make sure to reload systemd withsudo systemctl daemon-reloadprior to restarting the service withsudo systemctl restart caldera.service - To view the log file, run
cat /var/log/caldera.log
Clone this repo with git clone https://github.com/endiz/Caldera-Tips.git to download the scripts to your server before proceeding.
Use this script to stop caldera service, backup, and restart the service
You must have already created a service per section Run caldera at system boot - systemd
- Make the backup script executable
chmod +x scripts/backup_caldera.sh - Run backup script
sudo ./scripts/backup_caldera.sh - (optional but highly recommended) Run backup script nightly at 4am EDT with a cron job
sudo cp scripts/backup_caldera.sh /usr/local/sbin/backup_caldera.sh sudo chmod +x /usr/local/sbin/backup_caldera.sh echo "# Caldera Adversary Emulation Platform 0 4 * * * root /usr/local/sbin/backup_caldera.sh" | sudo tee -a /etc/crontab > /dev/null
Use this script to install all dependencies, create a virtual environment, install caldera with default plugins, create and start the caldera service, and create a caldera backup cron job and log. This script has only been tested with a fresh install of Ubuntu 22.04 OS. Other OS's based on debian may work.
- Make the backup script executable
chmod +x scripts/install_caldera.sh - Run install script
Check
sudo ./scripts/install_caldera.sh/var/log/caldera_install.logfor details of installation.
Jupyter Notebook to interact with caldera using the API