unfucked the havoc_installer
This commit is contained in:
+47
-33
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Streamlined Havoc C2 Framework installer with EDR evasion features
|
# Enhanced Havoc C2 Framework installer optimized for Red Team Operations
|
||||||
# This script automatically installs Havoc and prepares it for configuration
|
# This script installs and configures Havoc with EDR evasion features
|
||||||
|
# The mutation features are applied BEFORE building to ensure proper compilation
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
@@ -11,6 +12,7 @@ COMPILER_URL="http://musl.cc/x86_64-w64-mingw32-cross.tgz"
|
|||||||
COMPILER_DIR="/usr/bin/x86_64-w64-mingw32-cross"
|
COMPILER_DIR="/usr/bin/x86_64-w64-mingw32-cross"
|
||||||
COMPILER_PATH="$COMPILER_DIR/bin/x86_64-w64-mingw32-gcc"
|
COMPILER_PATH="$COMPILER_DIR/bin/x86_64-w64-mingw32-gcc"
|
||||||
IMPLANT_MUTATOR_SCRIPT="$HAVOC_DIR/implant_mutator.sh"
|
IMPLANT_MUTATOR_SCRIPT="$HAVOC_DIR/implant_mutator.sh"
|
||||||
|
HAVOC_GITHUB="https://github.com/HavocFramework/Havoc.git"
|
||||||
|
|
||||||
# Function to log messages
|
# Function to log messages
|
||||||
log() {
|
log() {
|
||||||
@@ -29,12 +31,16 @@ RANDOMIZED_BUILD_ID=$(random_string 16)
|
|||||||
# Install required dependencies
|
# Install required dependencies
|
||||||
log "Installing dependencies..."
|
log "Installing dependencies..."
|
||||||
apt-get update >/dev/null 2>&1
|
apt-get update >/dev/null 2>&1
|
||||||
apt-get install -y git golang-go make build-essential mingw-w64 nasm cmake \
|
apt-get install -y git build-essential apt-utils cmake libfontconfig1 libglu1-mesa-dev libgtest-dev libspdlog-dev libboost-all-dev libncurses5-dev libgdbm-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev mesa-common-dev qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5websockets5 libqt5websockets5-dev qtdeclarative5-dev golang-go qtbase5-dev libqt5websockets5-dev python3-dev libboost-all-dev mingw-w64 nasm >/dev/null 2>&1
|
||||||
ninja-build python3-pip libfontconfig1 libglu1-mesa-dev libgtest-dev \
|
|
||||||
libspdlog-dev libboost-all-dev libncurses5-dev libgdbm-dev libssl-dev \
|
# Fix for JSON dependency
|
||||||
libreadline-dev libffi-dev libsqlite3-dev libbz2-dev mesa-common-dev \
|
log "Installing nlohmann-json manually..."
|
||||||
qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5websockets5 \
|
mkdir -p /tmp/json
|
||||||
libqt5websockets5-dev binutils-dev wget >/dev/null 2>&1
|
cd /tmp/json
|
||||||
|
wget -q https://github.com/nlohmann/json/releases/download/v3.11.2/json.hpp
|
||||||
|
mkdir -p /usr/include/nlohmann
|
||||||
|
cp json.hpp /usr/include/nlohmann/
|
||||||
|
cd - > /dev/null
|
||||||
|
|
||||||
# Setup Go environment
|
# Setup Go environment
|
||||||
log "Setting up Go environment..."
|
log "Setting up Go environment..."
|
||||||
@@ -72,6 +78,7 @@ if [ -d "$HAVOC_DIR" ]; then
|
|||||||
cd $HAVOC_DIR
|
cd $HAVOC_DIR
|
||||||
git pull
|
git pull
|
||||||
else
|
else
|
||||||
|
# Clone with proper GitHub URL
|
||||||
git clone --quiet -b dev $HAVOC_GITHUB $HAVOC_DIR
|
git clone --quiet -b dev $HAVOC_GITHUB $HAVOC_DIR
|
||||||
cd $HAVOC_DIR
|
cd $HAVOC_DIR
|
||||||
fi
|
fi
|
||||||
@@ -81,11 +88,13 @@ mkdir -p $HAVOC_DATA_DIR
|
|||||||
mkdir -p $HAVOC_DIR/payloads
|
mkdir -p $HAVOC_DIR/payloads
|
||||||
mkdir -p $HAVOC_DIR/payloads/backup
|
mkdir -p $HAVOC_DIR/payloads/backup
|
||||||
|
|
||||||
# Apply source mutations first (before building)
|
# Initialize submodules
|
||||||
log "Applying implant mutations with signature: $RANDOMIZED_BUILD_ID"
|
log "Initializing submodules..."
|
||||||
# We'll skip the metadata.go modification since it's not essential
|
cd $HAVOC_DIR
|
||||||
|
git submodule init
|
||||||
|
git submodule update --recursive
|
||||||
|
|
||||||
# Create implant mutator script
|
# Create implant mutator script BEFORE building
|
||||||
log "Creating implant mutator script..."
|
log "Creating implant mutator script..."
|
||||||
cat > "$IMPLANT_MUTATOR_SCRIPT" << 'EOF'
|
cat > "$IMPLANT_MUTATOR_SCRIPT" << 'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
@@ -93,7 +102,7 @@ cat > "$IMPLANT_MUTATOR_SCRIPT" << 'EOF'
|
|||||||
# Randomizes critical implant signatures to avoid detection
|
# Randomizes critical implant signatures to avoid detection
|
||||||
|
|
||||||
# === CONFIG ===
|
# === CONFIG ===
|
||||||
HAVOC_ROOT="${HAVOC_ROOT:-$HOME/Tools/Havoc}"
|
HAVOC_ROOT="${HAVOC_ROOT:-$HOME/Tools/havoc}"
|
||||||
IMPLANT_DIR="$HAVOC_ROOT/payloads/Demon"
|
IMPLANT_DIR="$HAVOC_ROOT/payloads/Demon"
|
||||||
SRC_DIR="$IMPLANT_DIR/src"
|
SRC_DIR="$IMPLANT_DIR/src"
|
||||||
OUTPUT_DIR="$HAVOC_ROOT/payloads"
|
OUTPUT_DIR="$HAVOC_ROOT/payloads"
|
||||||
@@ -550,22 +559,34 @@ EOF
|
|||||||
|
|
||||||
chmod +x "$IMPLANT_MUTATOR_SCRIPT"
|
chmod +x "$IMPLANT_MUTATOR_SCRIPT"
|
||||||
|
|
||||||
# Build Havoc teamserver with custom compiler flags
|
# Perform mutations BEFORE building - this is critical
|
||||||
log "Building Havoc teamserver..."
|
log "Running implant mutations script before building..."
|
||||||
|
if [ -d "$HAVOC_DIR/payloads/Demon" ]; then
|
||||||
|
$IMPLANT_MUTATOR_SCRIPT --no-functions
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log "Warning: Implant mutation script ran with errors, but continuing build..."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "Skipping implant mutations as Demon directory not found yet. Will be applied after build."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install additional Go dependencies for the teamserver
|
||||||
|
log "Installing Go dependencies for teamserver..."
|
||||||
cd $HAVOC_DIR/teamserver
|
cd $HAVOC_DIR/teamserver
|
||||||
export EXTRA_GOFLAGS="-ldflags=-buildid=$(random_string 16)"
|
go mod download golang.org/x/sys
|
||||||
go build -trimpath -ldflags="-w -s -buildid=$(random_string 16)" -o havoc main.go
|
cd $HAVOC_DIR
|
||||||
|
|
||||||
|
# Build Havoc using make - build teamserver first
|
||||||
|
log "Building Havoc teamserver..."
|
||||||
|
cd $HAVOC_DIR
|
||||||
|
make ts-build
|
||||||
|
|
||||||
# Build Havoc client
|
# Build Havoc client
|
||||||
log "Building Havoc client..."
|
log "Building Havoc client..."
|
||||||
cd $HAVOC_DIR/client
|
make client-build
|
||||||
mkdir -p build
|
|
||||||
cd build
|
|
||||||
cmake -GNinja ..
|
|
||||||
ninja
|
|
||||||
|
|
||||||
# Create systemd service for Havoc
|
# Create systemd service for Havoc
|
||||||
log "Creating systemd service for Havoc Teamserver..."
|
log "Creating systemd service for Havoc teamserver..."
|
||||||
cat > /etc/systemd/system/havoc.service << EOF
|
cat > /etc/systemd/system/havoc.service << EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Advanced Security Service
|
Description=Advanced Security Service
|
||||||
@@ -576,7 +597,7 @@ Type=simple
|
|||||||
User=root
|
User=root
|
||||||
Group=root
|
Group=root
|
||||||
WorkingDirectory=$HAVOC_DIR/teamserver
|
WorkingDirectory=$HAVOC_DIR/teamserver
|
||||||
ExecStart=$HAVOC_DIR/teamserver/havoc server -d
|
ExecStart=$HAVOC_DIR/havoc server -d
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
@@ -591,18 +612,12 @@ EOF
|
|||||||
|
|
||||||
# Set proper permissions
|
# Set proper permissions
|
||||||
log "Setting proper permissions..."
|
log "Setting proper permissions..."
|
||||||
chmod 755 $HAVOC_DIR/teamserver/havoc
|
chmod -R 755 $HAVOC_DIR
|
||||||
chmod 755 $HAVOC_DIR/client/havoc
|
|
||||||
|
|
||||||
# Create symlinks to executables in /usr/local/bin
|
# Create symlinks to executables in /usr/local/bin
|
||||||
ln -sf $HAVOC_DIR/teamserver/havoc /usr/local/bin/havoc-server
|
ln -sf $HAVOC_DIR/havoc /usr/local/bin/havoc
|
||||||
ln -sf $HAVOC_DIR/client/havoc /usr/local/bin/havoc-client
|
|
||||||
ln -sf $IMPLANT_MUTATOR_SCRIPT /usr/local/bin/havoc-mutate
|
ln -sf $IMPLANT_MUTATOR_SCRIPT /usr/local/bin/havoc-mutate
|
||||||
|
|
||||||
# Run the implant mutator
|
|
||||||
log "Running initial implant mutation..."
|
|
||||||
$IMPLANT_MUTATOR_SCRIPT --no-functions
|
|
||||||
|
|
||||||
# Enable and start Havoc service
|
# Enable and start Havoc service
|
||||||
log "Enabling and starting Havoc service..."
|
log "Enabling and starting Havoc service..."
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
@@ -610,4 +625,3 @@ systemctl enable havoc
|
|||||||
systemctl start havoc
|
systemctl start havoc
|
||||||
|
|
||||||
log "Havoc C2 installation completed successfully!"
|
log "Havoc C2 installation completed successfully!"
|
||||||
log "Use the template-based configuration for additional setup."
|
|
||||||
Reference in New Issue
Block a user