Wordpress ad oggi è la piattaforma CMS più diffusa al mondo, di conseguenza anche la più analizzata sotto l’aspetto della sicurezza.
Per testare ed escludere la propria copia di wordpress da eventuali vulnerabilità note, è possibile utilizzare il software scanner WPScan.
Nel repository ufficiale CentOS non esiste il pacchetto precompilato di wpscan, quindi andrà scaricato e compilato manualmente.

Scenario e requisiti

Ambiente di test

  • Versione Linux: CentOS 6.5 (x86_64)
  • Versione WPScan: 2.3

Prerequisiti ( dal sito ufficiale wpscan.org )

  • Windows not supported
  • Ruby >= 1.9.2 – Recommended: 1.9.3
  • Curl >= 7.21 – Recommended: latest – FYI the 7.29 has a segfault
  • RubyGems – Recommended: latest
  • Git
  1. Installazione delle dipendenze =================================

WPScan è scritto con il linguaggio di scripting Ruby e necessita almeno della versione 1.9.2 .
Per installare tale versione su CentOS, rimando al mio articolo raggiungibile da QUI.

Il resto delle dipendenze possono essere installaretramite yum:

[root@wpscan_test ~]# yum install gcc git ruby-devel libxml2 libxml2-devel libxslt libxslt-devel libcurl-devel git
  1. Installazione WPScan =======================

Tramite git scaricare l’ultima versione di WPScan:

[root@wpscan_test ~]# git clone https://github.com/wpscanteam/wpscan.git
Initialized empty Git repository in /root/wpscan/.git/
remote: Reusing existing pack: 11357, done.
remote: Total 11357 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (11357/11357), 7.88 MiB | 440 KiB/s, done.
Resolving deltas: 100% (6456/6456), done.

Concluso il download, entrere nella directory e compilare il programma:

[root@wpscan_test ~]# ls
wpscan

[root@wpscan_test ~]# cd wpscan/

[root@wpscan_test wpscan]# gem install bundler && bundle install --without test development
Fetching: bundler-1.6.1.gem (100%)
Successfully installed bundler-1.6.1
1 gem installed
Installing ri documentation for bundler-1.6.1...
Installing RDoc documentation for bundler-1.6.1...
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Installing ffi 1.9.3
Installing ethon 0.7.0
Installing json 1.8.1
Installing mini_portile 0.5.3
Installing nokogiri 1.6.1
Installing ruby-progressbar 1.4.2
Installing terminal-table 1.4.5
Installing typhoeus 0.6.8
Using bundler 1.6.1
Your bundle is complete!
Gems in the groups test and development were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

Terminata la compilazione, testare il corretto funzionamento di wpscan:

[root@wpscan_test wpscan]# ./wpscan.rb
_______________________________________________________________
        __          _______   _____
        \ \        / /  __ \ / ____|
         \ \  /\  / /| |__) | (___   ___  __ _ _ __
          \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \
           \  /\  /  | |     ____) | (__| (_| | | | |
            \/  \/   |_|    |_____/ \___|\__,_|_| |_|

        WordPress Security Scanner by the WPScan Team
                    Version v2.3r59131b6
     Sponsored by the RandomStorm Open Source Initiative
   @_WPScan_, @ethicalhack3r, @erwan_lr, pvdl, @_FireFart_
_______________________________________________________________
....
....
....
  1. Scansione con WPScan =======================

WPScan offre varie opzioni di scansione, da quelle invasive a quelle soltanto informative.
Digitando il comando: “./wpscan.rb –help ” verrà stampata a video l’intera lista dei parametri con relativa descrizione.
Per avere un quadro generale della propria piattaforma wordpress ed effettuare anche dei test di sicurezza, lo switch da utilizzare è: –url

[root@wpscan_test wpscan]# ./wpscan.rb --url http://www.example.it
_______________________________________________________________
        __          _______   _____
        \ \        / /  __ \ / ____|
         \ \  /\  / /| |__) | (___   ___  __ _ _ __
          \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \
           \  /\  /  | |     ____) | (__| (_| | | | |
            \/  \/   |_|    |_____/ \___|\__,_|_| |_|

        WordPress Security Scanner by the WPScan Team
                    Version v2.3r59131b6
     Sponsored by the RandomStorm Open Source Initiative
   @_WPScan_, @ethicalhack3r, @erwan_lr, pvdl, @_FireFart_
_______________________________________________________________

[+] URL: http://www.example.it/
[+] Started: Fri Apr  4 14:24:44 2014

[+] robots.txt available under: 'http://www.example.it/robots.txt'
[+] Interesting header: Apache/2.2.15 (Unix) DAV/2
[+] XML-RPC Interface available under: http://www.example.it/xmlrpc.php

[+] WordPress version 3.8.1 identified from meta generator

[+] WordPress theme in use: k2 - v1.0.3

 | Name: k2 - v1.0.3
 | Location: http://www.example.it/wp-content/themes/k2/
 | Style URL: http://www.example.it/wp-content/themes/k2/style.css
 | Theme Name: K2
 | Theme URI: http://getk2.com
 | Description: <strong><a href="themes.php?page=k2-options">Configure K2</a></strong> or visit the <a href="http...
 | Author: Various Artists
 | Author URI: http://getk2.com/

[+] Enumerating plugins from passive detection ...
 |  1 plugins found:

 | Name: add-to-any - v1.2.9.2
 | Location: http://www.example.it/wp-content/plugins/add-to-any/
 | Readme: http://www.example.it/wp-content/plugins/add-to-any/README.txt

[+] Finished: Fri Apr  4 14:24:52 2014
[+] Memory used: 1.133 MB
[+] Elapsed time: 00:00:07

In questo caso WPScan non rileva alcuna vurnerabilità conosciuta, ma mostra soltanto alcune informazioni tipo la versione di wordpress,il nome del tema,i plugins installati, il web server in cui risiede la piattaforma ecc… Quando lo scanner rileva qualche possibile vurnerabilità, oltre che segnalare il problema, fornisce gli url dei siti in cui è possibile approfondire le notizie sul bug ( e magari come installare una patch).

[+] Enumerating plugins from passive detection ...
 |  5 plugins found:

 | Name: contact-form-7 - v3.7.2
 | Location:http://www.example.it/wp-content/plugins/contact-form-7/
 | Readme:http://www.example.it/wp-content/plugins/contact-form-7/readme.txt
 |
 | * Title: Contact Form 7 3.5.3 - Crafted File Extension Upload Remote Code Execution
 | * Reference: http://packetstormsecurity.com/files/125018/
 | * Reference: http://seclists.org/fulldisclosure/2014/Feb/0
 | * Reference: http://osvdb.org/102776

 | Name: jquery-slider-for-featured-content - v1.1
 | Location:http://www.example.it/wp-content/plugins/jquery-slider-for-featured-content/
 | Readme:http://www.example.it/wp-content/plugins/jquery-slider-for-featured-content/readme.txt

 | Name: leaguemanager - v3.8.8.1
 | Location:http://www.example.it/wp-content/plugins/leaguemanager/
 | Readme:http://www.example.it/wp-content/plugins/leaguemanager/readme.txt
 |
 | * Title: LeagueManager <= 3.7 - wp-admin/admin.php Multiple Parameter XSS
 | * Reference: http://packetstormsecurity.com/files/112698/
 | * Reference: http://www.securityfocus.com/bid/53525
 | * Reference: http://xforce.iss.net/xforce/xfdb/75629
 | * Reference: http://secunia.com/advisories/49949
 | * Reference: http://osvdb.org/82266
 |
 | * Title: LeagueManager 3.8 - SQL Injection
 | * Reference: http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2013-1852
 | * Reference: http://osvdb.org/91442
 | * Reference: http://www.exploit-db.com/exploits/24789/
  1. Schedulazione scan ed invio report tramite e-mail ====================================================

Per schedulare una scansione automatica del proprio sito wordpress, basta creare uno semplice script da eseguire tramite il demone cron.
Ponendo il caso di voler effettuare una scansione settimanale, si deve creare il file “/etc/cron.weekly/wpscan” ed al suo interno scrivere:

#!/bin/sh

# Directory installazione WPScan
wpsdir="/root/wpscan"

# Url sito wordpress
wpurl="http://www.example.it"

# Generatore data/ora stile: HH:mm dd/mm/YYYY
data=$(date "+%H:%M %d/%m/%Y")

# Indirizzo e-mail destinatario report
email="[email protected]"

# Entra nella directory di wpscan
cd $wpsdir

# Aggiorna database vurnerabilita' WPScan
ruby wpscan.rb --update

# Esegui WPScan ed invia report per e-mail

ruby wpscan.rb --url $wpurl | mail -s "WPScan Report $data" $email

Per concludere la procedura, rendere eseguibile lo script:

[root@wpscan_test wpscan]# chmod +x /etc/cron.weekly/wpscan