AD Privesc with Empire
  • SANS Workshop: Active Directory Privilege Escalation with Empire!
  • Installing the environment
    • AWS
    • Terraform
    • Ansible
    • Empire
    • Dependency setup script
  • Lab 1: Environment Orientation and Spinning up
  • Lab 2: Empire Setup and Initial Agent
  • Lab 3: Kerberoasting, Lateral Movement and DCSyncing
  • Lab 4: Hopping Trusts - Parent Child and Tree-Root
Powered by GitBook
On this page
  1. Installing the environment

Dependency setup script

You could run the following bash script as normal user to automate installation of all dependencies - you will still need to setup your own AWS account though :D

#!/bin/bash

# Ensure the script is not run as root
if [ "$EUID" -eq 0 ]; then
  echo "[ERROR] This script must not be run as root. Please run it with sudo." >&2
  exit 1
fi

# Function to check internet connectivity
check_internet() {
  echo "Checking internet connectivity..."
  if ping -c 1 google.com &>/dev/null; then
    echo "Internet connectivity verified."
  else
    echo "No internet connectivity. Please check your connection and try again."
    exit 1
  fi
}

# Function to check if a command exists
command_exists() {
  command -v "$1" &>/dev/null
}

# Function to run commands as root
run_as_root() {
  echo "[INFO] Running as root: $*"
  sudo "$@"
}

# Function to install Terraform
install_terraform() {
  echo "Terraform not found. Installing Terraform 1.10.4..."
  wget https://releases.hashicorp.com/terraform/1.10.4/terraform_1.10.4_linux_amd64.zip -O /tmp/terraform.zip
  run_as_root apt-get update && run_as_root apt-get install -y unzip wget
  run_as_root unzip /tmp/terraform.zip -d /usr/local/bin/
  rm /tmp/terraform.zip
  echo "Terraform 1.10.4 installed successfully."
}

# Function to install Ansible
install_ansible() {
  echo "Ansible not found. Installing Ansible..."
  run_as_root apt-get update && run_as_root apt-get install -y ansible
  echo "Ansible installed successfully."
}

# Function to install Git
install_git() {
  echo "Git not found. Installing Git..."
  run_as_root apt-get update && run_as_root apt-get install -y git
  echo "Git installed successfully."
}

# Function to install Empire
install_empire() {
  echo "Empire not found. Installing Empire..."
  run_as_root mkdir -p /opt/Empire
  run_as_root chown -R "$USER:$USER" /opt/Empire/
  cd /opt/Empire/
  git clone --recursive https://github.com/BC-SECURITY/Empire.git /opt/Empire
  cd /opt/Empire || exit
  ./setup/checkout-latest-tag.sh
  ./ps-empire install -y
  echo "Empire installed successfully."
}

# Main script execution

# Check for Internet Connectivity
check_internet

# Check for Git
if command_exists git; then
  echo "Git is already installed."
else
  install_git
fi

# Check for Terraform
if command_exists terraform; then
  echo "Terraform is already installed."
else
  install_terraform
fi

# Check for Ansible
if command_exists ansible; then
  echo "Ansible is already installed."
else
  install_ansible
fi

# Check for Empire
if [ -f /opt/Empire/ps-empire ]; then
  echo "Empire is already installed."
else
  install_empire
fi

echo "All checks and installations completed successfully."
PreviousEmpireNextLab 1: Environment Orientation and Spinning up

Last updated 4 months ago