T-Potについて
- HoneyPotをGCPに立てる
- HoneyPotとしては、一つで複数のハニーポットが立てられるT-Potを利用する
- 好きな場所にVMを置ける&セキュリティの観点からも、GCPのCompute EngineのVMインスタンスを利用すると良き
- 国によって攻撃元の国が異なったりするのかなとか調べたり、、
GCPの設定
ファイアーウォールの設定
- 全てのポートを許可する設定をする
- GCPは明示的にルールを書かないと解放されない
- VPCネットワーク→Firewall
- ファイアーウォールルールを設定ボタン
- 以下の画像の通りに設定
- 管理者用画面、sshはログインかかる
- 必要に応じて、ポート番号(例:64294, 64295, 64297)をファイアーウォールで制限しても良い。
- このルール以外は削除する
- ファイアーウォールルールを設定ボタン
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. |
- e2-standard-4(4 vCPU、2 コア、16 GB メモリ)を使用する
- Debian GNU/Linux 12 (bookworm)
- ストレージ:256GB
- ネットワーキング→ネットワークタグ
- default
- default
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のデフォルトのメール転送エージェント (MTA) と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
しばらく見ていると、以下のようにT-podのメインプロセスが失敗し、コンテナを停止するログが見つかる。
このエラーが起こる理由は、Debianのデフォルトのメール転送エージェント (MTA) の仕様で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番ポートを使用しているプロセスを停止wさせる。
そのために、まず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 systemctl restart tpot
http://VMの外部IP:64297/にアクセスすると、T-Podの管理画面にアクセスできる。
結構見ていると、T-Podにアクセス飛んできているの見れて楽しい。