【小ネタ】CMSmapでWordPressを攻めてみる!

2015.08.19

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

こんにちは、城内です。
もう8月も後半に入りましたが、皆さま夏は満喫されましたでしょうか?
海で海水浴や山でキャンプ、夜にはお祭りや花火大会。夏はいろいろと盛り沢山ですね。

ということで、今回はCMSmapというCMS用のセキュリティチェックツールを使った小ネタです。

はじめに

まずは、WordPressの環境を用意します。
以下の記事を参考に、デフォルトでさくっと起動しましょう。

やってみた

CMSmapは、GitHubで公開されています。

とりあえず、READMEに書かれている通り、git cloneします。

# git clone https://github.com/Dionach/CMSmap.git

cmsmap.pyがプログラムになります。
実行は以下の感じで、ちょっとオプションもつけてみました。-f WはWordPressの強制スキャンで、-Fはフルスキャンとのことです。

# python cmsmap.py -t http://sandbox-wp.elasticbeanstalk.com/ -f W -F
[-] Date & Time: 19/08/2015 03:00:11
[-] Target: http://sandbox-wp.elasticbeanstalk.com
[M] Website Not in HTTPS: http://sandbox-wp.elasticbeanstalk.com
[I] Server: Apache
[L] X-Frame-Options: Not Enforced
[I] Strict-Transport-Security: Not Enforced
[I] X-Content-Security-Policy: Not Enforced
[I] X-Content-Type-Options: Not Enforced
[L] Robots.txt Found: http://sandbox-wp.elasticbeanstalk.com/robots.txt
[I] CMS Detection: WordPress
[I] WordPress Version: 4.2.4
[I] WordPress Theme: twentyfifteen
[-] Enumerating WordPress Usernames via "Feed" ...
[-] Enumerating WordPress Usernames via "Author" ...
[M] wpadmin
[H] Valid ADMIN Credentials: wpadmin password
[H] Valid credentials: wpadmin password . Do you want to try uploading a shell?
[-] (If you are not admin, you won't be able to)
[y/N]: y
[-] Logging in to the target website as wpadmin:password
[ERROR] Unable to upload a shell. Try it manually
[M] Website vulnerable to XML-RPC Brute Force Vulnerability
[I] Autocomplete Off Not Found: http://sandbox-wp.elasticbeanstalk.com/wp-login.php
[-] Default WordPress Files:
[I] http://sandbox-wp.elasticbeanstalk.com/readme.html
[I] http://sandbox-wp.elasticbeanstalk.com/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/images/crystal/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/images/crystal/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/js/plupload/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/js/tinymce/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/js/swfupload/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/ID3/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/ID3/readme.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/ID3/license.commercial.txt
[-] Interesting Directories/Files ...
[L] http://sandbox-wp.elasticbeanstalk.com/0/
[L] http://sandbox-wp.elasticbeanstalk.com/2015/
[L] http://sandbox-wp.elasticbeanstalk.com/dashboard/
[L] http://sandbox-wp.elasticbeanstalk.com/h/
[L] http://sandbox-wp.elasticbeanstalk.com/s/
[L] http://sandbox-wp.elasticbeanstalk.com/hello/
[-] Searching WordPress Plugins ...
[I] akismet
[I] wp-multibyte-patch
[-] Searching WordPress Themes ...
[I] twentyfourteen
[I] twentythirteen
[-] Searching WordPress TimThumbs ...
[I] Checking for Directory Listing Enabled ...
[-] Date & Time: 19/08/2015 03:09:53
[-] Completed in: 0:09:41

各出力行の先頭にある[H][M]が、メッセージの緊急度を示すレベルのようです。
[H]は「High」で、[M]は「Mid」、[L]は「Low」、[I]は「Info」といったところでしょうか。

最低限、[H][M]くらいは対処したほうが良さそうですね。

解説

[M] Website Not in HTTPS: http://sandbox-wp.elasticbeanstalk.com
これは、SSLを使用してないけど大丈夫なのという警告ですが、これはWebサイトの要件次第なので、今回はスルーします。
[M] wpadmin
これは、WordPressのユーザ名がバレてますよという警告です。これに対しては、「Edit Author Slug」などのプラグインを利用して、「author slug」を別の名前に変更することで本当のユーザ名を隠ぺいしましょう。

wp_04

[H] Valid ADMIN Credentials: wpadmin password
これは非常にまずいですね。パスワードがクラックされています。間違っても「password」なんてパスワードは使用してはいけません!(今回はわざとですよ)
[H] Valid credentials: wpadmin password . Do you want to try uploading a shell?
これは、パスワードが分かったので、シェルをアップロードしてみようか?と聞かれています。この後、yと入力すると、「CMSmap - WordPress Shell」というプラグインがインストールされます。

wp_02

[ERROR] Unable to upload a shell. Try it manually
これはCMSmapのエラーメッセージです。シェルのアップロードに失敗したというメッセージですが、実際は成功していますので、ご注意ください(これはバグ?)。コードを読むと、正しくは、緊急度「High」で、プラグインのインストールに成功したから削除しておいてね的なメッセージが表示されるようです。
[M] Website vulnerable to XML-RPC Brute Force Vulnerability
これは、XML-RPCによるブルートフォースアタックの危険性があるよという警告メッセージです。XML-RPCを使用しないようであれば、無効化しておいた方が安全なようです。「Disable XML-RPC」などのプラグインを利用すると、簡単に無効化できます。

wp_03

対策後

ということで、上記で必要そうな対策をした結果が以下になります。

# python cmsmap.py -t http://sandbox-wp.elasticbeanstalk.com/ -f W -F
[-] Date & Time: 19/08/2015 10:09:17
[-] Target: http://sandbox-wp.elasticbeanstalk.com
[M] Website Not in HTTPS: http://sandbox-wp.elasticbeanstalk.com
[I] Server: Apache
[L] X-Frame-Options: Not Enforced
[I] Strict-Transport-Security: Not Enforced
[I] X-Content-Security-Policy: Not Enforced
[I] X-Content-Type-Options: Not Enforced
[L] Robots.txt Found: http://sandbox-wp.elasticbeanstalk.com/robots.txt
[I] CMS Detection: WordPress
[I] WordPress Version: 4.2.4
[I] WordPress Theme: twentyfifteen
[-] Enumerating WordPress Usernames via "Feed" ...
[-] Enumerating WordPress Usernames via "Author" ...
[M] custom
[I] Autocomplete Off Not Found: http://sandbox-wp.elasticbeanstalk.com/wp-login.php
[-] Default WordPress Files:
[I] http://sandbox-wp.elasticbeanstalk.com/readme.html
[I] http://sandbox-wp.elasticbeanstalk.com/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/images/crystal/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/images/crystal/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/js/plupload/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/js/tinymce/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/js/swfupload/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/ID3/license.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/ID3/readme.txt
[I] http://sandbox-wp.elasticbeanstalk.com/wp-includes/ID3/license.commercial.txt
[-] Interesting Directories/Files ...
[L] http://sandbox-wp.elasticbeanstalk.com/0/
[L] http://sandbox-wp.elasticbeanstalk.com/dashboard/
[-] Searching WordPress Plugins ...
[I] akismet
[I] disable-xml-rpc
[I] wp-multibyte-patch
[-] Searching WordPress Themes ...
[I] atom
[I] twentyfourteen
[I] twentythirteen
[-] Searching WordPress TimThumbs ...
[I] Checking for Directory Listing Enabled ...
[-] Date & Time: 19/08/2015 10:37:22
[-] Completed in: 0:28:04

かなりきれいになりました。
HTTPSは除いて、[M] customが出ていますが、これは本当のユーザ名ではないので問題ありません。

さいごに

私はWordPressのプロではないので、本当に堅牢な状態を作ろうと思うとなかなか難しいですが、このようなツールを使うことでセキュリティリスクが少しでも減らせるのであれば、やってみる価値はあるかと思います。

ちなみに、結構な負荷をかけるようですので、実行の際はご注意ください。
(EC2インスタンスがt2.microだったこともあり、BeanstalkのAuto Scalingが発動していました)