生存報告

主に情報セキュリティ関連のエントリをたまに書いて、存命であることを報告するページ。

CMSの脆弱性スキャナをいくつか試した

これまで、CMSってWordPressくらいしか触ったことない&脆弱性スキャナもWPScanくらいしか知らなかったので、情報収集がてら検証してみた。

昨年末に検証したログを記録として残しておく。1

対象のCMS脆弱性スキャナ

選定基準は以下のとおり。

  • CMS製品はシェアの大きいものを対象とする
  • 脆弱性の検証ということで、CMSはある程度、脆弱性の存在するバージョンとする。検証時点(2017年12月)から1年前時点の最新版とする
  • 脆弱性スキャナはKitPloitでヒットしたものから選定する

シェアは以下を参考にした。 Usage Statistics and Market Share of Content Management Systems for Websites, January 2018

選定の結果、以下の表のようになった。2

CMS Scanner Known Vulnerability
WordPress 4.7 WPScan 2.9.3 NVD - CVE-2017-5487
etc.
Joomla! 3.6.5 JoomScan 0.0.4
joomlavs
CMSsc4n 2.0
NVD - CVE-2017-9933
etc.
Drupal 8.2.4 Dropescan 1.40.1
CMSsc4n 2.0
NVD - CVE-2017-6919
etc.

CMSUbuntu Server、攻撃側はKali Linuxを使用。(一部例外あり)

実行結果とセットアップ時のメモ

セットアップ時のメモは主に自分用。

WordPress

公式サイトと5分間インストールを参考にインストールした。

WordPress のインストール - WordPress Codex 日本語版

Joomla!

インストールがうまくいかず調べたらPHPのモジュールが足りない模様。以下でインストール。

sudo apt-get install php7.0-xml

Drupal

こちらもモジュールが必要。 そのあとwgetで持ってきて、展開→公開ディレクトリにシンボリックリンク

sudo apt-get install php-gd
sudo apt-get install php-xml
wget https://ftp.drupal.org/files/projects/drupal-8.2.4.tar.gz

WPScan

https://wpscan.org/

Kali Linuxに入っている。メジャーなスキャナなだけあって色々検出してくる。

実行結果:

# wpscan --url http://192.168.112.135/wordpress/ --enumerate
_______________________________________________________________
        __          _______   _____                  
        \ \        / /  __ \ / ____|                 
         \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
          \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \ 
           \  /\  /  | |     ____) | (__| (_| | | | |
            \/  \/   |_|    |_____/ \___|\__,_|_| |_|

        WordPress Security Scanner by the WPScan Team 
                       Version 2.9.3
          Sponsored by Sucuri - https://sucuri.net
   @_WPScan_, @ethicalhack3r, @erwan_lr, pvdl, @_FireFart_
_______________________________________________________________

[+] URL: http://192.168.112.135/wordpress/
[+] Started: Fri Dec 29 10:01:22 2017

[!] The WordPress 'http://192.168.112.135/wordpress/readme.html' file exists exposing a version number
[+] Interesting header: LINK: <http://192.168.112.135/wordpress/wp-json/>; rel="https://api.w.org/"
[+] Interesting header: SERVER: Apache/2.4.18 (Ubuntu)
[+] XML-RPC Interface available under: http://192.168.112.135/wordpress/xmlrpc.php
[!] Includes directory has directory listing enabled: http://192.168.112.135/wordpress/wp-includes/

(snip)

[!] Title: WordPress 4.7 - User Information Disclosure via REST API
    Reference: https://wpvulndb.com/vulnerabilities/8715
    Reference: https://www.wordfence.com/blog/2016/12/wordfence-blocks-username-harvesting-via-new-rest-api-wp-4-7/
    Reference: https://github.com/WordPress/WordPress/commit/daf358983cc1ce0c77bf6d2de2ebbb43df2add60
    Reference: https://wordpress.org/news/2017/01/wordpress-4-7-1-security-and-maintenance-release/
    Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5487
[i] Fixed in: 4.7.1

(snip)

[+] Enumerating usernames ...
[+] Identified the following 1 user/s:
    +----+-------+---------+
    | Id | Login | Name    |
    +----+-------+---------+
    | 1  | admin | 404 Not |
    +----+-------+---------+
[!] Default first WordPress username 'admin' is still used

JoomScan

Category:OWASP Joomla Vulnerability Scanner Project - OWASP

github.com

OWASPのプロジェクトになっている。バージョン判定のほか、既知の脆弱性の判定もやってくれる。 スキャナの更新が2012年で止まっている?ので、現行の脆弱性には対応しなさそう。

git cloneしてインストール、URL指定して実行する。

git clone https://github.com/rezasp/joomscan.git
joomscan -u http://192.168.112.135/joomla/

実行結果:

 ..|''||   '|| '||'  '|'     |      .|'''.|  '||''|.  
.|'    ||   '|. '|.  .'     |||     ||..  '   ||   || 
||      ||   ||  ||  |     |  ||     ''|||.   ||...|' 
'|.     ||    ||| |||     .''''|.  .     '||  ||      
 ''|...|'      |   |     .|.  .||. |'....|'  .||.     
    
(snip)

Target: http://192.168.112.135/joomla
Server: Apache/2.4.18 (Ubuntu)

## Checking if the target has deployed an Anti-Scanner measure

[!] Scanning Passed ..... OK 

## Detecting Joomla! based Firewall ...

[!] No known firewall detected!

## Fingerprinting in progress ...

~Unable to detect the version. Is it sure a Joomla? 

## Fingerprinting done.

Vulnerabilities Discovered
==========================

# 1
Info -> Generic: htaccess.txt has not been renamed. 
Versions Affected: Any
Check: /htaccess.txt
Exploit: Generic defenses implemented in .htaccess are not available, so exploiting is more likely to succeed.

Vulnerable? Yes

# 2
Info -> Generic: Unprotected Administrator directory 
Versions Affected: Any
Check: /administrator/
Exploit: The default /administrator directory is detected. Attackers can bruteforce administrator accounts. Read: http://yehg.net/lab/pr0js/view.php/MULTIPLE%20TRICKY%20WAYS%20TO%20PROTECT.pdf

Vulnerable? Yes

# 3
Info -> Core: Multiple XSS/CSRF Vulnerability 
Versions Affected: 1.5.9 <= 
Check: /?1.5.9-x
Exploit: A series of XSS and CSRF faults exist in the administrator application.  Affected administrator components include com_admin, com_media, com_search.  Both com_admin and com_search contain XSS vulnerabilities, and com_media contains 2 CSRF vulnerabilities.  

Vulnerable? N/A

(snip)

joomlavs

github.com

バージョンチェックはやってくれる。脆弱性の検出はなかった。

実行にあたり、Ubunturubyではrubyモジュールの追加インストールが必要だった。スキャナを走らせてエラーメッセージを眺めつつ、必要なモジュールをがしがしインストール。 gemでのインストールがrootでできなかったので、攻撃側もUbuntu Serverで実行。

インストール用:

ruby -v
sudo gem install bundler && bundle instal
sudo apt-get install build-essential patch
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev libcurl4-openssl-dev
sudo gem install slop
sudo gem install typhoeus
sudo gem install nokogiri
sudo gem install colorize

実行結果:

./joomlavs.rb -u http://192.168.112.135/joomla/ --scan-all

----------------------------------------------------------------------

     ██╗ ██████╗  ██████╗ ███╗   ███╗██╗      █████╗ ██╗   ██╗███████╗
     ██║██╔═══██╗██╔═══██╗████╗ ████║██║     ██╔══██╗██║   ██║██╔════╝
     ██║██║   ██║██║   ██║██╔████╔██║██║     ███████║██║   ██║███████╗
██   ██║██║   ██║██║   ██║██║╚██╔╝██║██║     ██╔══██║╚██╗ ██╔╝╚════██║
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║  ██║ ╚████╔╝ ███████║
 ╚════╝  ╚═════╝  ╚═════╝ ╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝  ╚═══╝  ╚══════╝

----------------------------------------------------------------------

[+]URL: http://192.168.112.135/joomla/

[+]Started: Fri Dec 29 09:20:02 2017

[+]Found 1 interesting headers.

| Server: Apache/2.4.18 (Ubuntu)

[!]Listing enabled: http://192.168.112.135/joomla/administrator/components/

[!]Listing enabled: http://192.168.112.135/joomla/administrator/modules/

[!]Listing enabled: http://192.168.112.135/joomla/administrator/templates/

[+]Joomla version 3.6.5 identified from admin manifest

[!]Found 0 vulnerabilities affecting this version of Joomla!

[+]Scanning for vulnerable components...

[!]Found 0 vulnerable components.

------------------------------------------------------------------

[+]Scanning for vulnerable modules...

[!]Found 0 vulnerable modules.

------------------------------------------------------------------

[+]Scanning for vulnerable templates...

[!]Found 0 vulnerable templates.

------------------------------------------------------------------

Dropescan

github.com

バージョンチェックはやってくれる。脆弱性の検出はなかった。

git cloneとモジュールのインストールで完了。URLを指定して実行。

# droopescan scan drupal -u http://192.168.112.135/drupal/

実行結果:

[+] No themes found.

[+] No interesting urls found.

[+] Possible version(s):
    8.2.3

[+] No plugins found.

出力が素っ気ない。(悪いというわけではない)

CMSsc4n

github.com

CMSの使用有無とバージョンを判定してくれる。既知の脆弱性などは見ない。あとJSONExcelかで出力できるというちょっと変わった仕様。

Joomla!をスキャンする際、ローカルの環境では/joomla/まで指定しないといけなかった。手動で見るより少しマシくらいか。

スキャン対象の情報をJSONで指定する。JSONの書式が分からなかったので、ソースコードを読みつつトライ・アンド・エラーで実行。

JSONファイル:

# cat testsite.json 
{"192.168.112.135/joomla/": "text"}

実行コマンド:

python ./cmssc4n.py -e 2 -i testsite.json

実行結果:

  / ____|  \/  |/ ____|        | || |      
 | |    | \  / | (___  ___  ___| || |_ _ __  
 | |    | |\/| |\___ \/ __|/ __|__   _| '_ \ 
 | |____| |  | |____) \__ \ (__   | | | | | |
  \_____|_|  |_|_____/|___/\___|  |_| |_| |_|

** Tool to scan if a domain is a CMS (Wordpress , Drupal, Joomla, Prestashop or Moodle) and return the version
    ** Author: Ignacio Brihuega Rodriguez a.k.a N4xh4ck5
    ** Version 1.0
    ** DISCLAMER This tool was developed for educational goals. 
    ** The author is not responsible for using to others goals.
    ** A high power, carries a high responsibility!

192.168.112.135/joomla/

*****Checking if the CMS is a Wordpress*****
The CMS is not a Wordpress

*****Checking if the CMS is a Moodle*****
The CMS is not a Moodle

*****Checking if the CMS is a Drupal*****
The CMS is not a Drupal

*****Checking if the CMS is a Joomla*****
The CMS is a Joomla! => /language/en-GB/en-GB.xml file found. Trying to detect the version
Version Joomla detected in /language/en-GB/en-GB.xml ==> Joomla 3.6.5
The version Joomla is outdated

192.168.112.135/joomla/  is joomla
Exporting the results in a json

DrupalはJoomlaのときと同じ書式で実行できず。原因不明。

所感

  • 実用的なのはWPScanくらい。他のツールは環境あればやっておくか、くらい。
  • JoomScanも良いんだけどメンテされていないのがネック。3
  • どのツールも、Hack用ツールらしくアスキーアートでロゴ作っててすごい。自分もツールを作る際は見習いたい。

まとめ

シェアの大きいCMSを対象に、いくつかスキャナを試した。結論としてはやはりWPScanが実用レベル、他は無いより良いくらいだった。

が、シェアがWordPress一強なのであまり問題ないでしょう。4


  1. 残しておかないと自分も覚えていないお蔵入りになりそうなので。

  2. MovableTypeはシェアなさそうだし、とりあえず対象外。今回は種類を試すのが主旨なのでWordPressスキャナはWPScanのみ。

  3. プルリクしろという話だろうか……

  4. そのとき考えよう、の意