T-Potについて

GCPの設定

ファイアーウォールの設定

Compute Engineの設定

T-Pot Type RAM Storage Description
Hive 16GB 256GB SSD As a rule of thumb, the more honeypots, sensors & data, the more RAM and storage is needed.

作ったVMインスタンスにSSHで接続する

VMに接続して、T-Potをインストール

sudo apt update
env bash -c "$(curl -sL https://github.com/telekom-security/tpotce/raw/master/install.sh)"

install Typeは、一番多くのハニーポットが建てられるので、hを選択

### Choose your T-Pot type:
### (H)ive   - T-Pot Standard / HIVE installation.
###            Includes also everything you need for a distributed setup with sensors.
### (S)ensor - T-Pot Sensor installation.
###            Optimized for a distributed installation, without WebUI, Elasticsearch and Kibana.
### (L)LM    - T-Pot LLM installation.
###            Uses LLM based honeypots Beelzebub & Galah.
###            Requires Ollama (recommended) or ChatGPT subscription.
### M(i)ni   - T-Pot Mini installation.
###            Run 30+ honeypots with just a couple of honeypot daemons.
### (M)obile - T-Pot Mobile installation.
###            Includes everything to run T-Pot Mobile (available separately).
### (T)arpit - T-Pot Tarpit installation.
###            Feed data endlessly to attackers, bots and scanners.
###            Also runs a Denial of Service Honeypot (ddospot).

### Install Type? (h/s/l/i/m/t) h

### Installing T-Pot Standard / HIVE.

### T-Pot User Configuration ...

インストール完了したら、再起動する

sudo reboot

管理用のsshのポートが22番から、T-Potによって64295番に変更されてるので、「ブラウザウィンドウでカスタムポートを開く」で64295番を指定する

T-Potは再起動後に自動的に起動するので、上手くいっているかを確認する

sudo systemctl status tpot

T-Podを自分の環境で試したときは、activeになっているので上手くいっているかのように思われた。
しかし、[http://<VMの外部IP>:64297/]にアクセスできたり出来なかったりする事象が確認された。
これは、後述するが、GCEのDebianの仕様とT-Podの仕様が噛み合ってしまって、実際には正常に動いていないのに、systemctl status tpotではactiveになり、さも動いているかのように見えてしまうという事象である。

honeypot_trap_3@t-pot-2:~$ sudo systemctl status tpot
● tpot.service - T-Pot
     Loaded: loaded (/etc/systemd/system/tpot.service; enabled; preset: enabled)
     Active: active (running) since Tue 2024-12-31 13:07:43 UTC; 19s ago
    Process: 35168 ExecStartPre=/usr/bin/docker compose -f /home/honeypot_trap_3/tpotce/docker-compose.yml down -v (code=exited, status=0/SUCCESS)
   Main PID: 37368 (docker)
      Tasks: 20 (limit: 19175)
     Memory: 43.5M
        CPU: 1.459s
     CGroup: /system.slice/tpot.service
             ├─37368 /usr/bin/docker compose -f /home/honeypot_trap_3/tpotce/docker-compose.yml up
             └─37385 /usr/libexec/docker/cli-plugins/docker-compose compose -f /home/honeypot_trap_3/tpotce/docker-compose.yml up

Dec 31 13:08:00 t-pot-2 docker[37385]: tanner_redis         |   `-._    `-._`-.__.-'_.-'    _.-'
Dec 31 13:08:00 t-pot-2 docker[37385]: tanner_redis         |       `-._    `-.__.-'    _.-'
Dec 31 13:08:00 t-pot-2 docker[37385]: tanner_redis         |           `-._        _.-'
Dec 31 13:08:00 t-pot-2 docker[37385]: tanner_redis         |               `-.__.-'
Dec 31 13:08:00 t-pot-2 docker[37385]: tanner_redis         |
Dec 31 13:08:00 t-pot-2 docker[37385]: tanner_redis         | 1:M 31 Dec 2024 13:08:00.690 * Server initialized
Dec 31 13:08:00 t-pot-2 docker[37385]: tanner_redis         | 1:M 31 Dec 2024 13:08:00.690 * Ready to accept connections tcp
Dec 31 13:08:01 t-pot-2 docker[37385]: adbhoney             | INFO:config:Loading config from ./_internal/adbhoney.cfg
Dec 31 13:08:01 t-pot-2 docker[37385]: adbhoney             | INFO:ADBHoneypot:Configuration loaded with ['output_log', 'output_json'] as output plugins
Dec 31 13:08:01 t-pot-2 docker[37385]: adbhoney             | INFO:ADBHoneypot:Listening on 0.0.0.0:5555.

この事象を回避するための処理を行う。
問題なのは、T-Podは、上手くいかないとバックグラウンドでT-Podは再起動を繰り返すことである。
そのため、どこでエラーが起きているのかが、systemctlコマンドでは見つけにくいのであると思う。
まず、以下のコマンドで、T-Podのログを見る。

sudo journalctl -u tpot.service -f

しばらく見ていると、以下のようにメインプロセスで失敗し、コンテナが停止しているログが見つかる。
このエラーが起こる理由は、Debianの仕様で25番ポートを使用しており、T-Podも使用しようとしているためである。

Dec 31 13:10:03 t-pot-2 docker[44591]: Error response from daemon: driver failed programming external connectivity on endpoint mailoney (7303cd1b57e19c217baa8f83fdfe1879f2a71c3953cbaae9a411203df4980333): failed to bind port 0.0.0.0:25/tcp: Error starting userland proxy: listen tcp4 0.0.0.0:25: bind: address already in use
Dec 31 13:10:03 t-pot-2 systemd[1]: tpot.service: Main process exited, code=exited, status=1/FAILURE
Dec 31 13:10:03 t-pot-2 systemd[1]: tpot.service: Failed with result 'exit-code'.

今回は、T-Podを優先したいので、Debian側の25番ポートを使用しているプロセスを停止/パージさせる。
そのために、まずGCE側の25番ポートを使用しているプロセスを特定する。
lsofコマンドを使用する。

sudo apt install lsof
sudo lsof -i :25

自分の環境ではこのようになっていた。

honeypot_trap_3@t-pot-2:~$ sudo lsof -i :25
COMMAND PID        USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
exim4   819 Debian-exim    4u  IPv4   2714      0t0  TCP localhost:smtp (LISTEN)
exim4   819 Debian-exim    5u  IPv6   2715      0t0  TCP localhost:smtp (LISTEN)

自分の環境では、exim4が25番ポートを使用していたため、exim4プロセスをストップさせる。

sudo systemctl stop exim4
sudo apt purge exim4 exim4-*

これで自分の環境は問題が解決した。

sudo systemctl restart tpot

[http://<VMの外部IP>:64297/]にアクセスすると、T-Podの管理画面にアクセスできる。
結構見ていると、T-Podにアクセス飛んできているの見れて楽しい。

30日間でデータが消えないようにするために

T-Pot → Kibana → # Stack Management → Index Lifecycle Policies
以下の写真の右の「Include managed system policies」ボタンをオンにする。

tpotを探してクリック
右下のManageボタンをクリック→Edit

画像のようにCold Phaseをオンにして、「Move data into phase when:30 days old」に設定
Save Policy