LoginSignup
0
0

More than 3 years have passed since last update.

さくらVPSでハニーポットcowrieを導入する.ubuntu18.04を利用

Posted at

はじめに

この記事は自分の遊びのメモとして残しています.所属企業や所属大学などとは一切関係ないのでそちらを最初に記させていただきます.
※ハニーボットの導入に際しては,調べた限りさくらVPSを利用して導入すること自体に問題はなさそうですが今後または,今現在完璧に問題ありません!と断言できるものでもないので自己判断で導入されることをお勧めします.その際に本番SSHのセキュリティを固くすることを強くお勧めします.

今回導入するハニーポット

こちらを導入します.cowrie

cowrieとは...

Cowrieは不正アクセスの情報を知るためのハニーポットです。Cowrieは、sshやtelnetといったサーバーを遠隔操作するためのソフトウェアに対する不正アクセスの情報を記録できます。
参照:https://procspace.net/blog/security/21/

導入

以下のドキュメントをもとに導入しました
参考:https://cowrie.readthedocs.io/en/latest/INSTALL.html

0,専用のアカウントを作成しましょう!(非root権限で!)

$ sudo adduser username

このあとパスワードを決めるアナウンスをされます.
それを決めたら全てenterで問題ありません.

1,関連ライブラリを導入

$ sudo apt-get install git python-virtualenv libssl-dev libffi-dev build-essential libpython3-dev python3-minimal authbind virtualenv

2,githubからコードをインストール

$ sudo su username
$ git clone http://github.com/cowrie/cowrie

3,仮想化の導入(python)

機械学習とかでも良く個人的にはやります.本番環境のpythonを壊すとめんどくさいことになるのでpythonは仮想環境を作りましょう.
「必要な機能を必要最低限の権限で!」

$ cd hogehoge/cowrie
$ virtualenv --python=python3 cowrie-env
$ cd cowire-env/bin
$ source activate

4,パッケージインストール

$ cd ../../
$ pip install --upgrade -r requirements.txt

5,構成ファイルの設定

$ cd etc
$ cp cowrie.cfg.dist cowrie.cfg
$ vim cowrie.cfg

SSHの設定

# Endpoint to listen on for incoming SSH connections.
# See https://twistedmatrix.com/documents/current/core/howto/endpoints.html#servers
# (default: listen_endpoints = tcp:2222:interface=0.0.0.0)
# (use systemd: endpoint for systemd activation)
# listen_endpoints = systemd:domain=INET:index=0
# For both IPv4 and IPv6: listen_endpoints = tcp6:2222:interface=\:\:
# Listening on multiple endpoints is supported with a single space seperator
# e.g listen_endpoints = "tcp:2222:interface=0.0.0.0 tcp:1022:interface=0.0.0.0" will result listening both on ports 2222 and 1022
# use authbind for port numbers under 1024

listen_endpoints = tcp:2222:interface=0.0.0.0
#listen_endpoints = tcp:2222:interface=0.0.0.0を
#listen_endpoints = tcp:22:interface=0.0.0.0に変更

6,cowrieを実行

$ cd ../bin coweie start

番外編:ポート22を使う場合の設定

ポートリダイレクションをする方法もあるが個人的には,非root権限に例外的リッスンするのが良い気がします.
※特にさくらVPSで導入する場合には...

Authbindの利用

$ sudo apt-get install authbind
$ sudo touch /etc/authbind/byport/22
$ sudo chown cowrie:cowrie /etc/authbind/byport/22
$ sudo chmod 770 /etc/authbind/byport/22

こんな感じで導入することができます.

最後に

これからハニーポットの分析系の記事もあげていきたいと思いますので宜しくお願い致します.
それでは...

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0