【Cape Sandbox】Cape SandboxのHost構築

Sandbox

こんにちはmOqOmです。
今回はUbuntu Desktop 22.04.2 LTSにCapeV2 Sandboxを構築する方法を紹介していきます。
以下の公式ページのインストールを元に作成していきます。

Cape SandboxのHost構築

Hostの環境は以下のようになります。

  • Ubuntu Desktop 22.04.2 LTS (CapeV2のホスト)
    • プロセッサ: 8コア
    • メモリサイズ: 16GB
    • ハードディスクサイズ: 128GB
    • ユーザ名: cape

aptのアップデートとアップグレード

まず初めにaptのアップデートとアップグレードを以下のコマンドを用いて行います。

# アップデートとアップグレード
sudo apt-get update
sudo apt upgrade

KVMのダウンロードとインストール

aptのアップデートとアップグレードが完了したら次にKVMのダウンロードとインストールを行います。

KVMのダウンロード

以下のコマンドを用いてgithubからKVMのインストーラーのシェルをダウンロードします。

# KVMのダウンロード
wget https://raw.githubusercontent.com/kevoreilly/CAPEv2/master/installer/kvm-qemu.sh

KVMのインストール

上記でダウンロードしたKVMのインストールシェルに実行権限を与え、KVMをインストールします。
また【 <username> 】の場所を使用しているユーザ名に変更してください。
今回の環境の場合の【 <username> 】は【 cape 】となります。
KVMのインストール後OSの再起動を行います。

# 実行権限の付与
chmod +x ./kvm-qemu.sh
# KVMとマネージャーのインストール
sudo ./kvm-qemu.sh all <username> | sudo tee kvm-qemu.log
sudo ./kvm-qemu.sh virtmanager <username> | sudo tee kvm-qemu-virt-manager.log
# 再起動
sudo reboot

CapeV2のダウンロードとインストール

KVMのインストールが完了したらCapeV2のダウンロードとインストールを行います。

CapeV2のダウンロード

以下のコマンドを用いてgithubからcape2のインストーラーのシェルをダウンロードします。

# CapeV2のダウンロード
wget https://raw.githubusercontent.com/kevoreilly/CAPEv2/master/installer/cape2.sh

CapeV2のインストール

上記でダウンロードしたcape2のインストールシェルに実行権限を与え、cape2をインストールします。cape2のインストール後OSの再起動を行います。

# 実行権限の付与
chmod +x ./cape2.sh
# CapeV2のインストール
sudo ./cape2.sh all cape | sudo tee cape.log
# 再起動
sudo reboot

CapeのConfigファイルの編集

auxiliary.confの編集

tcpdumpが監視するネットワーク インターフェイス名を指定するため以下のコマンドを用いてconfファイルを修正します。

sudo nano /opt/CAPEv2/conf/auxiliary.conf

インターフェース名を【 virbr1 】から【 virbr0 】に変更します。
※今回はKVMのデフォルトインターフェースを指定しています。

変更前のauxiliary.conf

# Specify the network interface name on which tcpdump should monitor the
# traffic. Make sure the interface is active.
interface = virbr1

変更後のauxiliary.conf

# Specify the network interface name on which tcpdump should monitor the
# traffic. Make sure the interface is active.
interface = virbr0

cuckoo.confの編集

ResultServerに結果を返すためのIPアドレスを指定するため以下のコマンドを用いてconfファイルを修正します。

sudo nano /opt/CAPEv2/conf/cuckoo.conf

IPアドレスを使用する仮想マシンのデフォルトゲートウェイに変更します。
※今回はKVMのvirbr0のデフォルトゲートウェイを用いるので【 192.168.1.1 】から【 192.168.122.1 】へと変更してます。

修正前のcuckoo.conf

[resultserver]
# The Result Server is used to receive in real time the behavioral logs
# produced by the analyzer.
# Specify the IP address of the host. The analysis machines should be able
# to contact the host through such address, so make sure it's valid.
# NOTE: if you set resultserver IP to 0.0.0.0 you have to set the option
# `resultserver_ip` for all your virtual machines in machinery configuration.
ip = 192.168.1.1

後正前のcuckoo.conf

[resultserver]
# The Result Server is used to receive in real time the behavioral logs
# produced by the analyzer.
# Specify the IP address of the host. The analysis machines should be able
# to contact the host through such address, so make sure it's valid.
# NOTE: if you set resultserver IP to 0.0.0.0 you have to set the option
# `resultserver_ip` for all your virtual machines in machinery configuration.
ip = 192.168.122.1

reporting.confの編集

mongodbを有効化するために以下のコマンドを用いてconfファイルを修正します。

sudo nano /opt/CAPEv2/conf/reporting.conf

修正前のreporting.conf

[mongodb]
enabled = no
host = 127.0.0.1
port = 27017
db = cuckoo

修正後のreporting.conf

[mongodb]
enabled = yes
host = 127.0.0.1
port = 27017
db = cuckoo

routing.confの編集

ネットワークルーティングモードを使用するため以下のコマンドを用いてrouting.confを修正します。
※routeを【 internet 】へ変更し、インターフェースをKVMのデフォルとインターフェースである【 virbr0 】を指定します。

sudo nano /opt/CAPEv2/conf/routing.conf

修正前のrouting.conf

# Default network routing mode; "none", "internet", or "vpn_name".
# In none mode we don't do any special routing - the VM doesn't have any
# network access (this has been the default actually for quite a while).
# In internet mode by default all the VMs will be routed through the network
# interface configured below (the "dirty line").
# And in VPN mode by default the VMs will be routed through the VPN identified
# by the given name of the VPN.
# Note that just like enabling VPN configuration setting this option to
# anything other than "none" requires one to run utils/rooter.py as root next
# to the CAPE instance (as it's required for setting up the routing).
route = none

# Network interface that allows a VM to connect to the entire internet, the
# "dirty line" so to say. Note that, just like with the VPNs, this will allow
# malicious traffic through your network. So think twice before enabling it.
# (For example, to route all VMs through eth0 by default: "internet = eth0").
internet = none

修正後のrouting.conf

# Default network routing mode; "none", "internet", or "vpn_name".
# In none mode we don't do any special routing - the VM doesn't have any
# network access (this has been the default actually for quite a while).
# In internet mode by default all the VMs will be routed through the network
# interface configured below (the "dirty line").
# And in VPN mode by default the VMs will be routed through the VPN identified
# by the given name of the VPN.
# Note that just like enabling VPN configuration setting this option to
# anything other than "none" requires one to run utils/rooter.py as root next
# to the CAPE instance (as it's required for setting up the routing).
route = internet

# Network interface that allows a VM to connect to the entire internet, the
# "dirty line" so to say. Note that, just like with the VPNs, this will allow
# malicious traffic through your network. So think twice before enabling it.
# (For example, to route all VMs through eth0 by default: "internet = eth0").
internet = virbr0

その他Configファイルの編集について

cuckoo.confとweb.confの修正については、Guest構築の際に修正しますので、以下のリンクを参照してください。

次回の更新までお待ちください…

コメント

タイトルとURLをコピーしました