En esta entrada vamos a aprender como auditar WordPress con WPScan en OSX. Vamos, primero, a ver cómo se instala en este sistema operativo y luego alguna de sus funcionalidades más básicas.
WPScan es un software escrito en Ruby usado para realizar un escaneo de vulnerabilidades de sitios web WordPress.
Entre otras cosas, auditar WordPress con WPScan nos puede arrojar datos como los usuarios de la base de datos, o los plugins instalados y sus versiones (incluído si son vulnerables o no) y algunas cosas más que luego veremos.
Este software está patrocinado por Sucuri, una empresa de seguridad web bastante conocida dentro del mundo WordPress al disponer de un plugin para proteger el gestor de contenidos así como un firewall web y un servicio de limpieza de sitios WordPress infectados.
Instalación de WPScan en OSX
La verdad es que los pasos para instalar WPSCan en OSX no son demasiado complicados pero tiene una serie de requerimientos que estaría bien tenerlos contemplados antes de empezar la instalación.
- XCode.
- Ruby.
- Ruby Gem Bundler.
- Curl.
- Git.
- WPScan
Comprobando la instalación de Curl
cURL para que nos entendamos de forma rápida y sencilla es un proyecto que consiste en una librería y un intérprete de línea de comandos para realizar transferencia de archivos. El tenerlo instalado nos permite simular acciones de los usuarios a través de un navegador web.
Para ver si está instalado en nuestro sistema OSX debemos escribir en la terminal:
curl -V
Instalando XCode
Nos olvidamos de la línea de comandos por unos momentos y a través de la App Store podemos descargarnos el entorno de desarrollo para OSX.
Con XCode dispondremos del compilador necesario para luego a la hora de instalar y compilar Ruby.
Os aconsejo que tengáis bastante espacio libre en el disco duro pues ocupa bastante una vez descargado e instalado.
Instalando Git
Git es un un sistema distribuido de control de versiones, lo vamos a usar para descargarnos WPScan del repositorio de GitGub.
Para instalarlo en OSX es relativamente sencillo, basta con ir a su página web, descargarlo e instalarlo. Lo podéis descargar directamente de aquí.
Descargando WPScan desde GitHub
Una vez instalado Git abrimos un terminal y yendo a la carpeta bajo la que queramos instalar WPScan tenemos que clonar el repositorio de la nube en nuestro Mac. Para ello con esta simple instrucción podemos hacerlo:
git clone https://github.com/wpscanteam/wpscan.git
Con esto tendremos ya WPScan en una carpeta de nuestro Mac esperando a instalar Ruby para poder hacerlo funcionar.
Ruby, instalación con RVM
La forma más sencilla de instalar Ruby en mi Mac ha sido usando RVM (Ruby Version Manager), una instrucción para la línea de comandos para instalar y gestionar versiones de Ruby.
Para instalarlo en el terminal debemos introducir la siguiente instrucción.
curl -sSL https://get.rvm.io | bash -s stable
Para instalar Ruby.
rvm install ruby-2.3.3 cd wpscan sudo gem install bundler && sudo bundle install --without test
Con estas 3 líneas hemos instalado Ruby, hemos entrado en el directorio donde se ha clonado el repositorio de WPScan y hemos instalado la Gem Bundler para que gestione y mantenga actualizadas las dependencias del programa.
Si todo ha ido bien, dentro de la carpeta wpscan ya podremos auditar WordPress con WPScan en OSX.
ruby wpscan.rb --help _______________________________________________________________ __ _______ _____ \ \ / / __ \ / ____| \ \ /\ / /| |__) | (___ ___ __ _ _ __ ® \ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \ \ /\ / | | ____) | (__| (_| | | | | \/ \/ |_| |_____/ \___|\__,_|_| |_| WordPress Security Scanner by the WPScan Team Version 2.9.2 Sponsored by Sucuri - https://sucuri.net @_WPScan_, @ethicalhack3r, @erwan_lr, pvdl, @_FireFart_ _______________________________________________________________ Help : Some values are settable in a config file, see the example.conf.json --update Update the database to the latest version. --url | -u <target url> The WordPress URL/domain to scan. --force | -f Forces WPScan to not check if the remote site is running WordPress. --enumerate | -e [option(s)] Enumeration. option : u usernames from id 1 to 10 u[10-20] usernames from id 10 to 20 (you must write [] chars) p plugins vp only vulnerable plugins ap all plugins (can take a long time) tt timthumbs t themes vt only vulnerable themes at all themes (can take a long time) Multiple values are allowed : "-e tt,p" will enumerate timthumbs and plugins If no option is supplied, the default is "vt,tt,u,vp" --exclude-content-based "<regexp or string>" Used with the enumeration option, will exclude all occurrences based on the regexp or string supplied. You do not need to provide the regexp delimiters, but you must write the quotes (simple or double). --config-file | -c <config file> Use the specified config file, see the example.conf.json. --user-agent | -a <User-Agent> Use the specified User-Agent. --cookie <string> String to read cookies from. --random-agent | -r Use a random User-Agent. --follow-redirection If the target url has a redirection, it will be followed without asking if you wanted to do so or not --batch Never ask for user input, use the default behaviour. --no-color Do not use colors in the output. --log Creates a log.txt file with WPScan's output. --no-banner Prevents the WPScan banner from being displayed. --disable-accept-header Prevents WPScan sending the Accept HTTP header. --disable-referer Prevents setting the Referer header. --disable-tls-checks Disables SSL/TLS certificate verification. --wp-content-dir <wp content dir> WPScan try to find the content directory (ie wp-content) by scanning the index page, however you can specify it. Subdirectories are allowed. --wp-plugins-dir <wp plugins dir> Same thing than --wp-content-dir but for the plugins directory. If not supplied, WPScan will use wp-content-dir/plugins. Subdirectories are allowed --proxy <[protocol://]host:port> Supply a proxy. HTTP, SOCKS4 SOCKS4A and SOCKS5 are supported. If no protocol is given (format host:port), HTTP will be used. --proxy-auth <username:password> Supply the proxy login credentials. --basic-auth <username:password> Set the HTTP Basic authentication. --wordlist | -w <wordlist> Supply a wordlist for the password brute forcer. --username | -U <username> Only brute force the supplied username. --usernames <path-to-file> Only brute force the usernames from the file. --cache-dir <cache-directory> Set the cache directory. --cache-ttl <cache-ttl> Typhoeus cache TTL. --request-timeout <request-timeout> Request Timeout. --connect-timeout <connect-timeout> Connect Timeout. --threads | -t <number of threads> The number of threads to use when multi-threading requests. --max-threads <max-threads> Maximum Threads. --throttle <milliseconds> Milliseconds to wait before doing another web request. If used, the --threads should be set to 1. --help | -h This help screen. --verbose | -v Verbose output. --version Output the current version and exit. Examples : -Further help ... ruby wpscan.rb --help -Do 'non-intrusive' checks ... ruby wpscan.rb --url www.example.com -Do wordlist password brute force on enumerated users using 50 threads ... ruby wpscan.rb --url www.example.com --wordlist darkc0de.lst --threads 50 -Do wordlist password brute force on the 'admin' username only ... ruby wpscan.rb --url www.example.com --wordlist darkc0de.lst --username admin -Enumerate installed plugins ... ruby wpscan.rb --url www.example.com --enumerate p -Enumerate installed themes ... ruby wpscan.rb --url www.example.com --enumerate t -Enumerate users ... ruby wpscan.rb --url www.example.com --enumerate u -Enumerate installed timthumbs ... ruby wpscan.rb --url www.example.com --enumerate tt -Use a HTTP proxy ... ruby wpscan.rb --url www.example.com --proxy 127.0.0.1:8118 -Use a SOCKS5 proxy ... (cURL >= v7.21.7 needed) ruby wpscan.rb --url www.example.com --proxy socks5://127.0.0.1:9000 -Use custom content directory ... ruby wpscan.rb -u www.example.com --wp-content-dir custom-content -Use custom plugins directory ... ruby wpscan.rb -u www.example.com --wp-plugins-dir wp-content/custom-plugins -Update the DB ... ruby wpscan.rb --update -Debug output ... ruby wpscan.rb --url www.example.com --debug-output 2>debug.log See README for further information.
Con todo esto ya podemos auditar WordPress con WPScan en OSX.
Ejemplos de uso de WPScan
Llegó la hora de divertirse. Yo normalmente lo uso para ver el estado de las webs de otras agencias o para echar un vistazo al estado general de WordPress que van a llegar a mis manos. O simplemente a veces solo para jugar.
Por ejemplo… decidme una web… va… venga. La web de Vertele (¿no sabíais que estaba montada en WordPress? Pues sí, así es. Vamos a descubrir los usuarios que tiene en la base de datos.
ruby wpscan.rb --url http://www.vertele.com --enumerate u [+] Enumerating usernames ... [+] Identified the following 1 user/s: +----+-------+---------+ | Id | Login | Name | +----+-------+---------+ | 1 | admin | Vertele | +----+-------+---------+ [!] Default first WordPress username 'admin' is still used
Si señor… una web con un tráfico orgánico estimado brutal tiene como único usuario a admin.
También podemos ver los plugins vulnerables que tiene instalados, una opción más para auditar WordPress con WPScan en OSX.
ruby wpscan.rb --url http://www.vertele.com --enumerate vp
Además el propio WPScan en cada escaneo nos da información interesante del sitio web como cabeceras, versión de WordPress y otros datos de interés.
[+] URL: http://www.vertele.com/ [+] Started: Fri Dec 16 12:54:36 2016 [+] robots.txt available under: 'http://www.vertele.com/robots.txt' [!] A wp-config.php backup file has been found in: 'http://www.vertele.com/wp-config.php.old' [+] Interesting header: AGE: 33 [+] Interesting header: CF-RAY: 3121f11413422f2f-MAD [+] Interesting header: SERVER: cloudflare-nginx [+] Interesting header: VIA: 1.1 www.vertele.com:3128 (squid) [+] Interesting header: VIA: 1.1 varnish [+] Interesting header: X-CACHE: HIT from www.vertele.com [+] Interesting header: X-CACHE-LOOKUP: HIT from www.vertele.com:3128 [+] Interesting header: X-POWERED-BY: PHP/5.3.29-1~dotdeb.0 [+] Interesting header: X-VARNISH: 616978048 616977441 [+] This site has 'Must Use Plugins' (http://codex.wordpress.org/Must_Use_Plugins) [+] XML-RPC Interface available under: http://www.vertele.com/xmlrpc.php [+] WordPress version 3.2.1 (Released on 2011-07-12) identified from advanced fingerprinting, meta generator, rss generator, rdf generator, atom generator, links opml [!] 19 vulnerabilities identified from the version number
¡Bueno! Ya tenéis una herramienta más con la que pasar el tiempo probando cositas y haciendo auditorías de seguridad para WordPress. Ya sabéis auditar WordPress con WPScan en OSX.
Si tenéis dudas con la instalación hacédmelo saber y si sé os echaré una mano.